Guid value doesn't get inserted properly into the cassandra table

40 Views Asked by At

I have following static class that I used in several unit tests in one of my project. I have the cassandra database in a docker container. I want to specifically use the Testrunid1 in the TestBase static class in other test classes. The static class is given below.

public static class TestBase
{
    public static readonly string Testrunid1 = "88c93395-3b35-4b58-9b5a-b6ab150044532";
    public static readonly DateTime Timestamp1 = DateTime.Parse("2023-09-15T11:30:42");
    public const int LogItemsNumber = 10;
    public const string TestString =
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi feugiat, diam sit amet sodales porttitor, lectus libero dapibus eros, quis venenatis nunc dui sit amet nunc. Etiam tincidunt dolor enim, dapibus gravida lacus ullamcorper vel. ";

    public const int IndexedLinesNumber = 12000;
    public static DateTime TimestampGenerator(int iteration)
    {
        var timestamp = Timestamp1;
        return timestamp.Add(TimeSpan.FromSeconds(3 * iteration));
    }

    public static IEnumerable<DumpsysData> CreateEnumerableOfDumpSysItems()
    {
        for (var i = 0; i < LogItemsNumber; i++)
        {
            yield return new DumpsysData(
                Guid.Parse(Testrunid1),
                i,
                TimestampGenerator(i),
                CreateLines(),
                CreateTableLines()
            );
        }
    }
    public static List<IndexedLine> CreateLines() 
    {
        var listOfLines = new List<IndexedLine>();
        for (var i = 0; i < IndexedLinesNumber; i++)
        {
            listOfLines.Add(new IndexedLine(i, TestString));
        }

        return listOfLines;
    }

    public static Dictionary<string, IndexedLine> CreateTableLines() 
    {
        var listOfTableLines = new Dictionary<string, IndexedLine>();
        for (var i = 0; i < IndexedLinesNumber; i++)
        {
            if (i % 1000 == 0)
            {
                listOfTableLines.Add($"Test{i}", new IndexedLine(i, TestString));
            }
        }

        return listOfTableLines;
    }
}

In another test class I have following method. Here I'm adding data to two tables. Guid in the row for TestRunById table gets added as expected (not 0s). But the Guid values go into DumpsysLog table is always 0s (00000000-0000-0000-0000-000000000000).

private async Task CreateTestDumpSysDataRows()
{
    var testRunHeader = new TestRunHeader(Guid.Parse(TestBase.Testrunid1), "TestProject", "TestVersion");
    await _analysisSession.TestRunsById.Insert(testRunHeader).ExecuteAsync();
    using var iterator = TestBase.CreateEnumerableOfDumpSysItems().GetEnumerator();

    while (iterator.MoveNext())
    {
       await _session.DumpsysLog.Insert(iterator.Current).ExecuteAsync();
    }
}

When I retrieve the data it looks like this. I'm not sure what causes this issue. enter image description here

0

There are 0 best solutions below