public void Setup() { _cultureInfo = CultureInfo.CurrentUICulture; var english = CultureInfo.CreateSpecificCulture("en"); Thread.CurrentThread.CurrentUICulture = english; var localizationService = new MemoryLocalizationService { FallbackBehavior = FallbackBehaviors.MissingMessage }; localizationService.AddString(english, "/Login/Form/Error/WrongPasswordOrEmail", "WrongPasswordOrEmail"); localizationService.AddString(english, "/Shared/Address/DefaultAddressName", "Default address"); var startPageMock = new Mock<StartPage>(); var userStore = new Mock<IUserStore<ApplicationUser>>(); var authenticationManager = new Mock<IAuthenticationManager>(); var customercontextFacadeMock = new Mock<CustomerContextFacade>(); var countryManagerFacadeMock = new Mock<CountryManagerFacade>(); countryManagerFacadeMock.Setup(x => x.GetCountries()).Returns(() => new CountryDto()); var addressBookService = new AddressBookService(customercontextFacadeMock.Object, countryManagerFacadeMock.Object); var request = new Mock<HttpRequestBase>(); _httpContextMock = new Mock<HttpContextBase>(); _requestContext = new Mock<RequestContext>(); _controllerExceptionHandler = new Mock<ControllerExceptionHandler>(); _contentLoaderMock = new Mock<IContentLoader>(); _userManagerMock = new Mock<ApplicationUserManager>(userStore.Object); _signinManagerMock = new Mock<ApplicationSignInManager>(_userManagerMock.Object, authenticationManager.Object); _userServiceMock = new Mock<UserService>(_userManagerMock.Object, _signinManagerMock.Object, authenticationManager.Object, localizationService, customercontextFacadeMock.Object); request.Setup( x => x.Url) .Returns(new Uri(_testUrl)); request.SetupGet( x => x.UrlReferrer) .Returns(new Uri(_testUrl)); _httpContextMock.SetupGet( x => x.Request) .Returns(request.Object); _contentLoaderMock.Setup(x => x.Get<StartPage>(It.IsAny<ContentReference>())).Returns(startPageMock.Object); _subject = new LoginControllerForTest(_signinManagerMock.Object, _userManagerMock.Object, _userServiceMock.Object, localizationService, _contentLoaderMock.Object, addressBookService, _controllerExceptionHandler.Object); _subject.ControllerContext = new ControllerContext(_httpContextMock.Object, new RouteData(), _subject); _exceptionContext = new ExceptionContext { HttpContext = _httpContextMock.Object, RequestContext = _requestContext.Object }; }
public AddressBookServiceTests() { _address1 = CustomerAddress.CreateInstance(); _address1.AddressId = new PrimaryKeyId(new Guid(_address1Id)); _address1.Name = _address1.AddressId.ToString(); var address2 = CustomerAddress.CreateInstance(); address2.AddressId = new PrimaryKeyId(new Guid(_address2Id)); address2.Name = address2.AddressId.ToString(); _currentContact = new FakeCurrentContact(new[] { _address1, address2 }) { PreferredBillingAddress = _address1, PreferredShippingAddress = _address1 }; var customerContext = new FakeCustomerContext(_currentContact); var countryManager = new FakeCountryManager(); _subject = new AddressBookService(customerContext, countryManager, new Mock<IOrderFactory>().Object); }
public void Setup() { _address1 = CustomerAddress.CreateInstance(); _address1.AddressId = new PrimaryKeyId(Guid.NewGuid()); _address1.Name = _address1.AddressId.ToString(); _address2 = CustomerAddress.CreateInstance(); _address2.AddressId = new PrimaryKeyId(Guid.NewGuid()); _address2.Name = _address2.AddressId.ToString(); _currentContact = new FakeCurrentContact(new[] { _address1, _address2 }); var customerContext = new FakeCustomerContext(_currentContact); var countryManager = new FakeCountryManager(); _subject = new AddressBookService(customerContext, countryManager); }
public CheckoutControllerForTest(ICartService cartService, IContentRepository contentRepository, UrlResolver urlResolver, IMailService mailService, ICheckoutService checkoutService, IContentLoader contentLoader, IPaymentService paymentService, LocalizationService localizationService, Func<string,CartHelper> cartHelper, CurrencyService currencyService, AddressBookService addressBookService, ControllerExceptionHandler controllerExceptionHandler, CustomerContextFacade customerContextFacade) : base(cartService, contentRepository, urlResolver, mailService, checkoutService, contentLoader, paymentService, localizationService, cartHelper, currencyService, addressBookService, controllerExceptionHandler,customerContextFacade) { }
public void LoadAddress_WhenAddressIdDoesNotExist_ShouldThrowException() { _currentContact = new FakeCurrentContact(Enumerable.Empty<CustomerAddress>()); var customerContext = new FakeCustomerContext(_currentContact); var countryManager = new FakeCountryManager(); _subject = new AddressBookService(customerContext, countryManager); var model = new Address(); model.AddressId = Guid.NewGuid(); _subject.LoadAddress(model); }