Ejemplo n.º 1
0
        public void should_raise_error_if_attempting_to_copy_a_null_object()
        {
            var mockBlueprint = new Mock<IBlueprint<AnObject>>();
            var mockPropertySetterFactory = new Mock<IPropertySetterFactory<AnObject>>();

            var builder = new Builder<AnObject>(mockBlueprint.Object, mockPropertySetterFactory.Object);

            Assert.Throws<ArgumentNullException>(() => builder.Copy(null));
        }
Ejemplo n.º 2
0
        public void should_be_able_to_copy_an_existing_object()
        {
            var source = new AnObject();
            var mockBlueprint = new Mock<IBlueprint<AnObject>>();
            var mockPropertySetterFactory = new Mock<IPropertySetterFactory<AnObject>>();
            var mockPropertySetter = new Mock<IPropertySetter>();

            mockPropertySetterFactory.Setup(x => x.CreateCopyObjectSetter(source)).Returns(mockPropertySetter.Object);

            var builder = new Builder<AnObject>(mockBlueprint.Object, mockPropertySetterFactory.Object);
            builder.Copy(source).Build();

            mockPropertySetter.Verify(x => x.ApplyValue(
                It.IsAny<AnObject>(),
                It.IsAny<IDictionary<string, object>>()
            ), Times.Once());
        }