コード例 #1
0
 public bool Equals(Demo obj)
 {
     if (obj == null)
     {
         return false;
     }
     return Name == obj.Name && Age == obj.Age;
 }
コード例 #2
0
        public void MergeWith_WithCustomName_MergesNameIntoBase()
        {
            var @base = new Demo
                {
                    Age = 20,
                    Name = "Tim"
                };
            var @new = new Demo
                {
                    Name = "Fred"
                };
            var expected = new Demo
                {
                    Age = 20,
                    Name = "Fred"
                };

            // Act
            @base.MergeWith(@new);

            // Assert
            Assert.AreEqual(expected, @base);
        }
コード例 #3
0
 public NestingDemo()
 {
     Nested = new Demo();
 }
コード例 #4
0
        public void Merge_WithEmptyIterable_ReturnsDefaultObject()
        {
            // Arrange
            var expected = new Demo();

            // Act
            var actual = new List<Demo>().Merge();

            // Assert
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void Merge_WithDefaultValueInConstructor_IgnoresDefaultValueWhenMerging()
        {
            var @base = new Demo
            {
                Age = 20,
                Name = "Tim"
            };
            var @new = new Demo
            {
                Age = 10
            };
            var expected = new Demo
            {
                Age = 10,
                Name = "Tim"
            };

            // Act
            @base.MergeWith(@new);

            // Assert
            Assert.AreEqual(expected, @base);
        }
コード例 #6
0
 public NestingDemo()
 {
     Nested = new Demo();
 }