Exemplo n.º 1
0
        public void With_GetOnlyProperty_ThrowsKeyNotFoundException()
        {
            // arrange
            var builder = new TestClassBuilder();

            // act
            void SetReadOnlyProperty() => builder.With(tc => tc.ICannotBeWrittenTo, 1.0);

            // assert
            Assert.ThrowsException <KeyNotFoundException>((Action)SetReadOnlyProperty);
        }
Exemplo n.º 2
0
        public void With_Field_ThrowsKeyNotFoundException()
        {
            // arrange
            var builder = new TestClassBuilder();

            // act
            void SetField() => builder.With(tc => tc.IAmMostDefinitelyNotAProperty, "test");

            // assert
            Assert.ThrowsException <KeyNotFoundException>((Action)SetField);
        }
Exemplo n.º 3
0
        public void With_SetterProperty_IsExpected()
        {
            // arrange
            var       builder  = new TestClassBuilder();
            const int expected = 2;

            // act
            var result = builder.With(tc => tc.IAmAProperty, expected).Create();

            // assert
            Assert.AreEqual(expected, result.IAmAProperty);
        }