Example #1
0
        public void OrderControllerCallsOrderEntryFlowServiceForNavigation()
        {
            TestableOrdersController  controller  = GetOrderControllerInitialized();
            MockOrderEntryFlowService flowService = controller.MockOrderEntryFlowService;

            Assert.IsFalse(flowService.NavigateNextFromDetailsViewCalled);
            controller.NavigateNextFromDetailsView();
            Assert.IsTrue(flowService.NavigateNextFromDetailsViewCalled);

            Assert.IsFalse(flowService.NavigateNextFromGeneralViewCalled);
            controller.NavigateNextFromGeneralView();
            Assert.IsTrue(flowService.NavigateNextFromGeneralViewCalled);

            Assert.IsFalse(flowService.NavigatePreviousFromDetailsViewCalled);
            controller.NavigatePreviousFromDetailsView();
            Assert.IsTrue(flowService.NavigatePreviousFromDetailsViewCalled);

            Assert.IsFalse(flowService.NavigatePreviousFromReviewViewCalled);
            controller.NavigatePreviousFromPreviewView();
            Assert.IsTrue(flowService.NavigatePreviousFromReviewViewCalled);

            Assert.IsFalse(flowService.NavigateNextFromReviewViewCalled);
            controller.NavigateToConfirmationView();
            Assert.IsTrue(flowService.NavigateNextFromReviewViewCalled);

            Assert.IsFalse(flowService.NavigateToCurrentViewCalled);
            controller.CallNavigateToCurrentView();
            Assert.IsTrue(flowService.NavigateToCurrentViewCalled);
        }
Example #2
0
        public void SubmitOrderCallsRepository()
        {
            TestableOrdersController controller = GetOrderControllerInitialized();
            Order order = GetPopulatedOrder();

            controller.CurrentOrder = order;
            controller.SubmitOrder();

            Assert.IsTrue(controller.MockOrdersService.SubmitOrderCalled);
        }
Example #3
0
        private TestableOrdersController GetOrderControllerInitialized()
        {
            TestableOrdersController controller = new TestableOrdersController(
                new MockHttpContextLocatorService(),
                new MockOrderEntryFlowService()
                );

            controller.InitializeState(new StateValue <Order>());
            return(controller);
        }
Example #4
0
        public void CheckOrderEntryFlowIsStartedRedirectsToDefaultWithNotStartedFlow()
        {
            TestableOrdersController controller = GetOrderControllerInitialized();

            controller.CurrentOrder = null;

            controller.VerifyOrderEntryFlowIsStarted();

            Assert.IsTrue(controller.MockOrderEntryFlowService.NavigateToDefaultViewCalled);
        }
Example #5
0
        public void CheckOrderEntryFlowIsStartedDoesNotRedirectWithRunningFlow()
        {
            TestableOrdersController controller = GetOrderControllerInitialized();

            controller.CurrentOrder = new Order();

            controller.VerifyOrderEntryFlowIsStarted();

            Assert.IsFalse(controller.MockOrderEntryFlowService.NavigateToDefaultViewCalled);
        }
Example #6
0
        public void StartLoadOrderFlowThrowsWithOrderThatIsNotDraft()
        {
            TestableOrdersController controller = GetOrderControllerInitialized();

            controller.MockHttpContextLocatorService.GetCurrentContext().User = new GenericPrincipal(new GenericIdentity("CurrentUser"), null);
            controller.MockOrdersService.Order             = GetPopulatedOrder();
            controller.MockOrdersService.Order.OrderStatus = (int)OrderStatusEnum.Submitted;

            controller.StartLoadOrderFlow(controller.MockOrdersService.Order.OrderId);
        }
Example #7
0
        public void StartLoadOrderFlowThrowsWithOrderNotFromCurrentUser()
        {
            TestableOrdersController controller = GetOrderControllerInitialized();

            controller.MockHttpContextLocatorService.GetCurrentContext().User = new GenericPrincipal(new GenericIdentity("CurrentUser"), null);
            controller.MockOrdersService.Order         = GetPopulatedOrder();
            controller.MockOrdersService.Order.Creator = "AnotherUser";

            controller.StartLoadOrderFlow(controller.MockOrdersService.Order.OrderId);
        }
Example #8
0
        public void StartCreateOrderFlowCallsCreateNewOrderIfNeeded()
        {
            TestableOrdersController controller = GetOrderControllerInitialized();

            controller.MockHttpContextLocatorService.GetCurrentContext().User = new GenericPrincipal(new GenericIdentity("CurrentUser"), null);

            controller.StartCreateOrderFlow();

            Assert.IsTrue(controller.CreateNewOrderCalled);
        }
Example #9
0
        public void StartCreateOrderFlowShouldNavigateToStartView()
        {
            TestableOrdersController controller = GetOrderControllerInitialized();

            controller.MockHttpContextLocatorService.GetCurrentContext().User = new GenericPrincipal(new GenericIdentity("CurrentUser"), null);

            controller.StartCreateOrderFlow();

            Assert.IsTrue(controller.MockOrderEntryFlowService.NavigateToCurrentViewCalled);
        }
Example #10
0
        public void CreateOrderSetCreatorProperty()
        {
            TestableOrdersController controller = GetOrderControllerInitialized();

            controller.MockHttpContextLocatorService.GetCurrentContext().User = new GenericPrincipal(new GenericIdentity("CurrentUser"), null);
            controller.CreateNewOrder();

            Assert.IsNotNull(controller.CurrentOrder.Creator);
            Assert.AreEqual("CurrentUser", controller.CurrentOrder.Creator);
        }
Example #11
0
        public void StartLoadOrderFlowCallsOrdersService()
        {
            TestableOrdersController controller = GetOrderControllerInitialized();

            controller.MockOrdersService.Order = GetPopulatedOrder();
            controller.MockHttpContextLocatorService.GetCurrentContext().User = new GenericPrincipal(new GenericIdentity("CurrentUser"), null);

            controller.StartLoadOrderFlow(controller.MockOrdersService.Order.OrderId);

            Assert.IsTrue(controller.MockOrdersService.GetOrderWithDetailsCalled);
        }
Example #12
0
        public void CreateOrderCompleteClearCurrentOrderAndCompletesFlow()
        {
            TestableOrdersController controller = GetOrderControllerInitialized();

            controller.MockHttpContextLocatorService.GetCurrentContext().User = new GenericPrincipal(new GenericIdentity("CurrentUser"), null);
            controller.CreateNewOrder();
            Assert.IsNotNull(controller.CurrentOrder);

            controller.CreateOrderComplete();

            Assert.IsNull(controller.CurrentOrder);
        }
Example #13
0
        public void CancelChangesClearCurrentOrderAndDonNotCallRepository()
        {
            TestableOrdersController controller = GetOrderControllerInitialized();

            controller.MockOrdersService.Order = GetPopulatedOrder();
            controller.MockHttpContextLocatorService.GetCurrentContext().User = new GenericPrincipal(new GenericIdentity("CurrentUser"), null);

            Assert.IsNull(controller.CurrentOrder);

            controller.StartLoadOrderFlow(controller.MockOrdersService.Order.OrderId);
            Assert.IsNotNull(controller.CurrentOrder);
            controller.CancelChanges();
            Assert.IsNull(controller.CurrentOrder);

            Assert.IsFalse(controller.MockOrdersService.SaveAsDraftCalled);
        }
 private TestableOrdersController GetOrderControllerInitialized()
 {
     TestableOrdersController controller = new TestableOrdersController(
         new MockHttpContextLocatorService(),
         new MockOrderEntryFlowService()
     );
     controller.InitializeState(new StateValue<Order>());
     return controller;
 }