Exemplo n.º 1
0
 public ImageService(
     CosinessDbContext context,
     IFileStorage blobStorageService)
 {
     this._context            = context;
     this._blobStorageService = blobStorageService;
 }
Exemplo n.º 2
0
        public OrderServiceTests()
        {
            var options = new DbContextOptionsBuilder <CosinessDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context = new CosinessDbContext(options);

            var shoppingCartService = new Mock <IShoppingCartService>();

            shoppingCartService
            .Setup(x => x.ClearProductsAsync(It.IsAny <string>()))
            .Callback((string recipientId) =>
            {
                var shoppingCart = _context.ShoppingCarts
                                   .FirstOrDefault(x => x.RecipientId == recipientId);

                _context.ShoppingCartsProducts.RemoveRange(shoppingCart.Products);
                _context.SaveChanges();
            });

            _orderService = new OrderService(_context, shoppingCartService.Object);

            SeedData();

            AutoMapperConfig.RegisterMappings(
                typeof(OrderInputModel).GetTypeInfo().Assembly);
        }
Exemplo n.º 3
0
 public AddressService(
     CosinessDbContext context,
     IBaseNameOnlyEntityService <Town> townsService)
 {
     _context      = context;
     _townsService = townsService;
 }
Exemplo n.º 4
0
 public OrderService(
     CosinessDbContext context,
     IShoppingCartService shoppingCartService)
 {
     _context             = context;
     _shoppingCartService = shoppingCartService;
 }
        public ShoppingCartServiceTests()
        {
            var options = new DbContextOptionsBuilder <CosinessDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context = new CosinessDbContext(options);

            _shoppingCartService = new ShoppingCartService(_context);

            SeedData();
        }
        protected BaseNameOnlyEntityServiceTests()
        {
            var options = new DbContextOptionsBuilder <CosinessDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context = new CosinessDbContext(options);

            _entitiesService = new BaseNameOnlyEntityService <TEntity>(_context);

            _entityId = Guid.NewGuid().ToString();

            SeedData();
        }
        public ReviewServiceTests()
        {
            var options = new DbContextOptionsBuilder <CosinessDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context = new CosinessDbContext(options);

            this.SeedData();

            _reviewService = new ReviewService(_context);

            AutoMapperConfig.RegisterMappings(
                typeof(ReviewInputModel).GetTypeInfo().Assembly);
        }
Exemplo n.º 8
0
 public ProductService(
     CosinessDbContext context,
     IBaseNameOnlyEntityService <Category> categoryService,
     IBaseNameOnlyEntityService <Set> setService,
     IBaseNameOnlyEntityService <Dimension> dimensionService,
     IBaseNameOnlyEntityService <Color> colorService,
     IBaseNameOnlyEntityService <Material> materialService,
     IImageService imageService)
 {
     _context          = context;
     _categoryService  = categoryService;
     _setService       = setService;
     _dimensionService = dimensionService;
     _colorService     = colorService;
     _materialService  = materialService;
     _imageService     = imageService;
 }
Exemplo n.º 9
0
        public AddressServiceTests()
        {
            var options = new DbContextOptionsBuilder <CosinessDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context = new CosinessDbContext(options);

            this.SeedData();

            var townsService = new Mock <IBaseNameOnlyEntityService <Town> >();

            townsService.Setup(x => x.GetIdByNameAsync(_townName))
            .ReturnsAsync(_townId);

            _addressesService = new AddressService(_context, townsService.Object);

            AutoMapperConfig.RegisterMappings(
                typeof(AddressInputModel).GetTypeInfo().Assembly);
        }
Exemplo n.º 10
0
        public ImageServiceTests()
        {
            var options = new DbContextOptionsBuilder <CosinessDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context = new CosinessDbContext(options);

            SeedData();

            _minnieFileContent = new MemoryStream();
            var minnieImageMock = new Mock <IFormFile>();

            minnieImageMock.Setup(x => x.FileName)
            .Returns(_minnieImage);
            minnieImageMock.Setup(x => x.OpenReadStream())
            .Returns(_minnieFileContent);
            _minnieImageFile = minnieImageMock.Object;

            _spaceFileContent = new MemoryStream();
            var spaceImageMock = new Mock <IFormFile>();

            spaceImageMock.Setup(x => x.FileName)
            .Returns(_spaceImage);
            spaceImageMock.Setup(x => x.OpenReadStream())
            .Returns(_spaceFileContent);
            _spaceImageFile = spaceImageMock.Object;

            var storageService = new Mock <IFileStorage>();

            storageService.Setup(x => x.UploadAsync(_minnieImage, _minnieFileContent))
            .ReturnsAsync(_minnieUrl);
            storageService.Setup(x => x.UploadAsync(_spaceImage, _spaceFileContent))
            .ReturnsAsync(_spaceUrl);

            _imageService = new ImageService(_context, storageService.Object);
        }
