public void ProteinBenchmarkService_Update_CreatesNewBenchmark() { // Arrange using (var artifacts = new ArtifactFolder()) { var container = CreateTestDataContainer(artifacts.GetRandomFilePath()); int containerCount = container.Data.Count; var benchmarkService = new ProteinBenchmarkService(container); var clientGuid = Guid.NewGuid(); var slotIdentifier = new SlotIdentifier(new ClientIdentifier("New Client", "10.9.8.1", ClientSettings.DefaultPort, clientGuid), 0); var benchmarkIdentifier = new ProteinBenchmarkIdentifier(Int32.MaxValue, Processor, Threads); var frameTimes = new[] { TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.2), TimeSpan.FromMinutes(1.1) }; // Act benchmarkService.Update(slotIdentifier, benchmarkIdentifier, frameTimes); // Assert Assert.AreEqual(containerCount + 1, container.Data.Count); var benchmark = benchmarkService.GetBenchmark(slotIdentifier, benchmarkIdentifier); Assert.IsNotNull(benchmark); Assert.AreEqual(slotIdentifier, benchmark.SlotIdentifier); Assert.AreEqual(clientGuid, benchmark.SlotIdentifier.ClientIdentifier.Guid); Assert.AreEqual(benchmarkIdentifier, benchmark.BenchmarkIdentifier); Assert.AreEqual(3, benchmark.FrameTimes.Count); Assert.AreEqual(TimeSpan.FromMinutes(1.1), benchmark.FrameTimes[0].Duration); Assert.AreEqual(TimeSpan.FromMinutes(1.2), benchmark.FrameTimes[1].Duration); Assert.AreEqual(TimeSpan.FromMinutes(1.0), benchmark.FrameTimes[2].Duration); } }
public void ProteinBenchmarkService_GetBenchmark_BenchmarkWithoutGuidMatchesSlotIdentifierByNameAndPath() { var guid = Guid.NewGuid(); const int slotID = 0; const int projectID = 9039; var container = new ProteinBenchmarkDataContainer(); container.Data.Add(new ProteinBenchmark { SourceName = "Foo", SourcePath = "192.168.1.194:36330", SourceGuid = Guid.Empty, SourceSlotID = slotID, ProjectID = projectID, FrameTimes = new[] { 1.4, 1.6, 1.5 }.Select(ProteinBenchmarkFrameTime.FromMinutes).ToList() }); var benchmarkService = new ProteinBenchmarkService(container); var slotIdentifier = new SlotIdentifier(new ClientIdentifier("Foo", "192.168.1.194", ClientSettings.DefaultPort, guid), slotID); var benchmarkIdentifier = new ProteinBenchmarkIdentifier(projectID); // Act var benchmark = benchmarkService.GetBenchmark(slotIdentifier, benchmarkIdentifier); // Assert Assert.IsNotNull(benchmark); Assert.AreEqual(slotIdentifier.ClientIdentifier.Name, benchmark.SourceName); Assert.AreEqual(slotIdentifier.ClientIdentifier.ToServerPortString(), benchmark.SourcePath); Assert.AreNotEqual(slotIdentifier.ClientIdentifier.Guid, benchmark.SourceGuid); Assert.AreEqual(slotIdentifier.SlotID, benchmark.SourceSlotID); Assert.AreEqual(benchmarkIdentifier, benchmark.BenchmarkIdentifier); }
public void ProteinBenchmarkService_GetBenchmark_BenchmarkWithProcessorAndThreadsMatchesBenchmarkIdentifierByProjectIDAndProcessorAndThreads() { const int projectID = 9039; var container = new ProteinBenchmarkDataContainer(); var slotIdentifier = new SlotIdentifier(new ClientIdentifier("Foo", "192.168.1.194", ClientSettings.DefaultPort, Guid.NewGuid()), 0); container.Data.Add(new ProteinBenchmark { ProjectID = projectID, Processor = Processor, Threads = 12 } .UpdateFromSlotIdentifier(slotIdentifier)); container.Data.Add(new ProteinBenchmark { ProjectID = projectID, Processor = Processor, Threads = Threads } .UpdateFromSlotIdentifier(slotIdentifier)); var benchmarkService = new ProteinBenchmarkService(container); var benchmarkIdentifier = new ProteinBenchmarkIdentifier(projectID, Processor, Threads); // Act var benchmark = benchmarkService.GetBenchmark(slotIdentifier, benchmarkIdentifier); // Assert Assert.IsNotNull(benchmark); Assert.AreSame(container.Data[1], benchmark); Assert.AreEqual(slotIdentifier, benchmark.SlotIdentifier); Assert.AreEqual(benchmarkIdentifier, benchmark.BenchmarkIdentifier); }
public void ProteinBenchmarkService_GetBenchmark_BenchmarkWithGuidMatchesSlotIdentifierByGuid() { var guid = Guid.NewGuid(); const int slotID = 0; const int projectID = 9039; var container = new ProteinBenchmarkDataContainer(); container.Data.Add(new ProteinBenchmark { SourceName = "Foo", SourcePath = "192.168.1.194:36330", SourceGuid = guid, SourceSlotID = slotID, ProjectID = projectID, FrameTimes = new[] { 1.4, 1.6, 1.5 }.Select(ProteinBenchmarkFrameTime.FromMinutes).ToList() }); var benchmarkService = new ProteinBenchmarkService(container); var slotIdentifier = new SlotIdentifier(new ClientIdentifier("Bar", "192.168.1.200", 46330, guid), slotID); var benchmarkIdentifier = new ProteinBenchmarkIdentifier(projectID); // Act var benchmark = benchmarkService.GetBenchmark(slotIdentifier, benchmarkIdentifier); // Assert Assert.IsNotNull(benchmark); Assert.AreEqual(slotIdentifier, benchmark.SlotIdentifier); Assert.AreEqual(benchmarkIdentifier, benchmark.BenchmarkIdentifier); }