/// <summary> ///Clear 的测试 ///</summary> public void ClearTestHelper <KeyT>() { SafeHashSet <KeyT> target = new SafeHashSet <KeyT>(); // TODO: 初始化为适当的值 target.Clear(); Assert.Inconclusive("无法验证不返回值的方法。"); }
/// <summary> /// Performs truncation selection /// </summary> /// <returns></returns> public override List <IGenotype> DoSelection() { ICollection <IGenotype> selection; int index; if (AllowDuplicates) { selection = new List <IGenotype>(SelectionCount); } else { selection = new SafeHashSet <IGenotype>(MaxRetriesForDuplicates); } while (selection.Count < SelectionCount) { index = Tools.StaticRandom.Next(0, Population.Count); selection.Add(Population[index]); } if (AllowDuplicates) { return((List <IGenotype>)selection); } else { return(selection.ToList()); } }
/// <summary> ///SafeHashSet`1 构造函数 的测试 ///</summary> public void SafeHashSetConstructorTestHelper <KeyT>() { IEnumerable <KeyT> collection = null; // TODO: 初始化为适当的值 SafeHashSet <KeyT> target = new SafeHashSet <KeyT>(collection); Assert.Inconclusive("TODO: 实现用来验证目标的代码"); }
/// <summary> ///AddRange 的测试 ///</summary> public void AddRangeTestHelper <KeyT>() { SafeHashSet <KeyT> target = new SafeHashSet <KeyT>(); // TODO: 初始化为适当的值 IEnumerable <KeyT> collection = null; // TODO: 初始化为适当的值 target.AddRange(collection); Assert.Inconclusive("无法验证不返回值的方法。"); }
/// <summary> ///Add 的测试 ///</summary> public void AddTestHelper <KeyT>() { SafeHashSet <KeyT> target = new SafeHashSet <KeyT>(); // TODO: 初始化为适当的值 KeyT key = default(KeyT); // TODO: 初始化为适当的值 target.Add(key); Assert.Inconclusive("无法验证不返回值的方法。"); }
// //编写测试时,还可使用以下属性: // //使用 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 /// <summary> ///Count 的测试 ///</summary> public void CountTestHelper <KeyT>() { SafeHashSet <KeyT> target = new SafeHashSet <KeyT>(); // TODO: 初始化为适当的值 int actual; actual = target.Count; Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> ///UnionWith 的测试 ///</summary> public void UnionWithTestHelper <KeyT>() { SafeHashSet <KeyT> target = new SafeHashSet <KeyT>(); // TODO: 初始化为适当的值 IEnumerable <KeyT> other = null; // TODO: 初始化为适当的值 target.UnionWith(other); Assert.Inconclusive("无法验证不返回值的方法。"); }
public void 取得SafeHashSet是否包含指定元素_SafeHashSet包含該元素_應回傳True() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; var result = safeHashSet.Contains(3); result.Should().Be(true); }
public void 取得SafeHashSet是否包含指定元素_SafeHashSet不包含該元素_應回傳False() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; var result = safeHashSet.Contains(10); result.Should().Be(false); }
public void SafeHashSet清除所有元素_清除成功_SafeHashSet的長度應為0() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; const int expectedCount = 0; safeHashSet.Clear(); safeHashSet.Count.Should().Be(expectedCount); }
public void SafeHashSet依照帶入參數檢查是否與該參數集合有交集_SafeHashSet與傳入參數沒有交集_應回傳False() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; var param = Enumerable.Range(6, 5); var result = safeHashSet.Overlaps(param); result.Should().Be(false); }
public void SafeHashSet依照帶入參數檢查是否與該參數集合包含相同元素_SafeHashSet與傳入參數包含相同元素_應回傳True() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; var param = Enumerable.Range(0, 6).SelectMany(x => Enumerable.Repeat(x, 2)); var result = safeHashSet.SetEquals(param); result.Should().Be(true); }
public void SafeHashSet依照帶入參數檢查是否與該參數集合包含相同元素_SafeHashSet與傳入參數不包含相同元素_應回傳False() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; var param = Enumerable.Range(0, 10); var result = safeHashSet.SetEquals(param); result.Should().Be(false); }
public void SafeHashSet依照帶入參數檢查是否為該參數的超集_SafeHashSet是傳入參數的超集_應回傳True() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; var param = Enumerable.Range(0, 3); var result = safeHashSet.IsSupersetOf(param); result.Should().Be(true); }
public void SafeHashSet依照帶入參數檢查是否為該參數的真超集_SafeHashSet不是傳入參數的真超集_應回傳False() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; var param = Enumerable.Range(0, 6); var result = safeHashSet.IsProperSupersetOf(param); result.Should().Be(false); }
/// <summary> ///ToArrayAndClear 的测试 ///</summary> public void ToArrayAndClearTestHelper <KeyT>() { SafeHashSet <KeyT> target = new SafeHashSet <KeyT>(); // TODO: 初始化为适当的值 KeyT[] expected = null; // TODO: 初始化为适当的值 KeyT[] actual; actual = target.ToArrayAndClear(); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public void SafeHashSet依照帶入參數檢查是否為該參數子集_SafeHashSet不是傳入參數的子集_應回傳False() { var safeHashSet = new SafeHashSet <int> { 1, 2, 3, 4, 5 }; var param = Enumerable.Range(0, 3); var result = safeHashSet.IsSubsetOf(param); result.Should().Be(false); }
/// <summary> ///GetEnumerator 的测试 ///</summary> public void GetEnumeratorTestHelper <KeyT>() { SafeHashSet <KeyT> target = new SafeHashSet <KeyT>(); // TODO: 初始化为适当的值 IEnumerator <KeyT> expected = null; // TODO: 初始化为适当的值 IEnumerator <KeyT> actual; actual = target.GetEnumerator(); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> ///Contains 的测试 ///</summary> public void ContainsTestHelper <KeyT>() { SafeHashSet <KeyT> target = new SafeHashSet <KeyT>(); // TODO: 初始化为适当的值 KeyT key = default(KeyT); // TODO: 初始化为适当的值 bool expected = false; // TODO: 初始化为适当的值 bool actual; actual = target.Contains(key); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> ///IsProperSubsetOf 的测试 ///</summary> public void IsProperSubsetOfTestHelper <KeyT>() { SafeHashSet <KeyT> target = new SafeHashSet <KeyT>(); // TODO: 初始化为适当的值 IEnumerable <KeyT> other = null; // TODO: 初始化为适当的值 bool expected = false; // TODO: 初始化为适当的值 bool actual; actual = target.IsProperSubsetOf(other); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> ///RemoveAll 的测试 ///</summary> public void RemoveAllTestHelper <KeyT>() { SafeHashSet <KeyT> target = new SafeHashSet <KeyT>(); // TODO: 初始化为适当的值 Predicate <KeyT> match = null; // TODO: 初始化为适当的值 int expected = 0; // TODO: 初始化为适当的值 int actual; actual = target.RemoveAll(match); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public void 複製SafeHashSet至指定陣列_複製成功_複製結果應與原集合相同() { var fixure = new Fixture(); var safeHashSet = new SafeHashSet <int>(); const int count = 10; safeHashSet.AddMany(fixure.Create <int>, count); var result = new int[count]; safeHashSet.CopyTo(result, 0); result.Should().BeEquivalentTo(safeHashSet); }
public void SafeHashSet依照加入指定元素_集合中已經包含該元素故加入失敗_SafeHashSet應包含該元素並應回傳False() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; const int element = 3; var result = safeHashSet.Add(element); result.Should().Be(false); var isContain = safeHashSet.Contains(element); isContain.Should().Be(true); }
public void 移除SafeHashSet指定元素_移除成功_集合應不包含該元素並回傳True() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; const int target = 4; var result = safeHashSet.Remove(target); result.Should().Be(true); var isContain = safeHashSet.Contains(target); isContain.Should().Be(false); }
public void SafeHashSet依照加入指定元素_加入成功_SafeHashSet應包含該元素並回傳True() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; const int element = 10; var result = safeHashSet.Add(element); result.Should().Be(true); var isContain = safeHashSet.Contains(element); isContain.Should().Be(true); }
public void SafeHashSet依照帶入參數執行邏輯異或_執行成功_應該是SafeHashSet與參數邏輯異或後的結果() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; var param = Enumerable.Range(3, 6); var expectedResult = new List <int> { 0, 1, 2, 6, 8, 7 }; safeHashSet.SymmetricExceptWith(param); safeHashSet.Should().BeEquivalentTo(expectedResult, options => options.WithoutStrictOrderingFor(x => false)); }
public void SafeHashSet依照帶入參數執行差集操作_執行成功_結果應是SafeHashSet與參數的差集() { var safeHashSet = new SafeHashSet <int> { 1, 2, 3, 4, 5 }; var param = Enumerable.Range(0, 10).Where(x => x % 2 == 0); safeHashSet.ExceptWith(param); var expectedResult = new List <int> { 1, 3, 5 }; safeHashSet.SequenceEqual(expectedResult).Should().Be(true); }
public void 繞行SafeHashSet操作集合_不同執行緒同時對SafeHashSet操作新增與刪除_不應擲出例外() { var safeHashSet = new SafeHashSet <int> { 1, 2, 3, 4, 5 }; Task.Run(() => { while (true) { safeHashSet.Add(0); } }); Task.Run(() => { while (true) { safeHashSet.Remove(0); } }); Task.Run(() => { while (true) { safeHashSet.Clear(); } }); Task.Run(() => { while (true) { safeHashSet.IntersectWith(Enumerable.Range(0, 3)); } }); Task.Run(() => { while (true) { safeHashSet.UnionWith(Enumerable.Range(0, 3)); } }); Action action = () => IterateCollection(safeHashSet).Wait(); action.Should().NotThrow(); }
public void SafeHashSet依照帶入參數執行聯集操作_執行成功_結果應是SafeHashSet與參數的聯集() { var safeHashSet = new SafeHashSet <int> { 1, 2, 3 }; var param = Enumerable.Range(0, 5); safeHashSet.UnionWith(param); var expectedResult = new List <int> { 1, 2, 3, 0, 4 }; safeHashSet.SequenceEqual(expectedResult).Should().Be(true); }
public void 繞行SafeHashSet_繞行完成_繞行結果應該與原集合相同() { var fixure = new Fixture(); var safeHashSet = new SafeHashSet <int>(); const int count = 10; safeHashSet.AddMany(fixure.Create <int>, count); var result = new List <int>(); foreach (var x in safeHashSet) { result.Add(x); } result.Should().BeEquivalentTo(safeHashSet); }