public async Task CreateAsync_Should_UnPublishedProduct() { ProductDto result = null; //Given var input = new CreateUpdateProductDto { Title = "New Product", Description = "New Product Description", Cover = new SaveFileDto() { FileName = "demo.jpg", Content = new byte[] { 1, 2, 34, 4, 5 } }, GigId = Guid.Parse(Zero1FiveTestData.GigId), IsPublished = false }; await WithUnitOfWorkAsync(async() => { var categories = await _categoryRepository.GetListAsync(); input.CategoryId = categories.First().Id; //When result = await _productAppService.CreateAsync(input); }); //Then result.Id.ShouldNotBe(Guid.Empty); result.CategoryId.ShouldNotBe(Guid.Empty); result.Title.ShouldBe(input.Title); result.Description.ShouldBe(input.Description); result.CoverImage.ShouldContain(input.Cover.FileName); result.IsPublished.ShouldBe(false); }
public async Task UpdateAsync_Should_UpdateProduct() { var productId = (await _productRepository.GetListAsync()).First().Id; var product = await _productRepository.FindAsync(productId); var input = new CreateUpdateProductDto() { Id = productId, CategoryId = product.CategoryId, GigId = product.GigId, Title = "newTitle", Cover = new SaveFileDto() { FileName = "demo.jpg", Content = new byte[] { 1, 2, 34, 4, 5 } }, Description = "new product Description ", IsPublished = true }; var result = await _productAppService.UpdateAsync(productId, input); result.Id.ShouldBe(productId); result.Title.ShouldBe(input.Title); result.CoverImage.ShouldContain(input.Cover.FileName); result.Description.ShouldBe(input.Description); result.CategoryId.ShouldBe(input.CategoryId); result.GigId.ShouldBe(input.GigId); }