public void Contains_Name_UserTypes_Test() { // Arrange var utCollection = new MultiCollection <IdKey, NameKey, Person>(); // 1 Значение var idType = new IdKey(1); var idValue = idType.Id; var nameType = new NameKey("A"); var nameValue = nameType.Name; var personType = new Person(idValue, nameValue); var personIdValue = personType.Id; var personNotesValue = personType.Notes; // 2 Значение var idType2 = new IdKey(2); var idValue2 = idType2.Id; var nameType2 = new NameKey("B"); var nameValue2 = nameType2.Name; var personType2 = new Person(idValue2, nameValue2); var personIdValue2 = personType2.Id; var personNotesValue2 = personType2.Notes; utCollection.Clear(); utCollection.Add(new IdKey(idValue), new NameKey(nameValue), new Person(idValue, nameValue)); utCollection.Add(new IdKey(idValue2), new NameKey(nameValue2), new Person(idValue2, nameValue2)); // Action var newNameKey = new NameKey(nameValue); var isContainsByValue = utCollection.Contains(newNameKey); var isContainsByRef = utCollection.Contains(nameType); var hCodeId = newNameKey.GetHashCode(); var hcIdType = nameType.GetHashCode(); // Assert Assert.IsFalse(utCollection.Contains(new NameKey("C"))); Assert.AreEqual(hcIdType, hCodeId); Assert.IsTrue(isContainsByValue); Assert.IsTrue(isContainsByRef); }
public void Contains_Value_UserTypes_Test() { // Arrange var utCollection = new MultiCollection <IdKey, NameKey, Person>(); // 1 Значение var idType = new IdKey(1); var idValue = idType.Id; var nameType = new NameKey("A"); var nameValue = nameType.Name; var personType = new Person(idValue, nameValue); var personIdValue = personType.Id; var personNotesValue = personType.Notes; // 2 Значение var idType2 = new IdKey(2); var idValue2 = idType2.Id; var nameType2 = new NameKey("B"); var nameValue2 = nameType2.Name; var personType2 = new Person(idValue2, nameValue2); var personIdValue2 = personType2.Id; var personNotesValue2 = personType2.Notes; utCollection.Clear(); utCollection.Add(new IdKey(idValue), new NameKey(nameValue), new Person(idValue, nameValue)); utCollection.Add(idType2, nameType2, personType2); // Action var isContainsByValue = utCollection.Contains(new Person(idValue2, nameValue2)); var isContainsByRef = utCollection.Contains(personType2); // Assert Assert.IsTrue(isContainsByValue); Assert.IsTrue(isContainsByRef); }
public void RemoveTest() { // Arrange var expectedId = _person2.Id; var expectedName = _person2.Notes; // Action var isContains = _stdCollection.Contains(expectedId, expectedName); Assert.IsTrue(isContains); var result = _stdCollection.Remove(expectedId, expectedName); Assert.IsTrue(result); isContains = _stdCollection.Contains(expectedId, expectedName); Assert.IsFalse(isContains); }