public async void Should_Be_Update_Product_Returns_Object() { using var siteAuthDbContextFactory = new SiteAuthDbContextFactory(); using (var context = new SiteAuthDbContext(siteAuthDbContextFactory.Options)) { siteAuthDbContextFactory.SeedContextForSqlite(context); } using (var context = new SiteAuthDbContext(siteAuthDbContextFactory.Options)) { // Arrange var productModel = new ProductModel() { IsDeleted = false, Description = "Product 121212", ImageUrl = "http://localhost:3333/images/product121212.png", Price = 1200 }; int productId = 1; var logger = new Mock <ILogger <ProductsCommands> >(); var productsCommands = new ProductsCommands(context, logger.Object, Mapper); // Act var result = await productsCommands.UpdateAsync(productId, productModel); // Assert Assert.NotNull(result); Assert.True(result.Description == productModel.Description); } }
public async void Should_Be_Delete_Product_Returns_Success() { using var siteAuthDbContextFactory = new SiteAuthDbContextFactory(); using (var context = new SiteAuthDbContext(siteAuthDbContextFactory.Options)) { siteAuthDbContextFactory.SeedContextForSqlite(context); } using (var context = new SiteAuthDbContext(siteAuthDbContextFactory.Options)) { // Arrange int productId = 1; var logger = new Mock <ILogger <ProductsCommands> >(); var productsCommands = new ProductsCommands(context, logger.Object, Mapper); // Act var result = await productsCommands.DeleteAsync(productId); // Assert Assert.True(result); var current = Mapper.Map <ProductModel>(context.Products.FirstOrDefault(x => x.Id == productId)); Assert.Null(current); } }
public async void Should_Be_Get_One_Product_Returns_Product() { using var siteAuthDbContextFactory = new SiteAuthDbContextFactory(); using (var context = new SiteAuthDbContext(siteAuthDbContextFactory.Options)) { siteAuthDbContextFactory.SeedContextForSqlite(context); } using (var context = new SiteAuthDbContext(siteAuthDbContextFactory.Options)) { // Arrange int productId = 1; var logger = new Mock <ILogger <ProductsQueries> >(); var productsQueries = new ProductsQueries(context, logger.Object, Mapper); // Act var result = await productsQueries.GetOneAsync(productId); // Assert Assert.NotNull(result); Assert.True(result.Id == productId); } }