Exemplo n.º 1
0
 internal static string ToProcessorAndThreadsString(this ProteinBenchmarkIdentifier identifier, SlotType slotType)
 {
     return(identifier.HasProcessor
         ? identifier.HasThreads
             ? $"{slotType}:{identifier.Threads} / {identifier.Processor}"
             : $"{slotType} / {identifier.Processor}"
         : String.Empty);
 }
Exemplo n.º 2
0
        private static IProteinBenchmarkService CreateBenchmarkServiceWithOneSlotAndProject()
        {
            var benchmarkService    = new ProteinBenchmarkService(new ProteinBenchmarkDataContainer());
            var slotIdentifier      = CreateSlotIdentifier("Test", SlotIdentifier.NoSlotID);
            var benchmarkIdentifier = new ProteinBenchmarkIdentifier(12345);

            benchmarkService.Update(slotIdentifier, benchmarkIdentifier, Array.Empty <TimeSpan>());
            return(benchmarkService);
        }
Exemplo n.º 3
0
        private static IProteinBenchmarkService CreateBenchmarkServiceWithTwoSlotsAndProjects()
        {
            var benchmarkService = new ProteinBenchmarkService(new ProteinBenchmarkDataContainer());

            var slotIdentifier      = CreateSlotIdentifier("Test", 0);
            var benchmarkIdentifier = new ProteinBenchmarkIdentifier(12345);

            benchmarkService.Update(slotIdentifier, benchmarkIdentifier, Array.Empty <TimeSpan>());

            slotIdentifier      = CreateSlotIdentifier("Test", 1);
            benchmarkIdentifier = new ProteinBenchmarkIdentifier(23456);
            benchmarkService.Update(slotIdentifier, benchmarkIdentifier, Array.Empty <TimeSpan>());
            benchmarkIdentifier = new ProteinBenchmarkIdentifier(65432);
            benchmarkService.Update(slotIdentifier, benchmarkIdentifier, Array.Empty <TimeSpan>());

            return(benchmarkService);
        }
Exemplo n.º 4
0
        public void FahClient_UpdateWorkUnitBenchmarkAndRepository()
        {
            // Arrange
            var benchmarkService       = new ProteinBenchmarkService(new ProteinBenchmarkDataContainer());
            var mockWorkUnitRepository = new Mock <IWorkUnitRepository>();
            var fahClient = new FahClient(null, new InMemoryPreferencesProvider(), benchmarkService, null, mockWorkUnitRepository.Object);

            var workUnit = new WorkUnit();

            workUnit.ProjectID    = 2669;
            workUnit.ProjectRun   = 1;
            workUnit.ProjectClone = 2;
            workUnit.ProjectGen   = 3;
            workUnit.Finished     = new DateTime(2010, 1, 1);
            workUnit.QueueIndex   = 0;
            var settings = new ClientSettings {
                Name = "Owner", Server = "Path", Port = ClientSettings.NoPort
            };
            var currentWorkUnit = new WorkUnitModel(new SlotModel(new NullClient {
                Settings = settings
            }), workUnit);
            var slotIdentifier = currentWorkUnit.SlotModel.SlotIdentifier;

            var workUnitCopy = workUnit.Copy();

            workUnitCopy.FramesObserved = 4;
            var frames = new Dictionary <int, LogLineFrameData>()
                         .With(new LogLineFrameData {
                Duration = TimeSpan.FromMinutes(0), ID = 0
            },
                               new LogLineFrameData {
                Duration = TimeSpan.FromMinutes(5), ID = 1
            },
                               new LogLineFrameData {
                Duration = TimeSpan.FromMinutes(5), ID = 2
            },
                               new LogLineFrameData {
                Duration = TimeSpan.FromMinutes(5), ID = 3
            });

            workUnitCopy.Frames     = frames;
            workUnitCopy.UnitResult = WorkUnitResult.FinishedUnit;

            var parsedUnits = new[] { new WorkUnitModel(new SlotModel(new NullClient {
                    Settings = settings
                }), workUnitCopy) };

            mockWorkUnitRepository.SetupGet(x => x.Connected).Returns(true);

            var benchmarkIdentifier = new ProteinBenchmarkIdentifier(2669);

            // Assert (pre-condition)
            Assert.IsFalse(benchmarkService.DataContainer.Data.Any(x => x.SlotIdentifier.Equals(slotIdentifier)));
            Assert.IsFalse(benchmarkService.GetBenchmarkProjects(slotIdentifier).Contains(2669));
            Assert.IsNull(benchmarkService.GetBenchmark(slotIdentifier, benchmarkIdentifier));

            // Act
            fahClient.UpdateWorkUnitBenchmarkAndRepository(currentWorkUnit, parsedUnits);

            // Assert
            Assert.IsTrue(benchmarkService.DataContainer.Data.Any(x => x.SlotIdentifier.Equals(slotIdentifier)));
            Assert.IsTrue(benchmarkService.GetBenchmarkProjects(slotIdentifier).Contains(2669));
            Assert.AreEqual(TimeSpan.FromMinutes(5), benchmarkService.GetBenchmark(slotIdentifier, benchmarkIdentifier).AverageFrameTime);

            mockWorkUnitRepository.Verify(x => x.Insert(It.IsAny <WorkUnitModel>()), Times.Once);
        }