Ejemplo n.º 1
0
        public void WhenDataGiven_ShouldReturnHashCodeOfProperty()
        {
            //Arrange
            var comparer = new KeyComparer<TestPoco, int>(f => f.Id) as IEqualityComparer<TestPoco>;
            var data = new TestPoco() { Id = 1 };

            //Act
            var result = comparer.GetHashCode(data);

            //Assert
            Assert.AreEqual(data.Id.GetHashCode(), result);
        }
Ejemplo n.º 2
0
        public void WhenPropertiesComparedAreNotEqual_ShouldReturnFalse()
        {
            //Arrange
            var comparer = new KeyComparer<TestPoco, int>(f => f.Id) as IEqualityComparer<TestPoco>;
            var one = new TestPoco() { Id = 1 };
            var two = new TestPoco() { Id = 2 };

            //Act
            var result = comparer.Equals(one, two);

            //Assert
            Assert.IsFalse(result);
        }
Ejemplo n.º 3
0
        public void WhenDiffrentValuesAreProvidedWithKeySelector_ShouldReturnFullyJoinedList()
        {
            //Arrange
            var right = new TestPoco[] {
                new TestPoco { Id = 1 },
                new TestPoco { Id = 2 } };
            var left = new TestPoco[] {
                new TestPoco { Id = 1 },
                new TestPoco { Id = 3 }
            };

            //Act
            var result = right.FullOuterJoin(left, (t) => t.Id, (r, l) => new { One = r, Two = l });

            //Assert
            Assert.AreEqual(3, result.Count());
            Assert.AreEqual(1, result.ElementAt(0).One.Id);
            Assert.AreEqual(1, result.ElementAt(0).Two.Id);
            Assert.AreEqual(2, result.ElementAt(1).One.Id);
            Assert.AreEqual(null, result.ElementAt(1).Two);
            Assert.AreEqual(null, result.ElementAt(2).One);
            Assert.AreEqual(3, result.ElementAt(2).Two.Id);
        }