public void ProteinBenchmarkSlotIdentifier_Value_Test2() { var client = new ProteinBenchmarkSlotIdentifier("name", "path"); Assert.AreEqual("name (path)", client.Value); Assert.IsFalse(client.AllSlots); }
public ICollection <ProteinBenchmark> GetBenchmarks(ProteinBenchmarkSlotIdentifier slotIdentifier, Int32 projectId) { if (slotIdentifier == null) { throw new ArgumentNullException("slotIdentifier"); } _cacheLock.EnterReadLock(); try { var list = Data.FindAll(benchmark => { if (slotIdentifier.AllSlots) { return(benchmark.ProjectID.Equals(projectId)); } if (benchmark.ToSlotIdentifier().Equals(slotIdentifier)) { return(benchmark.ProjectID.Equals(projectId)); } return(false); }); return(list.AsReadOnly()); } finally { _cacheLock.ExitReadLock(); } }
public void RemoveAll(ProteinBenchmarkSlotIdentifier slotIdentifier, int projectId) { if (slotIdentifier == null) { throw new ArgumentNullException("slotIdentifier"); } _cacheLock.EnterWriteLock(); try { Data.RemoveAll(benchmark => { if (slotIdentifier.AllSlots) { return(benchmark.ProjectID.Equals(projectId)); } if (benchmark.ToSlotIdentifier().Equals(slotIdentifier)) { return(benchmark.ProjectID.Equals(projectId)); } return(false); }); Write(); } finally { _cacheLock.ExitWriteLock(); } }
public bool Contains(ProteinBenchmarkSlotIdentifier slotIdentifier) { if (slotIdentifier == null) { throw new ArgumentNullException("slotIdentifier"); } _cacheLock.EnterReadLock(); try { return(Data.Find(benchmark => { if (slotIdentifier.AllSlots) { return true; } if (benchmark.ToSlotIdentifier().Equals(slotIdentifier)) { return true; } return false; }) != null); } finally { _cacheLock.ExitReadLock(); } }
public void ProteinBenchmarkSlotIdentifier_Value_Test1() { var client = new ProteinBenchmarkSlotIdentifier(); Assert.AreEqual("All Slots", client.Value); Assert.IsTrue(client.AllSlots); }
public void UpdateMinimumFrameTime(ProteinBenchmarkSlotIdentifier slotIdentifier, int projectId) { if (slotIdentifier == null) { throw new ArgumentNullException("slotIdentifier"); } // GetBenchmarks() BEFORE entering write lock // because it uses a read lock IEnumerable <ProteinBenchmark> benchmarks = GetBenchmarks(slotIdentifier, projectId); // write lock _cacheLock.EnterWriteLock(); try { foreach (ProteinBenchmark benchmark in benchmarks) { benchmark.UpdateMinimumFrameTime(); } Write(); } finally { _cacheLock.ExitWriteLock(); } }
public void ProteinBenchmarkSlotIdentifier_Comparison_Test3() { var client1 = new ProteinBenchmarkSlotIdentifier(); var client2 = new ProteinBenchmarkSlotIdentifier(); Assert.IsTrue(client1.Equals(client2)); Assert.IsTrue(client1.CompareTo(client2) == 0); }
public void ProteinBenchmarkSlotIdentifier_Comparison_Test2() { var client1 = new ProteinBenchmarkSlotIdentifier(); var client2 = new object(); // calls Object.Equals() override Assert.AreNotEqual(client1, client2); }
public void ProteinBenchmarkSlotIdentifier_Comparison_Test11() { var client1 = new ProteinBenchmarkSlotIdentifier("name", "path\\to\\folder\\"); var client2 = new ProteinBenchmarkSlotIdentifier("name", "path/to/folder/"); Assert.IsFalse(client1.Equals(client2)); Assert.IsTrue(client1.CompareTo(client2) > 0); }
public void ProteinBenchmarkSlotIdentifier_Comparison_Test13() { var client1 = new ProteinBenchmarkSlotIdentifier("name", "path\\"); var client2 = new ProteinBenchmarkSlotIdentifier("name2", "path\\"); Assert.IsFalse(client1.Equals(client2)); Assert.IsTrue(client1.CompareTo(client2) < 0); }
public void ProteinBenchmarkSlotIdentifier_Comparison_Test19() { var client1 = new ProteinBenchmarkSlotIdentifier(); Assert.IsFalse(null == client1); Assert.IsTrue(null != client1); //Assert.IsFalse(null < client1); //Assert.IsFalse(null > client1); }
public void ProteinBenchmarkSlotIdentifier_Comparison_Test18() { var client1 = new ProteinBenchmarkSlotIdentifier(); Assert.IsFalse(client1 == null); Assert.IsTrue(client1 != null); //Assert.IsFalse(client1 < null); //Assert.IsFalse(client1 > null); }
public void ProteinBenchmarkSlotIdentifier_Comparison_Test17() { var client1 = new ProteinBenchmarkSlotIdentifier("name", "path"); var client2 = new ProteinBenchmarkSlotIdentifier(); Assert.IsFalse(client1 == client2); Assert.IsTrue(client1 != client2); Assert.IsFalse(client1 < client2); Assert.IsTrue(client1 > client2); }
public ICollection <Int32> GetBenchmarkProjects(ProteinBenchmarkSlotIdentifier slotIdentifier) { if (slotIdentifier == null) { throw new ArgumentNullException("slotIdentifier"); } _cacheLock.EnterReadLock(); try { var projects = new List <int>(); foreach (var benchmark in Data) { if (projects.Contains(benchmark.ProjectID)) { continue; } if (slotIdentifier.AllSlots) { projects.Add(benchmark.ProjectID); } else { if (benchmark.ToSlotIdentifier().Equals(slotIdentifier)) { projects.Add(benchmark.ProjectID); } } } projects.Sort(); return(projects.AsReadOnly()); } finally { _cacheLock.ExitReadLock(); } }
public void RemoveAll(ProteinBenchmarkSlotIdentifier slotIdentifier) { if (slotIdentifier == null) { throw new ArgumentNullException("slotIdentifier"); } if (slotIdentifier.AllSlots) { throw new ArgumentException("Cannot remove all client slots."); } _cacheLock.EnterWriteLock(); try { Data.RemoveAll(benchmark => benchmark.ToSlotIdentifier().Equals(slotIdentifier)); Write(); } finally { _cacheLock.ExitWriteLock(); } }
public void ProteinBenchmarkSlotIdentifier_GetHashCode_Test2() { var client = new ProteinBenchmarkSlotIdentifier("name", "path"); Assert.AreEqual(-331019282, client.GetHashCode()); }
public void ProteinBenchmarkSlotIdentifier_Comparison_Test14() { var client1 = new ProteinBenchmarkSlotIdentifier(); Assert.IsFalse(client1.Equals(null)); }
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(); }
public void ProteinBenchmarkSlotIdentifier_GetHashCode_Test1() { var client = new ProteinBenchmarkSlotIdentifier(); Assert.AreEqual(0, client.GetHashCode()); }