public void TestUpdateProductOptionOK() { using (var context = new ProductDbContext(builder.Options)) { SetUpTestData(context); IProductOptionRepository productOptionRepository = new ProductOptionRepository(context); productOptions[0].Name = "Test Update Product Option"; productOptions[0].Description = "Test Update product option"; productOptionRepository.AddOrUpdateAsync(productOptions[0], false); var currentProductOptions = productOptionRepository.GetProductOptions(); currentProductOptions.Result.Count.Should().Be(1); currentProductOptions.Result[0].Name.Should().Equals("Test Update Product Option"); currentProductOptions.Result[0].Description.Should().Equals("Test Update product option"); context.Database.EnsureDeleted(); } }
public void TestAddProductOptionOK() { using (var context = new ProductDbContext(builder.Options)) { SetUpTestData(context); IProductOptionRepository productOptionRepository = new ProductOptionRepository(context); ProductOption p = new ProductOption { Id = new Guid(), ProductId = products[0].Id, Name = "Test add Product Option 2", Description = "Test add product option" }; productOptionRepository.AddOrUpdateAsync(p, true); var currentProductOptions = productOptionRepository.GetProductOptions(); currentProductOptions.Result.Count.Should().Be(2); p.ProductId.Should().Equals(currentProductOptions.Result[1].ProductId); p.Name.Should().Equals(currentProductOptions.Result[1].Name); context.Database.EnsureDeleted(); } }