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

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

            mock.Setup(t => t.AddDocumentRewriter(
                           It.IsAny <IDocumentRewriter>()))
            .Returns(new Func <IDocumentRewriter, IStitchingBuilder>(t =>
            {
                docRewriter = t;
                return(mock.Object);
            }));

            // act
            StitchingBuilderExtensions
            .AddDocumentRewriter(mock.Object, (schema, doc) => doc);

            // assert
            Assert.IsType <DelegateDocumentRewriter>(docRewriter);
        }
Пример #3
0
        public void AddDocumentRewriter_DelegateIsNull_ArgumentNullException()
        {
            // arrange
            IDocumentRewriter docRewriter = null;
            var mock = new Mock <IStitchingBuilder>();

            mock.Setup(t => t.AddDocumentRewriter(
                           It.IsAny <IDocumentRewriter>()))
            .Returns(new Func <IDocumentRewriter, IStitchingBuilder>(t =>
            {
                docRewriter = t;
                return(mock.Object);
            }));

            // act
            Action action = () => StitchingBuilderExtensions
                            .AddDocumentRewriter(mock.Object,
                                                 (RewriteDocumentDelegate)null);

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