// //编写测试时,还可使用以下特性: // //使用 ClassInitialize 在运行类中的第一个测试前先运行代码 //[ClassInitialize()] //public static void MyClassInitialize(TestContext testContext) //{ //} // //使用 ClassCleanup 在运行完类中的所有测试后再运行代码 //[ClassCleanup()] //public static void MyClassCleanup() //{ //} // //使用 TestInitialize 在运行每个测试前先运行代码 //[TestInitialize()] //public void MyTestInitialize() //{ //} // //使用 TestCleanup 在运行完每个测试后运行代码 //[TestCleanup()] //public void MyTestCleanup() //{ //} // #endregion private static SortedSplitList <TestObject> GetSortedSplitListSortedById() { SortedSplitList <TestObject> sortedSplitList = new SortedSplitList <TestObject>(new CompareById()); var obj1 = new TestObject() { Id = 1 }; var obj2 = new TestObject() { Id = 2 }; var obj3 = new TestObject() { Id = 3 }; var obj4 = new TestObject() { Id = 4 }; sortedSplitList.Add(obj2); sortedSplitList.Add(obj4); sortedSplitList.Add(obj1); sortedSplitList.Add(obj3); return(sortedSplitList); }
public void TestEmptyEnumeration() { // Arrange var sortedSplitList = new SortedSplitList <TestObject>(new CompareById()); // Act Assert.IsFalse(sortedSplitList.Any()); }
/// <summary> ///Clear 的测试 ///</summary> public void ClearTestHelper <T>() { IComparer <T> defaultComparer = null; int deepness = 0; SortedSplitList <T> target = new SortedSplitList <T>(defaultComparer, deepness); target.Clear(); Assert.Inconclusive("无法验证不返回值的方法。"); }
public void TestPartiallyEnumerate() { var sortedSplitList = new SortedSplitList <TestObject>(new CompareByDateId()); sortedSplitList.Add(new TestObject() { Id = 1, Date = DateTime.Parse("01/01/2003") }); sortedSplitList.Add(new TestObject() { Id = 2, Date = DateTime.Parse("01/01/2003") }); sortedSplitList.Add(new TestObject() { Id = 3, Date = DateTime.Parse("01/01/2003") }); sortedSplitList.Add(new TestObject() { Id = 4, Date = DateTime.Parse("01/01/2003") }); sortedSplitList.Add(new TestObject() { Id = 5, Date = DateTime.Parse("01/02/2003") }); sortedSplitList.Add(new TestObject() { Id = 6, Date = DateTime.Parse("01/02/2003") }); sortedSplitList.Add(new TestObject() { Id = 7, Date = DateTime.Parse("01/02/2003") }); sortedSplitList.Add(new TestObject() { Id = 8, Date = DateTime.Parse("01/03/2003") }); sortedSplitList.Add(new TestObject() { Id = 9, Date = DateTime.Parse("01/03/2003") }); Assert.AreEqual(4, sortedSplitList.PartiallyEnumerate(new TestObject() { Date = DateTime.Parse("01/01/2003") }, new CompareByDate()).Count()); Assert.AreEqual(3, sortedSplitList.PartiallyEnumerate(new TestObject() { Date = DateTime.Parse("01/02/2003") }, new CompareByDate()).Count()); Assert.AreEqual(2, sortedSplitList.PartiallyEnumerate(new TestObject() { Date = DateTime.Parse("01/03/2003") }, new CompareByDate()).Count()); foreach (var testObject in sortedSplitList.PartiallyEnumerate(new TestObject() { Date = DateTime.Parse("01/01/2003") }, new CompareByDate())) { Console.WriteLine(testObject.Id); } }
protected override void Clean_internal() { SortedSplitListCellTree = null; }
protected override void Init_internal() { SortedSplitListCellTree = new SortedSplitList <Cell>(new CompareByPositions()); }