public async void NewShippingInfo_DoNotSaveAddressNewSession_AddsViewModelInfoToNewSessionOrderDetails()
        {
            WebOrderCheckoutDetails checkoutDetails = null;

            Address mappedAddress = new Address();

            Mock<AddressViewModel> viewModelMock = new Mock<AddressViewModel>();
            viewModelMock.Setup(vm => vm.MapToNewAddress()).
                Returns(mappedAddress).
                Verifiable();

            var viewModel = viewModelMock.Object;
            viewModel.City = "Waterloo";
            viewModel.CountryCode = "CA";
            viewModel.ProvinceCode = "ON";
            viewModel.POBoxNumber = "1234";
            viewModel.PostalCode = "N2L 6R2";
            viewModel.StreetAddress = "445 Wes Graham Way";

            Mock<IVeilDataAccess> dbStub = TestHelpers.GetVeilDataAccessFake();
            SetupVeilDataAccessWithCarts(dbStub, GetCartsListContainingCartWithNewAndUsed());
            SetupVeilDataAccessWithCountriesSetupForInclude(dbStub, GetCountries());
            SetupVeilDataAccessWithProvincesSetupForInclude(dbStub, GetProvinceList(viewModel));
            Mock<ControllerContext> contextStub = GetControllerContextWithSessionSetupToReturn(null);

            contextStub.
                SetupSet(c => c.HttpContext.Session[CheckoutController.OrderCheckoutDetailsKey] = It.IsAny<WebOrderCheckoutDetails>()).
                Callback((string name, object val) => checkoutDetails = (WebOrderCheckoutDetails)val);

            CheckoutController controller = CreateCheckoutController(dbStub.Object, context: contextStub.Object);

            await controller.NewShippingInfo(viewModel, false);

            Assert.That(
                () => 
                    viewModelMock.Verify(vm => vm.MapToNewAddress(),
                    Times.Once),
                Throws.Nothing);

            Assert.That(checkoutDetails != null);
            Assert.That(checkoutDetails.Address, Is.EqualTo(mappedAddress));
            Assert.That(checkoutDetails.ProvinceCode, Is.EqualTo(viewModel.ProvinceCode));
            Assert.That(checkoutDetails.CountryCode, Is.EqualTo(viewModel.CountryCode));
        }
        public async void NewShippingInfo_SaveAddress_MapsViewModelAndAddsNewAddressToDbSet()
        {
            Address mappedAddress = new Address();

            Mock<AddressViewModel> viewModelMock = new Mock<AddressViewModel>();
            viewModelMock.Setup(vm => vm.MapToNewAddress()).
                Returns(mappedAddress).
                Verifiable();

            var viewModel = viewModelMock.Object;
            viewModel.City = "Waterloo";
            viewModel.CountryCode = "CA";
            viewModel.ProvinceCode = "ON";
            viewModel.POBoxNumber = "1234";
            viewModel.PostalCode = "N2L 6R2";
            viewModel.StreetAddress = "445 Wes Graham Way";

            MemberAddress newAddress = null;

            Mock<IVeilDataAccess> dbStub = TestHelpers.GetVeilDataAccessFake();
            SetupVeilDataAccessWithCarts(dbStub, GetCartsListContainingCartWithNewAndUsed());
            SetupVeilDataAccessWithCountriesSetupForInclude(dbStub, GetCountries());
            
            Mock<DbSet<MemberAddress>> addressDbSetMock = TestHelpers.GetFakeAsyncDbSet(new List<MemberAddress>().AsQueryable());
            addressDbSetMock.
                Setup(adb => adb.Add(It.IsAny<MemberAddress>())).
                Returns<MemberAddress>(val => val).
                Callback<MemberAddress>(ma => newAddress = ma).
                Verifiable();

            dbStub.
                Setup(db => db.MemberAddresses).
                Returns(addressDbSetMock.Object);

            SetupVeilDataAccessWithProvincesSetupForInclude(dbStub, new List<Province> { new Province { ProvinceCode = viewModel.ProvinceCode, CountryCode = viewModel.CountryCode } });
            Mock<ControllerContext> contextStub = GetControllerContextWithSessionSetupToReturn(null);

            CheckoutController controller = CreateCheckoutController(dbStub.Object, context: contextStub.Object);

            await controller.NewShippingInfo(viewModel, true);

            Assert.That(
                () => 
                    viewModelMock.Verify(vm => vm.MapToNewAddress(),
                    Times.Once),
                Throws.Nothing);

            Assert.That(
                () => 
                    addressDbSetMock.Verify(adb => adb.Add(It.IsAny<MemberAddress>()),
                    Times.Once),
                Throws.Nothing);

            Assert.That(newAddress != null);
            Assert.That(newAddress.CountryCode, Is.EqualTo(viewModel.CountryCode));
            Assert.That(newAddress.ProvinceCode, Is.EqualTo(viewModel.ProvinceCode));
            Assert.That(newAddress.MemberId, Is.EqualTo(memberId));
            Assert.That(newAddress.Address, Is.SameAs(mappedAddress));
        }