Beispiel #1
0
        public void ShouldUseBuildLogTransformerToGenerateView()
        {
            DynamicMock buildLogTransformerMock = new DynamicMock(typeof(IBuildLogTransformer));
            DynamicMock cruiseRequestMock       = new DynamicMock(typeof(ICruiseRequest));
            DynamicMock buildSpecifierMock      = new DynamicMock(typeof(IBuildSpecifier));
            DynamicMock requestStub             = new DynamicMock(typeof(IRequest));

            ICruiseRequest  cruiseRequest  = (ICruiseRequest)cruiseRequestMock.MockInstance;
            IBuildSpecifier buildSpecifier = (IBuildSpecifier)buildSpecifierMock.MockInstance;
            IRequest        request        = (IRequest)requestStub.MockInstance;

            cruiseRequestMock.ExpectAndReturn("BuildSpecifier", buildSpecifier);
            cruiseRequestMock.SetupResult("Request", request);
            requestStub.SetupResult("ApplicationPath", "myAppPath");
            Hashtable expectedXsltArgs = new Hashtable();

            expectedXsltArgs["applicationPath"] = "myAppPath";
            buildLogTransformerMock.ExpectAndReturn("Transform", "transformed", buildSpecifier, new string[] { @"xsl\myxsl.xsl" }, new HashtableConstraint(expectedXsltArgs), null);

            XslReportBuildAction action = new XslReportBuildAction((IBuildLogTransformer)buildLogTransformerMock.MockInstance, null);

            action.XslFileName = @"xsl\myxsl.xsl";

            Assert.AreEqual("transformed", ((HtmlFragmentResponse)action.Execute(cruiseRequest)).ResponseFragment);

            buildLogTransformerMock.Verify();
            cruiseRequestMock.Verify();
            buildSpecifierMock.Verify();
        }
        public void ShouldUseBuildLogTransformerToGenerateView()
        {
            var buildLogTransformerMock = new Mock <IBuildLogTransformer>();
            var cruiseRequestMock       = new Mock <ICruiseRequest>();
            var buildSpecifierMock      = new Mock <IBuildSpecifier>();
            var requestStub             = new Mock <IRequest>();

            ICruiseRequest  cruiseRequest  = (ICruiseRequest)cruiseRequestMock.Object;
            IBuildSpecifier buildSpecifier = (IBuildSpecifier)buildSpecifierMock.Object;
            IRequest        request        = (IRequest)requestStub.Object;

            cruiseRequestMock.SetupGet(_cruiseRequest => _cruiseRequest.BuildSpecifier).Returns(buildSpecifier).Verifiable();
            cruiseRequestMock.SetupGet(_cruiseRequest => _cruiseRequest.Request).Returns(request).Verifiable();
            requestStub.SetupGet(_request => _request.ApplicationPath).Returns("myAppPath").Verifiable();
            buildLogTransformerMock.Setup(transformer => transformer.Transform(buildSpecifier, new string[] { @"xsl\myxsl.xsl" }, It.Is <Hashtable>(t => t.Count == 1 && (string)t["applicationPath"] == "myAppPath"), null)).
            Returns("transformed").Verifiable();

            XslReportBuildAction action = new XslReportBuildAction((IBuildLogTransformer)buildLogTransformerMock.Object, null);

            action.XslFileName = @"xsl\myxsl.xsl";

            Assert.AreEqual("transformed", ((HtmlFragmentResponse)action.Execute(cruiseRequest)).ResponseFragment);

            buildLogTransformerMock.Verify();
            cruiseRequestMock.Verify();
            buildSpecifierMock.Verify();
        }