예제 #1
0
        public void ReadBinaryTest()
        {
            var container = new ProteinBenchmarkService
            {
                FileName = Path.Combine("..\\..\\TestFiles", Constants.BenchmarkCacheFileName),
            };

            container.Read();
            Assert.AreEqual(1246, container.GetAll().Count);
        }
예제 #2
0
        public void WriteAndReadBinaryTest()
        {
            var collection = new ProteinBenchmarkService
            {
                FileName = "TestProteinBenchmark.dat",
            };

            collection.Data = CreateTestList();
            collection.Write();
            collection.Data = null;
            collection.Read();
            ValidateTestList(collection.Data);
        }
예제 #3
0
        public void FahClient_UpdateBenchmarkData_Test()
        {
            // setup
            var benchmarkCollection = new ProteinBenchmarkService();
            var database            = MockRepository.GenerateMock <IUnitInfoDatabase>();
            var fahClient           = new FahClient(MockRepository.GenerateStub <IMessageConnection>())
            {
                BenchmarkService = benchmarkCollection, UnitInfoDatabase = database
            };

            var unitInfo1 = new UnitInfo();

            unitInfo1.OwningClientName = "Owner";
            unitInfo1.OwningClientPath = "Path";
            unitInfo1.OwningSlotId     = 0;
            unitInfo1.ProjectID        = 2669;
            unitInfo1.ProjectRun       = 1;
            unitInfo1.ProjectClone     = 2;
            unitInfo1.ProjectGen       = 3;
            unitInfo1.FinishedTime     = new DateTime(2010, 1, 1);
            unitInfo1.QueueIndex       = 0;
            var currentUnitInfo = new UnitInfoModel {
                CurrentProtein = new Protein(), UnitInfoData = unitInfo1
            };

            var unitInfo1Clone = unitInfo1.DeepClone();

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

            unitInfo1Clone.FrameData  = frameDataDictionary;
            unitInfo1Clone.UnitResult = WorkUnitResult.FinishedUnit;
            var unitInfoLogic1 = new UnitInfoModel {
                CurrentProtein = new Protein(), UnitInfoData = unitInfo1Clone
            };

            var parsedUnits = new[] { unitInfoLogic1 };

            // arrange
            database.Stub(x => x.Connected).Return(true);
            database.Expect(x => x.Insert(null)).IgnoreArguments().Repeat.Times(1);

            var benchmarkClient = new ProteinBenchmarkSlotIdentifier("Owner Slot 00", "Path");

            // assert before act
            Assert.AreEqual(false, benchmarkCollection.Contains(benchmarkClient));
            Assert.AreEqual(false, new List <int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669));
            Assert.IsNull(benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData));

            // act
            fahClient.UpdateBenchmarkData(currentUnitInfo, parsedUnits, 0);

            // assert after act
            Assert.AreEqual(true, benchmarkCollection.Contains(benchmarkClient));
            Assert.AreEqual(true, new List <int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669));
            Assert.AreEqual(TimeSpan.FromMinutes(5), benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData).AverageFrameTime);

            database.VerifyAllExpectations();
        }