예제 #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is TestElement))
            {
                return(false);
            }

            TestElement espacialidadeAComparar = (TestElement)obj;

            return(Id == espacialidadeAComparar.Id);
        }
예제 #2
0
        public void TestAreEqualElement_NoFunc_SameIdS()
        {
            //Arrange
            var el1   = new TestElement(1, "test 1");
            var el2   = new TestElement(2, "test 2");
            var el3   = new TestElement(3, "test 3");
            var el4   = new TestElement(1, "test 4");
            var list1 = new List <TestElement> {
                el1, el2
            };
            var list2 = new List <TestElement> {
                el3, el4
            };

            //Act
            var areTheSame = list1.AnyEqualElement(list2);

            //Assert
            Assert.True(areTheSame);
        }
예제 #3
0
        public void TestAreEqualElement_NoFunc_AllDiffIds()
        {
            //Arrange
            var el1   = new TestElement(1, "test 1");
            var el2   = new TestElement(2, "test 2");
            var el3   = new TestElement(3, "test 3");
            var el4   = new TestElement(4, "test 1");
            var list1 = new List <TestElement> {
                el1, el2
            };
            var list2 = new List <TestElement> {
                el3, el4
            };

            //Act
            var areTheSame = list1.AnyEqualElement(list2);

            //Assert
            Assert.False(false);
        }
예제 #4
0
        public void TestAreEqualElement_WithFunc_SameElemString()
        {
            //Arrange
            var el1   = new TestElement(1, "test 1");
            var el2   = new TestElement(2, "test 2");
            var el3   = new TestElement(3, "test 3");
            var el4   = new TestElement(4, "test 1");
            var list1 = new List <TestElement> {
                el1, el2
            };
            var list2 = new List <TestElement> {
                el3, el4
            };

            //Act
            var areTheSame = list1.AnyEqualElement(list2, (x, y) => x.Name == y.Name);

            //Assert
            Assert.True(areTheSame);
        }
예제 #5
0
        public void TestRemoveEqualElements_WithFunc_DifferentId()
        {
            //Arrange
            var el1   = new TestElement(1, "test 1");
            var el2   = new TestElement(2, "test 2");
            var el3   = new TestElement(3, "test 3");
            var el4   = new TestElement(4, "test 1");
            var list1 = new List <TestElement> {
                el1, el2
            };
            var list2 = new List <TestElement> {
                el3, el4
            };

            //Act
            var removedItens = list1.RemoveEqualElements(list2, (x, y) => x.Id == y.Id);

            //Assert
            Assert.Equal(2, list1.Count);
            Assert.Equal(0, removedItens.Count);
        }
예제 #6
0
        public void TestRemoveEqualElements_NoFunc_DiferentObjects()
        {
            //Arrange
            var el1   = new TestElement(1, "test 1");
            var el2   = new TestElement(2, "test 2");
            var el3   = new TestElement(3, "test 3");
            var el4   = new TestElement(4, "test 1");
            var list1 = new List <TestElement> {
                el1, el2
            };
            var list2 = new List <TestElement> {
                el3, el4
            };

            //Act
            var removedItens = list1.RemoveEqualElements(list2);

            //Assert
            Assert.Equal(2, list1.Count);
            Assert.Equal(0, removedItens.Count);
        }
예제 #7
0
        public void TestRemoveEqualElements_NoFunc_SameObjects()
        {
            //Arrange
            var el1   = new TestElement(1, "test 1");
            var el2   = new TestElement(2, "test 2");
            var el3   = new TestElement(3, "test 3");
            var el4   = new TestElement(1, "test 1");
            var list1 = new List <TestElement> {
                el1, el2
            };
            var list2 = new List <TestElement> {
                el3, el4
            };

            //Act
            var removedItens = list1.RemoveEqualElements(list2);

            //Assert
            Assert.Equal(1, list1.Count);
            Assert.Equal(1, removedItens.Count);
            Assert.Equal("test 1", removedItens.FirstOrDefault().Name);
        }