public void SingleElementTest() { IDistinctOrderedCollection<string> elephant = new DistinctOrderedStringCollection("elephant"); elephant.Count.Should().Be(1); elephant.Should().BeEquivalentTo("elephant"); IDistinctOrderedCollection<string> giraffe = new DistinctOrderedStringCollection("giraffe"); giraffe.Count.Should().Be(1); giraffe.Should().BeEquivalentTo("giraffe"); }
public void MultipleElementTest_NoCollisions() { IDistinctOrderedCollection<string> animals = new DistinctOrderedStringCollection("elephant", "giraffe", "lion"); animals.Count.Should().Be(3); animals.Should().BeEquivalentTo("elephant", "giraffe", "lion"); IDistinctOrderedCollection<string> numbers = new DistinctOrderedStringCollection("2", "4", "3", "7", "5"); numbers.Count.Should().Be(5); numbers.Should().BeEquivalentTo("2", "3", "4", "5", "7"); }
public void MultipleElementTest_WithCollisions() { IDistinctOrderedCollection<string> animals = new DistinctOrderedStringCollection("giraffe", "elephant", "elephant"); animals.Count.Should().Be(2); animals.Should().BeEquivalentTo("elephant", "giraffe"); IDistinctOrderedCollection<string> numbers = new DistinctOrderedStringCollection("4", "17", "5", "5", "8", "4"); numbers.Count.Should().Be(4); numbers.Should().BeEquivalentTo("4", "5", "8", "17"); }
public void HashCodeTest() { IDistinctOrderedCollection <string> animals = new DistinctOrderedStringCollection("elephant", "giraffe", "ant"); var hashCode = this.Comparer.GetHashCode(animals); var hashCodeAgain = this.Comparer.GetHashCode(animals); hashCodeAgain.Should().Be(hashCode); IDistinctOrderedCollection <string> animalsAgain = new DistinctOrderedStringCollection("giraffe", "elephant", "ant"); this.Comparer.GetHashCode(animalsAgain).Should().Be(hashCode); }
private static IDistinctOrderedCollection <string> GetClassesFromEntityProperty(TypeInfo targetTypeInfo) { var classAttribute = targetTypeInfo.GetCustomAttribute <HypermediaClientObjectAttribute>(); IDistinctOrderedCollection <string> classes; if (classAttribute == null || classAttribute.Classes == null) { classes = new DistinctOrderedStringCollection(targetTypeInfo.Name); } else { classes = classAttribute.Classes; } return(classes); }
public void EqualsTest() { IDistinctOrderedCollection <string> animals = new DistinctOrderedStringCollection("lion", "elephant", "cat"); this.Comparer.Equals(animals, animals).Should().BeTrue(); this.Comparer.Equals(animals, null).Should().BeFalse(); this.Comparer.Equals(null, animals).Should().BeFalse(); IDistinctOrderedCollection <string> animalsAgain = new DistinctOrderedStringCollection("cat", "cat", "elephant", "lion"); this.Comparer.Equals(animals, animalsAgain).Should().BeTrue(); this.Comparer.Equals(animalsAgain, animals).Should().BeTrue(); IDistinctOrderedCollection <string> numbers = new DistinctOrderedStringCollection("1", "2", "3"); this.Comparer.Equals(animals, numbers).Should().BeFalse(); this.Comparer.Equals(numbers, animals).Should().BeFalse(); }