Exemplo n.º 11
0
 public BaseNameOnlyEntityService(CosinessDbContext context)
 {
     _context = context;
 }
Exemplo n.º 12
0
 public ShoppingCartService(CosinessDbContext context)
 {
     _context = context;
 }
Exemplo n.º 13
0
 public ReviewService(CosinessDbContext context)
 {
     this._context = context;
 }
Exemplo n.º 14
0
 public StorageService(CosinessDbContext context)
 {
     this._context = context;
 }
Exemplo n.º 15
0
        public ProductServiceTests()
        {
            var options = new DbContextOptionsBuilder <CosinessDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context = new CosinessDbContext(options);

            _categorySheetsId = SetBaseNameOnlyEntityId <Category>(_categorySheetsName);
            _categoryPillowId = SetBaseNameOnlyEntityId <Category>(_categoryPillowName);

            _setMoonId  = SetBaseNameOnlyEntityId <Set>(_setMoonName);
            _setSpaceId = SetBaseNameOnlyEntityId <Set>(_setSpaceName);

            _dimensionLargeId = SetBaseNameOnlyEntityId <Dimension>(_dimensionLargeName);
            _dimensionSmallId = SetBaseNameOnlyEntityId <Dimension>(_dimensionSmallName);

            _colorBlueId = SetBaseNameOnlyEntityId <Color>(_colorBlueName);
            _colorRedId  = SetBaseNameOnlyEntityId <Color>(_colorRedName);

            _materialSilkId  = SetBaseNameOnlyEntityId <Material>(_materialSilkName);
            _materialSatinId = SetBaseNameOnlyEntityId <Material>(_materialSatinName);

            this.SeedData();

            _context.SaveChanges();

            var categoryService = new Mock <IBaseNameOnlyEntityService <Category> >();

            categoryService.Setup(x => x.GetIdByNameAsync(_categorySheetsName))
            .ReturnsAsync(_categorySheetsId);
            categoryService.Setup(x => x.GetIdByNameAsync(_categoryPillowName))
            .ReturnsAsync(_categoryPillowId);

            var setService = new Mock <IBaseNameOnlyEntityService <Set> >();

            setService.Setup(x => x.GetIdByNameAsync(_setMoonName))
            .ReturnsAsync(_setMoonId);
            setService.Setup(x => x.GetIdByNameAsync(_setSpaceName))
            .ReturnsAsync(_setSpaceId);

            var dimensionService = new Mock <IBaseNameOnlyEntityService <Dimension> >();

            dimensionService.Setup(x => x.GetIdByNameAsync(_dimensionLargeName))
            .ReturnsAsync(_dimensionLargeId);
            dimensionService.Setup(x => x.GetIdByNameAsync(_dimensionSmallName))
            .ReturnsAsync(_dimensionSmallId);

            var colorService = new Mock <IBaseNameOnlyEntityService <Color> >();

            colorService.Setup(x => x.GetIdByNameAsync(_colorBlueName))
            .ReturnsAsync(_colorBlueId);
            colorService.Setup(x => x.GetIdByNameAsync(_colorRedName))
            .ReturnsAsync(_colorRedId);

            var materialService = new Mock <IBaseNameOnlyEntityService <Material> >();

            materialService.Setup(x => x.GetIdByNameAsync(_materialSilkName))
            .ReturnsAsync(_materialSilkId);
            materialService.Setup(x => x.GetIdByNameAsync(_materialSatinName))
            .ReturnsAsync(_materialSatinId);

            var imageService = new Mock <IImageService>();

            var imageMock = new Mock <IFormFile>();

            imageMock.Setup(x => x.FileName)
            .Returns(_imageName);
            imageMock.Setup(x => x.OpenReadStream())
            .Returns(new MemoryStream());
            _image = imageMock.Object;

            _productService = new ProductService(
                _context,
                categoryService.Object,
                setService.Object,
                dimensionService.Object,
                colorService.Object,
                materialService.Object,
                imageService.Object);
        }