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", @"xsl\myotherxsl.xsl" }, new HashtableConstraint(expectedXsltArgs), null);

            MultipleXslReportBuildAction buildAction = new MultipleXslReportBuildAction((IBuildLogTransformer)buildLogTransformerMock.MockInstance, null);

            buildAction.XslFileNames = new BuildReportXslFilename[] {
                new BuildReportXslFilename(@"xsl\myxsl.xsl"),
                new BuildReportXslFilename(@"xsl\myotherxsl.xsl")
            };

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

            buildLogTransformerMock.Verify();
            cruiseRequestMock.Verify();
            buildSpecifierMock.Verify();
        }
Beispiel #2
0
        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", @"xsl\myotherxsl.xsl" }, It.Is <Hashtable>(t => t.Count == 1 && (string)t["applicationPath"] == "myAppPath"), null)).
            Returns("transformed").Verifiable();

            MultipleXslReportBuildAction buildAction = new MultipleXslReportBuildAction((IBuildLogTransformer)buildLogTransformerMock.Object, null);

            buildAction.XslFileNames = new BuildReportXslFilename[] {
                new BuildReportXslFilename(@"xsl\myxsl.xsl"),
                new BuildReportXslFilename(@"xsl\myotherxsl.xsl")
            };

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

            buildLogTransformerMock.Verify();
            cruiseRequestMock.Verify();
            buildSpecifierMock.Verify();
        }
        public void ShouldCreateAnMultipleXslReportBuildActionWithCorrectNameXslFileName()
        {
            buildPlugin.ActionName = "MyAction";
            buildPlugin.ConfiguredLinkDescription = "My Plugin";
            buildPlugin.XslFileNames = xslFiles;

            MultipleXslReportBuildAction xslReportAction = new MultipleXslReportBuildAction(null, null);

            actionInstantiatorMock.ExpectAndReturn("InstantiateAction", xslReportAction, typeof(MultipleXslReportBuildAction));

            INamedAction[] namedActions = buildPlugin.NamedActions;

            Assert.AreEqual(1, namedActions.Length);
            Assert.AreEqual("MyAction", namedActions[0].ActionName);
            Assert.AreEqual(xslReportAction, namedActions[0].Action);
            Assert.AreEqual(xslFiles, ((MultipleXslReportBuildAction)namedActions[0].Action).XslFileNames);

            VerifyAll();
        }