コード例 #1
0
        public async Task DeleteBrandShouldDeleteExistingBrand()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            await context.Brands.AddAsync(new Brand { Id = 10 });

            var service = new BrandsService(context);

            var success = await service.DeleteBrandAsync(10);

            Assert.True(success);
        }
コード例 #2
0
        public async Task DeleteBrandShouldReturnFalseBrandDoesNotExist()
        {
            var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using var context = new WHMSDbContext(options);
            await context.Brands.AddAsync(new Brand { Name = "Test" });

            await context.SaveChangesAsync();

            var service = new BrandsService(context);

            var success = await service.DeleteBrandAsync(20);

            Assert.False(success);
        }