public void Build_ShouldMapTheExtendedCustomerIfTheCustomerIsSignedIn() { //Arrange var checkoutDetailsModel = fixture.CreateAnonymous <CheckoutDetailsModel>(); var customerData = fixture.CreateAnonymous <Customer>(); var extendedCustomer = fixture.CreateAnonymous <ExtendedCustomer>(); var authentication = CreateAuthenticationWithCustomerData(customerData); var customerAccountService = CreateCustomerAccountServiceWithExtendedCustomer(extendedCustomer); var builder = new BillingViewModelBuilder(checkoutDetailsModel, authentication, customerAccountService, mapper); //Act var viewModel = builder.Build(); //Assert viewModel.ShippingAddress.Address1.Should().Be(extendedCustomer.ShippingAddress.Address1); viewModel.ShippingAddress.City.Should().Be(extendedCustomer.ShippingAddress.City); viewModel.ShippingAddress.CountryID.Should().Be(extendedCustomer.ShippingAddress.CountryID); viewModel.ShippingAddress.FirstName.Should().Be(extendedCustomer.ShippingAddress.FirstName); viewModel.ShippingAddress.LastName.Should().Be(extendedCustomer.ShippingAddress.LastName); viewModel.ShippingAddress.Phone.Should().Be(extendedCustomer.ShippingAddress.Phone); viewModel.ShippingAddress.ZipCode.Should().Be(extendedCustomer.ShippingAddress.ZipCode); viewModel.BillingAddress.Address1.Should().Be(extendedCustomer.BillingAddress.Address1); viewModel.BillingAddress.City.Should().Be(extendedCustomer.BillingAddress.City); viewModel.BillingAddress.CountryID.Should().Be(extendedCustomer.BillingAddress.CountryID); viewModel.BillingAddress.FirstName.Should().Be(extendedCustomer.BillingAddress.FirstName); viewModel.BillingAddress.LastName.Should().Be(extendedCustomer.BillingAddress.LastName); viewModel.BillingAddress.Phone.Should().Be(extendedCustomer.BillingAddress.Phone); viewModel.BillingAddress.ZipCode.Should().Be(extendedCustomer.BillingAddress.ZipCode); }
public void Build_ShouldMapTheFieldsCorrectly() { //Arrange var checkoutDetailsModel = fixture.CreateAnonymous <CheckoutDetailsModel>(); var authentication = MockRepository.GenerateStub <IAuthentication>(); var customerAccountService = CreateCustomerAccountServiceWithExtendedCustomer(); var builder = new BillingViewModelBuilder(checkoutDetailsModel, authentication, customerAccountService, mapper); //Act var viewModel = builder.Build(); //Assert viewModel.Email.Should().Be(checkoutDetailsModel.Email); viewModel.FirstName.Should().Be(checkoutDetailsModel.FirstName); viewModel.LastName.Should().Be(checkoutDetailsModel.LastName); viewModel.PaymentMethod.Should().Be(checkoutDetailsModel.PaymentMethod); viewModel.Phone.Should().Be(checkoutDetailsModel.Phone); viewModel.BillingAddress.FirstName.Should().Be(checkoutDetailsModel.FirstName); viewModel.BillingAddress.LastName.Should().Be(checkoutDetailsModel.LastName); viewModel.BillingAddress.Phone.Should().Be(checkoutDetailsModel.Phone); viewModel.ShippingAddress.FirstName.Should().Be(checkoutDetailsModel.FirstName); viewModel.ShippingAddress.LastName.Should().Be(checkoutDetailsModel.LastName); viewModel.ShippingAddress.Phone.Should().Be(checkoutDetailsModel.Phone); }
public ActionResult Billing(CheckoutDetailsModel checkoutDetailsModel) { if (CheckIfCartSessionTimedoutOrCartIsEmpty()) { return(RedirectToAction("CheckoutSessionTimeout")); } if (!String.IsNullOrEmpty(Request.Form["LoginEmail"])) { var js = new JavaScriptSerializer(); var jsonModel = js.Serialize(checkoutDetailsModel); return(RedirectToAction("ProcessSignin", "MyAccount", new RouteValueDictionary { { "RedirectMode", RedirectMode.Route }, { "RouteController", "Checkout" }, { "RouteAction", "Billing" }, { "Email", Request.Form["LoginEmail"] }, { "Password", Request.Form["LoginPassword"] }, { "JSONEncodedRouteValues", jsonModel }, { "RouteValuesModelClassName", checkoutDetailsModel.GetType().FullName } })); } var builder = new BillingViewModelBuilder(checkoutDetailsModel, authentication, accountService, mapper); var viewModel = builder.Build(); return(View(viewModel)); }
public void Build_ShouldCheckIfTheCustomerIsSignedIn() { //Arrange var checkoutDetailsModel = fixture.CreateAnonymous <CheckoutDetailsModel>(); var authentication = MockRepository.GenerateStub <IAuthentication>(); authentication.Expect(x => x.IsSignedIn()).Return(false); var customerAccountService = CreateCustomerAccountServiceWithExtendedCustomer(); var builder = new BillingViewModelBuilder(checkoutDetailsModel, authentication, customerAccountService, mapper); //Act builder.Build(); //Assert authentication.VerifyAllExpectations(); }
public void Build_ShouldMapThePaymentMethodAsWasSelectedInTheCheckoutModel() { //Arrange var checkoutDetailsModel = fixture.Build <CheckoutDetailsModel>().With(x => x.PaymentMethod, PaymentMethod.PayPal).CreateAnonymous(); var customerData = fixture.CreateAnonymous <Customer>(); var extendedCustomer = fixture.CreateAnonymous <ExtendedCustomer>(); var authentication = CreateAuthenticationWithCustomerData(customerData); var customerAccountService = CreateCustomerAccountServiceWithExtendedCustomer(extendedCustomer); var builder = new BillingViewModelBuilder(checkoutDetailsModel, authentication, customerAccountService, mapper); //Act var viewModel = builder.Build(); //Assert viewModel.PaymentMethod.Should().Be(checkoutDetailsModel.PaymentMethod); }