public void TestGetProductOptionByIdNotFound() { using (var context = new ProductDbContext(builder.Options)) { SetUpTestData(context); IProductOptionRepository productOptionRepository = new ProductOptionRepository(context); ProductOption po = productOptionRepository.GetById(new Guid()); po.Should().BeNull(); context.Database.EnsureDeleted(); } }
public void GetById_gets_a_ProductOption_via_context() { //Arrange var repository = new ProductOptionRepository(_mapper, _mockContext,_logging); //Act var productOption = repository.GetById(new Guid("0643ccf0-ab00-4862-b3c5-40e2731abcc9")); //Assert Assert.IsNotNull(productOption); Assert.AreEqual(productOption.Name, "White"); }
public void Update_update_specified_ProductOption_via_context() { //Arrange var repository = new ProductOptionRepository(_mapper, _mockContext,_logging); var productOptionToUpdate = new core.Models.ProductOption { Id = new Guid("5c2996ab-54ad-4999-92d2-89245682d534"), ProductId = new Guid("de1287c0-4b15-4a7b-9d8a-dd21b3cafec3"), Name = "Rose Gold Test Mock", Description = "Gold Apple iPhone 6S" }; //Act repository.Update(productOptionToUpdate); var updatedProductOption = repository.GetById(new Guid("5c2996ab-54ad-4999-92d2-89245682d534")); //Assert Assert.IsNotNull(updatedProductOption); Assert.AreEqual(updatedProductOption.Name, "Rose Gold Test Mock"); Assert.AreEqual(updatedProductOption.Name, productOptionToUpdate.Name); }
public void TestGetProductOptionByIdOK() { using (var context = new ProductDbContext(builder.Options)) { SetUpTestData(context); IProductOptionRepository productOptionRepository = new ProductOptionRepository(context); ProductOption po = productOptionRepository.GetById(productOptions[0].Id); po.Should().NotBeNull(); po.Id.Should().Equals(productOptions[0].Id); po.Name.Should().Equals(productOptions[0].Name); po.Description.Should().Equals(productOptions[0].Description); po.ProductId.Should().Equals(productOptions[0].ProductId); context.Database.EnsureDeleted(); } }