Exemplo n.º 1
0
        public static void Equals_TwoDifferentStringsOfEqualLength_ReturnsTrue()
        {
            var comparer = new SelectorEqualityComparer <string, int>(s => s?.Length ?? 0);

            var output = comparer.Equals("AAA", "BBB");

            Assert.That(output, Is.True);
        }
Exemplo n.º 2
0
        public static void GetHashCode_OfStringWithLength3_Returns3()
        {
            // This exploits the fact that the hash code of an Int32 is the Int32 itself.
            var comparer = new SelectorEqualityComparer <string, int>(s => s?.Length ?? 0);

            var output = comparer.GetHashCode("AAA");

            Assert.That(output, Is.EqualTo(3));
        }
        public void CTor()
        {
            // Arrange: Declare any variables or set up any conditions
            //          required by your test.


            // Act:     Perform the activity under test.
            var comparer = new SelectorEqualityComparer<Entity>(e => e.Id);

            // Assert:  Verify that the activity under test had the
            //          expected results
        }
        public void Equals_WhenIdsDoNotMatch_ShouldReturnFalse()
        {
            // Arrange: Declare any variables or set up any conditions
            //          required by your test.
            var x = new Entity() { Id = 1, Description = "One" };
            var y = new Entity() { Id = 2, Description = "Two" };

            var comparer = new SelectorEqualityComparer<Entity>(e => e.Id);


            // Act:     Perform the activity under test.
            var result = comparer.Equals(x, y);

            // Assert:  Verify that the activity under test had the
            //          expected results
            Assert.That(result, Is.False);
        }