public void AddCommand_NullCommand_ThrowsArgumentNullException()
        {
            var taconiteResult = new TaconiteResult();

              Action action = () => taconiteResult.AddCommand(null);

              action.ShouldThrow<ArgumentNullException>();
        }
        public void AddCommand_AddsCommand()
        {
            var command = Substitute.For<TaconiteCommand>();
              var taconiteResult = new TaconiteResult();

              taconiteResult.AddCommand(command);

              taconiteResult.Commands.Should().HaveCount(1)
            .And.Contain(command);
        }
        public void ExecuteResult_PassesActionResultExecutorToEachCommandWithCorrectContext()
        {
            var controllerContext = Substitute.For<ControllerContext>();
              var taconiteResult = new TaconiteResult();
              var command = Substitute.For<TaconiteCommand>();
              var commandXElement = new XElement("command");
              command.CreateCommandXElement(Arg.Any<ActionResultExecutor>()).Returns(commandXElement);
              taconiteResult.AddCommand(command);

              taconiteResult.ExecuteResult(controllerContext);

              command.Received().CreateCommandXElement(Arg.Is<ActionResultExecutor>(x => x.ControllerContext == controllerContext));
        }
        public void ExecuteResult_OneCommand_WritesCorrectTaconiteDocumentToResponse()
        {
            var controllerContext = Substitute.For<ControllerContext>();
              XElement taconiteDocument = null;
              controllerContext.HttpContext.Response.Received()
            .When(x => x.Write(Arg.Any<XElement>()))
            .Do(x => taconiteDocument = x.Arg<XElement>());
              var taconiteResult = new TaconiteResult();
              var command = Substitute.For<TaconiteCommand>();
              var commandXElement = new XElement("command");
              command.CreateCommandXElement(Arg.Any<ActionResultExecutor>()).Returns(commandXElement);
              taconiteResult.AddCommand(command);

              taconiteResult.ExecuteResult(controllerContext);

              controllerContext.HttpContext.Response.Received().ContentType = "text/xml";
              controllerContext.HttpContext.Response.Received().Write(Arg.Any<XElement>());
              taconiteDocument.Name.Should().Be((XName) "taconite");
              taconiteDocument.Elements().Should().HaveCount(1)
            .And.Contain(commandXElement);
        }