public void XmlFileExists_Add_FindByInvalidId_Remove() { var newId = new GuidWrapper().NewGuid(); var product = new Product { ProductId = newId, Description = "New Product", GivenDays = 10, NecessaryAmount = 1 }; _productRepository.Save(product); var addedProduct = _productRepository.FindById("1"); Assert.That(addedProduct, Is.Null); _productRepository.Remove(product); var removedProduct = _productRepository.FindById(newId); Assert.That(removedProduct, Is.Null); }
public void XmlFileExists_Add_FindByValidId_Edit_Remove() { var newId = new GuidWrapper().NewGuid(); var product = new Product { ProductId = newId, Description = "New Product", GivenDays = 10, NecessaryAmount = 1 }; _productRepository.Save(product); var addedProduct = _productRepository.FindById(newId); Assert.That(addedProduct, Is.Not.Null); Assert.That(addedProduct.ProductId, Is.EqualTo(newId)); Assert.That(addedProduct.Description, Is.EqualTo("New Product")); Assert.That(addedProduct.GivenDays, Is.EqualTo(10)); Assert.That(addedProduct.NecessaryAmount, Is.EqualTo(1)); addedProduct.Description = "Edited Product"; addedProduct.GivenDays = 20; addedProduct.NecessaryAmount = 2; _productRepository.Save(addedProduct); var editedProduct = _productRepository.FindById(newId); Assert.That(editedProduct, Is.Not.Null); Assert.That(editedProduct.ProductId, Is.EqualTo(newId)); Assert.That(editedProduct.Description, Is.EqualTo("Edited Product")); Assert.That(editedProduct.GivenDays, Is.EqualTo(20)); Assert.That(editedProduct.NecessaryAmount, Is.EqualTo(2)); _productRepository.Remove(editedProduct); var removedProduct = _productRepository.FindById(newId); Assert.That(removedProduct, Is.Null); }
public ProductHandler(IProductRepository productRepository, GuidWrapper guidWrapper) { _productRepository = productRepository; _guidWrapper = guidWrapper; }