private MyAccountController CreateDefaultMyAccountControllerWithCustomerUserMailerAndCustomCustomerAccountService(IUserMailer userMailer,ICustomerAccountService customerAccountService)
        {
            var authentication = MockRepository.GenerateStub<IAuthentication>();
            var orderRepository = MockRepository.GenerateStub<IOrderRepository>();

            var controller = new MyAccountController(authentication, customerAccountService, userMailer, mapper, orderRepository);
            return controller;
        }
        public void RegisterPost_ShouldSendTheCustomerAnEmailIfSuccessful()
        {
            //Arrange

            var customerViewModel = fixture.CreateAnonymous<RegisterCustomerViewModel>();

            var authentication = MockRepository.GenerateStub<IAuthentication>();
            var orderRepository = MockRepository.GenerateStub<IOrderRepository>();

            var customerAccountService = MockRepository.GenerateStub<ICustomerAccountService>();

            customerAccountService.Stub(
                x => x.CreateCustomer(Arg<Customer>.Is.Anything)).Return(MembershipCreateStatus.Success);

            var userMailer = MockRepository.GenerateStrictMock<IUserMailer>();

            userMailer.Expect(x => x.NewCustomer(Arg<Customer>.Is.Anything)).Repeat.Once();

            var controller = new MyAccountController(authentication, customerAccountService, userMailer, mapper, orderRepository);

            //Act
            controller.Register(customerViewModel);
            //Assert
            userMailer.VerifyAllExpectations();
        }
        private MyAccountController CreateDefaultMyAccountControllerWithCustomAuthentication(
            IAuthentication authentication)
        {
            var customerAccountService = MockRepository.GenerateStub<ICustomerAccountService>();
            var userMailer = MockRepository.GenerateStub<IUserMailer>();
            var orderRepository = MockRepository.GenerateStub<IOrderRepository>();

            var controller = new MyAccountController(authentication, customerAccountService, userMailer,mapper, orderRepository);
            return controller;
        }
        public void Index_ShouldRenderTheRightViewModel()
        {
            //Arrange
            var authentication = MockRepository.GenerateStub<IAuthentication>();
            var customerAccountService = MockRepository.GenerateStub<ICustomerAccountService>();
            var userMailer = MockRepository.GenerateStub<IUserMailer>();
            var orderRepository = MockRepository.GenerateStub<IOrderRepository>();

            var customer = fixture.CreateAnonymous<ExtendedCustomer>();
            var customerData = fixture.CreateAnonymous<Customer>();

            orderRepository.Stub(x => x.GetOrdersByCustomerEmail(Arg<string>.Is.Anything));

            authentication.Stub(x => x.CustomerData).Return(customerData);

            customerAccountService.Stub(x => x.GetExtendedCustomerByEmail(Arg<string>.Is.Anything)).Return(customer);

            var controller = new MyAccountController(authentication, customerAccountService, userMailer, mapper, orderRepository);
            //Act
            var viewModel = controller.Index();
            //Assert
            viewModel.AssertViewRendered().WithViewData<MyAccountViewModel>();
        }