public void DeleteContactSuccess() { // Arrange IRepAddressBook rep = new RepAddressBook(); FakeConsoleInterface fakeConsole = new FakeConsoleInterface( new List <string> { "1", "3", "1", "Name 1", "Address 1", "1243545462", "01/01/1999", "email", "", "4", "1", "", "5" }); AddressBookService target = new AddressBookService(fakeConsole, rep); // act target.Start(); // asset StringAssert.Contains(fakeConsole.Output, String.Format(Constants.Messages.SuccessfullyDeleted)); }
public void AddWorkContactTestInvalidTitle() { // Arrange IRepAddressBook rep = new RepAddressBook(); FakeConsoleInterface fakeConsole = new FakeConsoleInterface( new List <string> { "1", "2", "1", "Name 1", "Address 1", "1243545462", "www.google.com", "Emp", "email", "NON", "", "NOnE", "", "5" }); AddressBookService target = new AddressBookService(fakeConsole, rep); // act target.Start(); // asset Assert.IsNotNull(rep.SearchByTaxID("1")); StringAssert.Contains(fakeConsole.Output, Constants.Messages.InvalidTitle); }
public void AddFriendContactTestSuccess() { // Arrange IRepAddressBook rep = new RepAddressBook(); FakeConsoleInterface fakeConsole = new FakeConsoleInterface( new List <string> { "1", "3", "1", "Name 1", "Address 1", "1243545462", "01/01/1999", "email", "", "5" }); AddressBookService target = new AddressBookService(fakeConsole, rep); // act target.Start(); // asset Assert.IsNotNull(rep.SearchByTaxID("1")); StringAssert.Contains(fakeConsole.Output, Constants.Messages.SuccessfullyAdded); }
public void AddCompanyContactInvalidNameSuccess() { // Arrange IRepAddressBook rep = new RepAddressBook(); FakeConsoleInterface fakeConsole = new FakeConsoleInterface( new List <string> { "1", "1", "1", "", "Name 1", "Address 1", "1243545462", "www.google.com", "", "5" }); AddressBookService target = new AddressBookService(fakeConsole, rep); // act target.Start(); // asset Assert.IsNotNull(rep.SearchByTaxID("1")); StringAssert.Contains(fakeConsole.Output, String.Format(Constants.Messages.FieldCannotBeNull, "Name")); }
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, CookieService cookieService) : base(cartService, contentRepository, urlResolver, mailService, checkoutService, contentLoader, paymentService, localizationService, cartHelper, currencyService, addressBookService, controllerExceptionHandler, customerContextFacade, cookieService) { }
public void AddCompanyContactUniqueTaxIDSuccess() { // Arrange IRepAddressBook rep = new RepAddressBook(); FakeConsoleInterface fakeConsole = new FakeConsoleInterface( new List <string> { "1", "1", "1", "Name 1", "Address 1", "1243545462", "www.google.com", "", "1", "1", "1", "", "2", "Name 1", "Address 1", "1243545462", "www.google.com", "", "5" }); AddressBookService target = new AddressBookService(fakeConsole, rep); // act target.Start(); // asset StringAssert.Contains(fakeConsole.Output, Constants.Messages.taxIDAlreadyExsists); }
public void EditCompanyContactSuccess() { // Arrange IRepAddressBook rep = new RepAddressBook(); FakeConsoleInterface fakeConsole = new FakeConsoleInterface( new List <string> { "1", "1", "1", "Name 1", "Address 1", "1243545462", "www.google.com", "", "3", "1", "Name 2", "Address 2", "1243545462", "www.google.com", "", "5" }); AddressBookService target = new AddressBookService(fakeConsole, rep); // act target.Start(); // asset StringAssert.Contains(fakeConsole.Output, Constants.Messages.SuccessfullyUpdated); }
public LoginControllerTests() { _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 <SiteUser> >(); var authenticationManager = new Mock <IAuthenticationManager>(); _orderGroupFactoryMock = new Mock <IOrderGroupFactory>(); 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, _orderGroupFactoryMock.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 <SiteUser> >(userStore.Object); _signinManagerMock = new Mock <ApplicationSignInManager <SiteUser> >(_userManagerMock.Object, authenticationManager.Object, new ApplicationOptions()); _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 void Setup() { _unitOfWork = new Mock <IUnitOfWork> { DefaultValue = DefaultValue.Mock }; _unitOfWorkFactory = () => _unitOfWork.Object; _addressBookService = new AddressBookService(_unitOfWorkFactory); }
public OrderConfirmationMailPageController( ConfirmationService confirmationService, AddressBookService addressBookService, CustomerContextFacade customerContextFacade, IOrderGroupCalculator orderGroupTotalsCalculator) : base(confirmationService, addressBookService, customerContextFacade, orderGroupTotalsCalculator) { }
public SubscriptionDetailController(AddressBookService addressBookService, IContentLoader contentLoader, ISettingsService settingsService) { _addressBookService = addressBookService; _contentLoader = contentLoader; _settingsService = settingsService; }
public OrderConfirmationController( ConfirmationService confirmationService, AddressBookService addressBookService, CustomerContextFacade customerContextFacade, IOrderGroupTotalsCalculator orderGroupTotalsCalculator, IKlarnaCheckoutService klarnaCheckoutService) : base(confirmationService, addressBookService, customerContextFacade, orderGroupTotalsCalculator) { _klarnaCheckoutService = klarnaCheckoutService; }
public OrderConfirmationMailController(ConfirmationService confirmationService, AddressBookService addressBookService, CustomerService customerService, IOrderGroupCalculator orderGroupCalculator) { _confirmationService = confirmationService; _addressBookService = addressBookService; _customerService = customerService; _orderGroupCalculator = orderGroupCalculator; }
public OrderConfirmationController( ConfirmationService confirmationService, AddressBookService addressBookService, IRecommendationService recommendationService, CustomerContextFacade customerContextFacade, IOrderGroupTotalsCalculator orderGroupTotalsCalculator) : base(confirmationService, addressBookService, customerContextFacade, orderGroupTotalsCalculator) { _recommendationService = recommendationService; }
public async void CitiesAreGrouping() { // Arange var service = new AddressBookService(); // Act var cities = service.GetCityGroups(); // Assert Assert.InRange <int>(cities.Count, 10, 5000); }
public void HasAddresses() { // Arange var service = new AddressBookService(); // Act var addresses = service.GetAddresses(); // Assert Assert.NotEmpty(addresses); }
protected OrderConfirmationControllerBase( ConfirmationService confirmationService, AddressBookService addressBookService, CustomerContextFacade customerContextFacade, IOrderGroupTotalsCalculator orderGroupTotalsCalculator) { ConfirmationService = confirmationService; _addressBookService = addressBookService; CustomerContext = customerContextFacade; _orderGroupTotalsCalculator = orderGroupTotalsCalculator; }
private static int GetAllMemberCount(List <ArticleInfoView> lstContent) { int allMembersCount = 0; try { if (lstContent != null && lstContent.Count > 0) { var lstArticles = lstContent[0]; List <string> allMember = new List <string>(); if (!string.IsNullOrEmpty(lstArticles.ToDepartment) || !string.IsNullOrEmpty(lstArticles.ToTag)) { AddressBookService addressBookService = new AddressBookService(); var userInfos = addressBookService.Repository.Entities.Where(address => address.EmployeeStatus == "A" && address.DeleteFlag != 1).ToList(); if (!string.IsNullOrEmpty(lstArticles.ToUser)) { allMember.AddRange(lstArticles.ToUser.Split(',')); } if (!string.IsNullOrEmpty(lstArticles.ToDepartment)) { var allDepartment = lstArticles.ToDepartment.Split(','); foreach (var d in allDepartment) { var inDepartmentMem = userInfos.Where(a => a.Department.Replace("[", ",").Replace("]", ",").Contains("," + d + ",")).ToList(); allMember.AddRange(inDepartmentMem.Select(mem => mem.UserId)); } log.Debug("Send to Department {0}", lstArticles.ToDepartment); } if (!string.IsNullOrEmpty(lstArticles.ToTag)) { var allTag = lstArticles.ToTag.Split(','); foreach (var t in allTag) { var inTagMem = userInfos.Where(a => a.TagList.Replace("[", ",").Replace("]", ",").Contains("," + t + ",")).ToList(); allMember.AddRange(inTagMem.Select(mem => mem.UserId)); } log.Debug("Send to Tag {0}", lstArticles.ToTag); } allMembersCount = allMember.Distinct().Count(); log.Debug("Send to members {0}", allMembersCount); } else { allMembersCount = lstArticles.ToUser.Split(',').Count(); log.Debug("Only Send to user {0},Count{1}", lstArticles.ToUser, allMembersCount); } } } catch (Exception e) { log.Error(e); } return(allMembersCount); }
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); }
public void Setup() { addressBook = new AddressBookService(); Person contact = new Person("Sonal", "Karle", "Ghatkopar", "Mumbai", "Maharashtra", "400 075", "91 9702420754", "*****@*****.**", "Friends"); Person contact1 = new Person("Sona", "Karle", "Gokhalenagar", "Pune", "Maharashtra", "411 016", "91 8806184089", "*****@*****.**", "Family"); Person contact2 = new Person("Ajinkya", "Patil", "Gandhinagar", "Ahmdabad", "Gujrat", "512 222", "91 7854373737", "*****@*****.**", "Profession"); Person contact3 = new Person("Yogesh", "Kadam", "Nashik", "Nashik", "Maharashtra", "400 022", "91 8657373737", "*****@*****.**", "Family"); addressBook.AddContact(contact); addressBook.AddContact(contact1); addressBook.AddContact(contact2); addressBook.AddContact(contact3); }
public void Setup() { addressBook = new AddressBookService(); Contact contact = new Contact("Sam", "Sher", "Shivajinagr", "Pune", "Mah", "111 222", "91 2837373737", "*****@*****.**", "Friends"); Contact contact1 = new Contact("Maj", "Sin", "vile", "mumbai", "Mah", "111 222", "91 2837373737", "*****@*****.**", "Family"); Contact contact2 = new Contact("Sim", "Ran", "patiala", "patiala", "Punjab", "111 222", "91 2837373737", "*****@*****.**", "Profession"); Contact contact3 = new Contact("M", "K", "vanas", "Pune", "Mah", "111 222", "91 2837373737", "*****@*****.**", "Family"); addressBook.AddContact(contact); addressBook.AddContact(contact1); addressBook.AddContact(contact2); addressBook.AddContact(contact3); }
protected OrderConfirmationControllerBase( ConfirmationService confirmationService, AddressBookService addressBookService, CustomerContextFacade customerContextFacade, IOrderGroupCalculator orderGroupCalculator, IMarketService marketService) { ConfirmationService = confirmationService; _addressBookService = addressBookService; CustomerContext = customerContextFacade; _orderGroupCalculator = orderGroupCalculator; _marketService = marketService; }
public OrderConfirmationController( ConfirmationService confirmationService, AddressBookService addressBookService, CustomerContextFacade customerContextFacade, IOrderGroupCalculator orderGroupCalculator, IMarketService marketService, IRecommendationService recommendationService, IKlarnaCheckoutService klarnaCheckoutService) : base(confirmationService, addressBookService, customerContextFacade, orderGroupCalculator, marketService) { _marketService = marketService; _recommendationService = recommendationService; _klarnaCheckoutService = klarnaCheckoutService; }
public void Service_CannotAddNonUniqueContact_WillThrow() { // Arrange AddressBook addressBook = new AddressBookBuilder() .AddContact3() .Build(); Contact contact = AddressBookBuilder.BuildContact3(addressBook.Id); IAddressBookRepository repo = Substitute.For <IAddressBookRepository>(); repo.GetContactAsync(contact.Name, contact.Address).Returns(addressBook); AddressBookService target = new AddressBookService(repo); // Act, Assert Assert.ThrowsAsync <ArgumentException>(() => target.AddContactAsync(contact)); }
public void TestGetOldestPersonSuccess() { var personList = new List <Person> { new Person { Name = "George", Gender = "Male" } }; _addressBookLoader.Setup(c => c.LoadAddressBook()).Returns(personList); classUnderTest = new AddressBookService(_addressBookLoader.Object, _logger.Object); var result = classUnderTest.GetOldestPerson(); Assert.Equal(personList[0], result.Result); }
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 void TestGetAgeDifferenceError() { var personList = new List <Person> { new Person { Name = "George", Gender = "Male", DateOfBirth = Convert.ToDateTime("01/01/2001") }, new Person { Name = "Beck", Gender = "Male", DateOfBirth = Convert.ToDateTime("01/01/2000") } }; _addressBookLoader.Setup(c => c.LoadAddressBook()).Returns(personList); classUnderTest = new AddressBookService(_addressBookLoader.Object, _logger.Object); var result = classUnderTest.GetAgeDifference("Beck", "Jack"); Assert.Null(result.Result); }
public void DeleteAddressBookEntry_ShouldReturnErrorResult_WhenEntryNotFound() { // Arrange const string addressBookEntryId = "AddressBookEntries/123"; _unitOfWork.Setup(u => u.AddressBookEntries.Load(addressBookEntryId)).Returns((AddressBookEntry)null); _addressBookService = new AddressBookServiceBuilder().WithUnitOfWorkFactory(_unitOfWorkFactory).Build(); // Act var result = _addressBookService.DeleteAddressBookEntry(addressBookEntryId); // Assert result.ResultType.Should().Be(AddressBookCommandResultType.Error); result.Error.Should().Be("This address book entry has already been deleted."); _unitOfWork.Verify(m => m.Commit(), Times.Never); _unitOfWork.Verify(m => m.Dispose(), Times.Once); }
public void DeleteAddressBookEntry_ShouldReturnSuccessResult_WhenDeleted() { // Arrange const string addressBookEntryId = "AddressBookEntries/123"; var addressBookEntry = AddressBookEntry.Create(addressBookEntryId, "ln", "st1", "st2", "c", "st", "84000", "hp", "mp", "em"); _unitOfWork.Setup(u => u.AddressBookEntries.Load(addressBookEntryId)).Returns(addressBookEntry); _addressBookService = new AddressBookServiceBuilder().WithUnitOfWorkFactory(_unitOfWorkFactory).Build(); // Act var result = _addressBookService.DeleteAddressBookEntry(addressBookEntryId); // Assert result.ResultType.Should().Be(AddressBookCommandResultType.Success); _unitOfWork.Verify(m => m.AddressBookEntries.Delete(addressBookEntry.Id), Times.Once); _unitOfWork.Verify(m => m.Commit(), Times.Once); _unitOfWork.Verify(m => m.Dispose(), Times.Once); }
public OrderConfirmationController( ConfirmationService confirmationService, AddressBookService addressBookService, CustomerContextFacade customerContextFacade, CheckoutService checkoutService, ICartService cartService, IOrderGroupCalculator orderGroupCalculator, IOrderRepository orderRepository, IMarketService marketService, IRecommendationService recommendationService, ISwedbankPayCheckoutService swedbankPayCheckoutService) : base(confirmationService, addressBookService, customerContextFacade, orderGroupCalculator, marketService) { _checkoutService = checkoutService; _cartService = cartService; _orderRepository = orderRepository; _recommendationService = recommendationService; _swedbankPayCheckoutService = swedbankPayCheckoutService; }