Example #1
0
        public void AddAddress_WithCorrectData_ShouldSuccessfullyCreate()
        {
            string errorMessagePrefix = "AddressesService AddAddress() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.addressesService = new AddressesService(context, new UniShopUsersService(context));

            UniShopUser user = context.Users.First();

            AddressServiceModel testAddress = new AddressServiceModel
            {
                City           = "SofiqTestCraete",
                Street         = "TesterCreate",
                BuildingNumber = "223"
            };

            int expectedCount = user.Addresses.Count() + 1;

            bool actualResult = this.addressesService.AddAddress(testAddress, user.Id);
            int  actualCount  = user.Addresses.Count();

            Assert.True(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
 public AddressesController(
     IAddressesService addresses,
     ICurrentUserService currentUser)
 {
     this.addresses   = addresses;
     this.currentUser = currentUser;
 }
Example #3
0
        public async Task GetAddressByIdAsync_WithInvalidId_ShouldThrowArgumentException(int addressId)
        {
            //Arrange
            var context = InitializeContext.CreateContextForInMemory();

            addressesService = new AddressesService(context);
            var testAddress = new Address
            {
                Id           = 1,
                City         = "Sofia",
                Country      = "Bulgaria",
                CreatedOn    = DateTime.UtcNow,
                EmailAddress = "*****@*****.**",
                District     = "Student City",
                ZipCode      = 1000,
                PhoneNumber  = "08552332",
                Street       = "Ivan Vazov"
            };

            await context.Addresses.AddAsync(testAddress);

            await context.SaveChangesAsync();

            var expectErrorMessage = "Address with the given ID doesn't exist!";

            //Act

            var ex = await Assert.ThrowsAsync <ArgumentException>(() => addressesService.GetAddressByIdAsync(addressId));

            Assert.Equal(expectErrorMessage, ex.Message);
        }
 public AddressesApiController(IUsersService usersService, IAddressesService addressesService,
                               ILogger <AddressesApiController> logger)
 {
     this._usersService     = usersService;
     this._addressesService = addressesService;
     this._logger           = logger;
 }
Example #5
0
        public async Task GetAddressByIdAsync_WithValidId_ShouldReturnCorrectAddress()
        {
            //Arrange
            var context = InitializeContext.CreateContextForInMemory();

            addressesService = new AddressesService(context);

            var addressId = 1;

            var testAddress = new Address
            {
                Id           = 1,
                City         = "Sofia",
                Country      = "Bulgaria",
                CreatedOn    = DateTime.UtcNow,
                EmailAddress = "*****@*****.**",
                District     = "Student City",
                ZipCode      = 1000,
                PhoneNumber  = "08552332",
                Street       = "Ivan Vazov"
            };

            await context.Addresses.AddAsync(testAddress);

            await context.SaveChangesAsync();

            //Act
            var result = await addressesService.GetAddressByIdAsync(addressId);

            //Assert
            Assert.Equal(result, testAddress);
        }
 public OrderService(ApplicationDbContext context, IProductsService productsService,
                     IAddressesService addressesService)
 {
     _context          = context;
     _productsService  = productsService;
     _addressesService = addressesService;
 }
 public AddressesController(
     IAddressesService addressesService,
     UserManager <ApplicationUser> userManager)
 {
     this.addressesService = addressesService;
     this.userManager      = userManager;
 }
 public OrdersController(IOrdersService ordersService, IAddressesService addressesService, IMoviesService moviesService, IUsersService usersService)
 {
     this.ordersService    = ordersService;
     this.addressesService = addressesService;
     this.moviesService    = moviesService;
     this.usersService     = usersService;
 }
Example #9
0
 public AddressesController(UserManager <PandaUser> userManager, IAddressesService addressesService,
                            IUsersService usersService, ILogger <AddressesController> logger)
 {
     this._userManager      = userManager;
     this._addressesService = addressesService;
     this._usersService     = usersService;
     this._logger           = logger;
 }
 public OrdersController(UserManager <ApplicationUser> userManager, IOrdersService orderService, IUsersService userService, IShoppingCartItemsService shoppingCartItemsService, IAddressesService addressesService)
 {
     this.userManager              = userManager;
     this.ordersService            = orderService;
     this.userService              = userService;
     this.shoppingCartItemsService = shoppingCartItemsService;
     this.addressesService         = addressesService;
 }
 public ReceiptsController(IReceiptsService receiptsService,
                           IPackagesService packagesService, IAddressesService addressesService, ILogger <ReceiptsController> logger)
 {
     this._receiptsService  = receiptsService;
     this._packagesService  = packagesService;
     this._addressesService = addressesService;
     this._logger           = logger;
 }
 public OrderProductStoresController(IOrderProductStoresService orderProductStoresService, IOrderProductDetailsService orderProductDetailsService, IProductsService productsService, IOrdersService ordersService, IAddressesService addressesService, ICustomersService customersService)
 {
     _orderProductStoresService  = orderProductStoresService;
     _orderProductDetailsService = orderProductDetailsService;
     _productsService            = productsService;
     _ordersService    = ordersService;
     _addressesService = addressesService;
     _customersService = customersService;
 }
 public OrganizationsService(
     IAddressesService addressesService,
     IDeletableEntityRepository <Organization> organizationRepository,
     IDeletableEntityRepository <ApplicationUser> userRepository)
 {
     this.addressesService       = addressesService;
     this.organizationRepository = organizationRepository;
     this.userRepository         = userRepository;
 }
 public GetLocalLatestViewComponent(
     IArticlesService articleService,
     UserManager <ApplicationUser> userManager,
     IAddressesService addressesService)
 {
     this.articleService   = articleService;
     this.userManager      = userManager;
     this.addressesService = addressesService;
 }
Example #15
0
 public DoctorsService(HealthDbContext db,
                       IAddressesService addressesService,
                       IPhonesService phonesService,
                       IEmailsService emailsService)
 {
     this.db               = db;
     this.phonesService    = phonesService;
     this.addressesService = addressesService;
     this.emailsService    = emailsService;
 }
Example #16
0
 public OrdersController(ISuppliersService suppliersService,
                         IAddressesService addressesService, IShoppingCartsService shoppingCartsService
                         , IUniShopUsersService uniShopUsersService, IOrderService orderService)
 {
     this.suppliersService     = suppliersService;
     this.addressesService     = addressesService;
     this.shoppingCartsService = shoppingCartsService;
     this.uniShopUsersService  = uniShopUsersService;
     this.orderService         = orderService;
 }
Example #17
0
 public OrdersController(IAddressesService adressesService, IUserService userService, IOrderService orderService,
                         IShoppingBagService shoppingBagService, IMapper mapper, IRepository <OrderProduct> orderProductRepository)
 {
     this.adressesService        = adressesService;
     this.userService            = userService;
     this.orderService           = orderService;
     this.shoppingBagService     = shoppingBagService;
     this.mapper                 = mapper;
     this.orderProductRepository = orderProductRepository;
 }
Example #18
0
 public OrdersController(
     IOrdersService ordersService,
     IUsersService usersService,
     IAddressesService addressesService,
     IShoppingCartsService shoppingCartsService)
 {
     this.ordersService        = ordersService;
     this.usersService         = usersService;
     this.addressesService     = addressesService;
     this.shoppingCartsService = shoppingCartsService;
 }
 public AddressesModel(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IMapper mapper,
     IAddressesService addressesService)
 {
     this.userManager      = userManager;
     this.signInManager    = signInManager;
     this.mapper           = mapper;
     this.addressesService = addressesService;
 }
Example #20
0
 public ParentsService(
     UserManager <SystemUser> userManager,
     IRepository <Parent> parentsRepository,
     IAddressesService addressesService,
     IDistrictsService districtsService
     )
 {
     this.userManager       = userManager;
     this.parentsRepository = parentsRepository;
     this.addressesService  = addressesService;
     this.districtsService  = districtsService;
 }
Example #21
0
 public ParentController(
     IParentsService parentsService,
     IDistrictsService districtsService,
     IAddressesService addressesService,
     ICalculatorService calculatorService,
     ICandidatesService candidatesService)
 {
     this.parentsService    = parentsService;
     this.districtsService  = districtsService;
     this.addressesService  = addressesService;
     this.calculatorService = calculatorService;
     this.candidatesService = candidatesService;
 }
Example #22
0
 public AdsService(SellMeDbContext context, IAddressesService addressesService, IUsersService usersService,
                   ICategoriesService categoriesService, IUpdatesService updatesService,
                   ISubCategoriesService subCategoriesService, IMapper mapper, ICloudinaryService cloudinaryService)
 {
     this.context              = context;
     this.addressesService     = addressesService;
     this.usersService         = usersService;
     this.categoriesService    = categoriesService;
     this.updatesService       = updatesService;
     this.subCategoriesService = subCategoriesService;
     this.mapper            = mapper;
     this.cloudinaryService = cloudinaryService;
 }
Example #23
0
        public AddressModelTests()
        {
            AutoMapperBootStrapper.CreateMapperConfiguration();
            IOptions <SiteDbContext> dataBaseConfig =
                new OptionsManager <SiteDbContext>(new IConfigureOptions <SiteDbContext> [0]);

            dataBaseConfig.Value.DefaultConnectionString =
                @"Data Source=haw.trustteam.be,41433; Initial Catalog=bocotransapp; Integrated Security=false;User ID =sa;Password=abit@complicated35; MultipleActiveResultSets=True";

            IUnitOfWork unitOfWork = new UnitOfWork(dataBaseConfig);

            _addressesService = new AddressesService(unitOfWork, null);
        }
Example #24
0
        public PersonsService(HealthDbContext db,
                              IAddressesService addressesService,
                              IPhonesService phonesService,
                              IEmailsService emailsService,
                              IRelativesService relativesService)
        {
            this.db = db;

            this.addressesService = addressesService;
            this.phonesService    = phonesService;
            this.emailsService    = emailsService;
            this.relativesService = relativesService;
        }
Example #25
0
 public CustomersService(
     IDeletableEntityRepository <Customer> customersRepository,
     IAddressesService addressesService,
     IPhonesServices phonesServices,
     IEmailsService emailsService,
     IOrganizationsService organizationsService)
 {
     this.customersRepository  = customersRepository;
     this.addressesService     = addressesService;
     this.phonesServices       = phonesServices;
     this.emailsService        = emailsService;
     this.organizationsService = organizationsService;
 }
Example #26
0
        /// <summary>
        /// Constructor injection
        /// </summary>
        /// <param name="addressesService"></param>
        /// <param name="errorsFactory"></param>
        /// <param name="paramParser"></param>
        public AddressesController(
            IAddressesService addressesService,
            IErrorsResultFactory errorsFactory,
            ParameterParser paramParser)
        {
            this.addressesService = addressesService ??
                                    throw new ArgumentNullException(nameof(addressesService));

            this.errorsFactory = errorsFactory ??
                                 throw new ArgumentNullException(nameof(errorsFactory));

            this.paramParser = paramParser ??
                               throw new ArgumentNullException(nameof(paramParser));
        }
Example #27
0
        public void GetAddressesByUserName_WithNonExistentUser_ShouldReturnEmptyResults()
        {
            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.addressesService = new AddressesService(context, new UniShopUsersService(context));

            UniShopUser user = context.Users.Last();

            List <AddressServiceModel> actualResults = this.addressesService.GetAddressesByUserName(user.UserName + "Test").ToList();
            int expectedResults = 0;

            Assert.Equal(expectedResults, actualResults.Count());
        }
Example #28
0
        public void GetAllCountries_ShouldReturnTheCorrectCount()
        {
            //Arrange
            var context = InitializeContext.CreateContextForInMemory();

            addressesService = new AddressesService(context);
            var expectedCount = 142;

            //Act
            var countriesCount = addressesService.GetAllCountries().Count;

            //Assert
            Assert.Equal(expectedCount, countriesCount);
        }
Example #29
0
 public OrdersService(
     IDeletableEntityRepository <Product> productRepository,
     IDeletableEntityRepository <ShoppingCart> shoppingCartRepository,
     IDeletableEntityRepository <Order> orderRepository,
     IUsersService usersService,
     IAddressesService addressesService,
     IShoppingCartsService shoppingCartsService)
 {
     this.productRepository      = productRepository;
     this.shoppingCartRepository = shoppingCartRepository;
     this.orderRepository        = orderRepository;
     this.usersService           = usersService;
     this.addressesService       = addressesService;
     this.shoppingCartsService   = shoppingCartsService;
 }
Example #30
0
 public TrucksService(
     IDeletableEntityRepository <Order> orderRepository,
     IAddressesService addressesService,
     IMapper mapper,
     IPriorityTypesService priorityTypesService,
     ITruckTypesService truckTypesService,
     IUsersService usersService)
 {
     this.orderRepository      = orderRepository;
     this.addressesService     = addressesService;
     this.mapper               = mapper;
     this.priorityTypesService = priorityTypesService;
     this.truckTypesService    = truckTypesService;
     this.usersService         = usersService;
 }
 public AddressesApiController(IUserService service, IAddressesService service2)
 {
     this._userService = service;
     this._addressesService = service2;
 }