Пример #1
0
                public void InvalidName_ShouldThrow(string invalidName)
                {
                    // arrange
                    var sut = new DynamicBuilder <SomeStruct>();

                    // act
                    Action getOverwrittenValue = () => sut.GetOverwrittenValue(invalidName);

                    // assert
                    getOverwrittenValue.Should().Throw <ArgumentNullException>();
                }
Пример #2
0
                public void NotOverwritten_ShouldReturnDefaultValueOfPropertyType()
                {
                    // arrange
                    var sut = new DynamicBuilder <SomeClass>();

                    // act
                    object result = sut.GetOverwrittenValue(nameof(SomeClass.Int32Property));

                    // assert
                    result.Should().Be(default(int));
                }
Пример #3
0
                public void UnknownName_ShouldThrow()
                {
                    // arrange
                    var sut = new DynamicBuilder <SomeClass>();

                    // act
                    Action getOverwrittenValue = () => sut.GetOverwrittenValue("UnknownProperty");

                    // assert
                    getOverwrittenValue.Should().Throw <InvalidOperationException>();
                }
Пример #4
0
                public void Overwritten_ShouldReturnOverwrittenValue()
                {
                    // arrange
                    var sut      = new DynamicBuilder <SomeClass>();
                    int expected = 1;

                    sut.Overwrite(nameof(SomeClass.Int32Property), expected);

                    // act
                    object result = sut.GetOverwrittenValue(nameof(SomeClass.Int32Property));

                    // assert
                    result.Should().Be(expected);
                }