public void SimpleStoreTest() { var config = new MeasurementStoreConfig() { StoreType = StoreType.MicrosoftSqlServer, ConnectionString = @"server=(localdb)\MSSqlLocalDb;Database=SimpleStoreTest" }; var trace = new MeasuredTrace() { PackageFileName = "xyz" }; var measurement = new CpuSampled() { ProcessName = "Foo", IsDpc = true, Count = 100, TotalSamplesDuringInterval = 1000, CpuCoreCount = 1 }; var measurement2 = new TraceAttribute() { Name = "FooA" }; trace.AddMeasurement(measurement); trace.AddMeasurement(measurement2); using (var store = new MeasurementStore(config)) { store.Database.EnsureCreated(); store.Database.EnsureDeleted(); store.Database.EnsureCreated(); Assert.True(store.SaveTraceAndMeasurements(trace) == 3); } }
public void BasicQueriesWork() { var config = new MeasurementStoreConfig() { StoreType = StoreType.MicrosoftSqlServer, ConnectionString = @"server=(localdb)\MSSqlLocalDb;Database=QueryTests;MultipleActiveResultSets = True" }; using (var store = new MeasurementStore(config)) { store.Database.EnsureCreated(); store.Database.EnsureDeleted(); store.Database.EnsureCreated(); foreach (var n in new[] { 1, 2, 3 }) { var trace = new MeasuredTrace() { PackageFileName = $"Trace{n}" }; var measurement = new CpuSampled() { ProcessName = "ProcessX", IsDpc = true, Count = 100, TotalSamplesDuringInterval = 1000, CpuCoreCount = 1 }; var measurement2 = new TraceAttribute() { Name = "AttributeX", WholeNumberValue = n }; trace.AddMeasurement(measurement); trace.AddMeasurement(measurement2); Assert.True(store.SaveTraceAndMeasurements(trace) == 3); trace.ProcessingRecords.Add(new ProcessingRecord() { Path = "xxx", StateChangeTime = new DateTime(1980, 2, 2), ProcessingState = ProcessingState.Discovered }); Assert.True(store.SaveChanges() == 1); } } using (var store = new MeasurementStore(config)) { foreach (var trace in store.GetTraceByFilter(t => true, true)) { Assert.NotEmpty(trace.ProcessingRecords); var measurements = trace.GetMeasurementsAll(); Assert.True(measurements.Count() == 2); } } }