public void ReadBinaryTest()
      {
         var container = new ProteinBenchmarkCollection
         {
            FileName = Path.Combine("..\\..\\TestFiles", Constants.BenchmarkCacheFileName),
         };

         container.Read();
         Assert.AreEqual(1246, container.Count);
      }
      public void WriteAndReadBinaryTest()
      {
         var collection = new ProteinBenchmarkCollection
         {
            FileName = "TestProteinBenchmark.dat",
         };

         collection.Data = CreateTestList();
         collection.Write();
         collection.Data = null;
         collection.Read();
         ValidateTestList(collection.Data);
      }
Exemple #3
0
      public void UpdateBenchmarkDataTest()
      {
         // setup
         var benchmarkCollection = new ProteinBenchmarkCollection();
         var database = MockRepository.GenerateMock<IUnitInfoDatabase>();
         var fahClient = new FahClient(MockRepository.GenerateStub<IMessageConnection>()) { BenchmarkCollection = 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;
         unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(0), FrameID = 0 });
         unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(5), FrameID = 1 });
         unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(10), FrameID = 2 });
         unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(15), FrameID = 3 });
         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 BenchmarkClient("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();
      }