Ejemplo n.º 1
0
        public void CopyPropertyValuesFrom_FieldsAreFound_ApplyChanges()
        {
            // Arrange
            var now       = DateTime.UtcNow;
            var testObj   = new { Id = SampleNumbers.int1, Name = SampleStrings.str1, DateTime = now, Comment = SampleStrings.str2, Hidden = SampleStrings.str3, Semi = SampleStrings.str4 };
            var testClass = new SampleObject(SampleNumbers.int2, SampleStrings.str4, DateTime.Today, SampleStrings.str5, SampleStrings.str6, SampleStrings.str7);

            // Act
            testClass.CopyPropertyValuesFrom(testObj);

            // Assert
            testClass.Id.Should().Be(SampleNumbers.int1);
            testClass.Name.Should().Be(SampleStrings.str1);
            testClass.DateTime.Should().Be(now);
            testClass.Comment.Should().Be(SampleStrings.str2);
            testClass.GetHidden().Should().Be(SampleStrings.str6, "private properties cannot be altered.");
            testClass.GetSemi().Should().Be(SampleStrings.str7, "protected properties cannot be altered.");
        }