Ejemplo n.º 1
0
        public async Task AddAsync_ReturnsTrue_IfProductDoesntExist()
        {
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var favouriteProductsRepository = new EfDeletableEntityRepository <UserFavouriteProduct>(context);
            var favouriteProductService     = new FavouriteProductsService(favouriteProductsRepository);

            var shouldBeTrue = await favouriteProductService.AddAsync("productId1", "userId1");

            Assert.True(shouldBeTrue);
        }
Ejemplo n.º 2
0
        public void All_ThrowsExceptionIfIdIsNull()
        {
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var favouriteProductsRepository = new EfDeletableEntityRepository <UserFavouriteProduct>(context);
            var favouriteProductService     = new FavouriteProductsService(favouriteProductsRepository);

            Assert.Throws <ArgumentNullException>(() =>
            {
                favouriteProductService.All <ProductSingleViewModel>(null);
            });
        }
Ejemplo n.º 3
0
        public async Task AddAsync_ThrowsException_IfParamatersAreNull()
        {
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var favouriteProductsRepository = new EfDeletableEntityRepository <UserFavouriteProduct>(context);
            var favouriteProductService     = new FavouriteProductsService(favouriteProductsRepository);

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await favouriteProductService.AddAsync(null, null);
            });
        }
Ejemplo n.º 4
0
        public async Task DeleteAsync_ReturnsTrue_IfDataIsCorect()
        {
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var favouriteProductsRepository = new EfDeletableEntityRepository <UserFavouriteProduct>(context);
            var favouriteProductService     = new FavouriteProductsService(favouriteProductsRepository);

            var favouriteProductsSeeder = new FavouriteProductsSeeder();

            await favouriteProductsSeeder.SeedFavouriteProducts(context);

            var shouldBeTrue = await favouriteProductService.DeleteAsync("productId1", "userId1");

            Assert.True(shouldBeTrue);
        }
Ejemplo n.º 5
0
        public async Task AddAsync_ReturnsFalse_IfProductAlreadyExists()
        {
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var favouriteProductsRepository = new EfDeletableEntityRepository <UserFavouriteProduct>(context);
            var favouriteProductService     = new FavouriteProductsService(favouriteProductsRepository);

            var favouriteProductsSeeder = new FavouriteProductsSeeder();

            await favouriteProductsSeeder.SeedFavouriteProducts(context);

            var shouldBeFalse = await favouriteProductService.AddAsync("productId1", "userId1");

            Assert.False(shouldBeFalse);
        }