Пример #1
0
        public void AddTypeRewriter_BuilderIsNull_ArgumentNullException()
        {
            // arrange
            // act
            Action action = () => StitchingBuilderExtensions
                            .AddTypeRewriter(null, (schema, type) => type);

            // assert
            Assert.Equal("builder",
                         Assert.Throws <ArgumentNullException>(action).ParamName);
        }
Пример #2
0
        public void AddTypeRewriter()
        {
            // arrange
            ITypeRewriter typeRewriter = null;
            var           mock         = new Mock <IStitchingBuilder>();

            mock.Setup(t => t.AddTypeRewriter(It.IsAny <ITypeRewriter>()))
            .Returns(new Func <ITypeRewriter, IStitchingBuilder>(t =>
            {
                typeRewriter = t;
                return(mock.Object);
            }));

            // act
            StitchingBuilderExtensions
            .AddTypeRewriter(mock.Object, (schema, type) => type);

            // assert
            Assert.IsType <DelegateTypeRewriter>(typeRewriter);
        }
Пример #3
0
        public void AddTypeRewriter_DelegateIsNull_ArgumentNullException()
        {
            // arrange
            ITypeRewriter typeRewriter = null;
            var           mock         = new Mock <IStitchingBuilder>();

            mock.Setup(t => t.AddTypeRewriter(It.IsAny <ITypeRewriter>()))
            .Returns(new Func <ITypeRewriter, IStitchingBuilder>(t =>
            {
                typeRewriter = t;
                return(mock.Object);
            }));

            // act
            Action action = () => StitchingBuilderExtensions
                            .AddTypeRewriter(mock.Object,
                                             (RewriteTypeDefinitionDelegate)null);

            // assert
            Assert.Equal("rewrite",
                         Assert.Throws <ArgumentNullException>(action).ParamName);
        }