Exemple #1
0
        public void FahClient_UpdateBenchmarkFrameTimes_DoesNotUpdateBenchmarksWhenNoFramesAreComplete()
        {
            // Arrange
            var benchmarkService = new ProteinBenchmarkService(new ProteinBenchmarkDataContainer());
            var fahClient        = new FahClient(null, new InMemoryPreferencesProvider(), benchmarkService, null, null);

            var workUnit = new WorkUnit();

            workUnit.ProjectID    = 12345;
            workUnit.ProjectRun   = 6;
            workUnit.ProjectClone = 7;
            workUnit.ProjectGen   = 8;
            workUnit.Assigned     = DateTime.UtcNow;
            var settings = new ClientSettings {
                Name = "Foo", Server = "Bar", Port = ClientSettings.DefaultPort
            };
            var workUnitModel = new WorkUnitModel(new SlotModel(new NullClient {
                Settings = settings
            }), workUnit);
            var newWorkUnitModel = new WorkUnitModel(workUnitModel.SlotModel, workUnit.Copy());

            // Act
            fahClient.UpdateBenchmarkFrameTimes(workUnitModel, newWorkUnitModel);

            // Assert
            Assert.IsNull(benchmarkService.GetBenchmark(newWorkUnitModel.SlotModel.SlotIdentifier, newWorkUnitModel.BenchmarkIdentifier));
        }
Exemple #2
0
        // ReSharper disable InconsistentNaming

        private static FahClient CreateClient(ClientSettings settings)
        {
            var client = new FahClient(null, null, null, null, null);

            client.Settings = settings;
            return(client);
        }
Exemple #3
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);
        }