public void TestShouldDeleteProduct() { // Arrange var sut = CreateInMemoryRepository(SampleProducts.CreateProducts()); // Act sut.RemoveProduct(1); // Assert Assert.AreEqual(2, sut.GetProducts().Count()); }
public void TestShouldGetProducts() { // Arrange var sut = CreateInMemoryRepository(SampleProducts.CreateProducts()); // Act var result = sut.GetProducts(n => n.Id == 2).ToList(); // Assert Assert.AreEqual(1, result.Count); Assert.AreEqual("SecondProduct", result.Single().Name); }
public void TestShouldUpdateProduct() { // Arrange var sut = CreateInMemoryRepository(SampleProducts.CreateProducts()); // Act sut.UpdateProduct(SampleProducts.CreateProduct(2, "Updated name", "Updated description.")); // Assert Assert.AreEqual("Updated name", sut.GetProducts(e => e.Id == 2).Single().Name); Assert.AreEqual("Updated description.", sut.GetProducts(e => e.Id == 2).Single().Description); }
public void TestShouldInsertProductWhenThereAreSomeAlready() { // Arrange var sut = CreateInMemoryRepository(SampleProducts.CreateProducts()); // Act var result = sut.AddProduct(SampleProducts.CreateProduct()); // Assert Assert.AreEqual(4, result.Id); Assert.AreEqual("FirstProduct", result.Name); }
public void TestShouldSearchProductFromName() { // Arrange var allProducts = SampleProducts.CreateProducts(); // Act var result = Entity.Search <Product>("Second"); // Assert var products = allProducts.Where(result.Compile()); Assert.AreEqual(2, products.Single().Id); }
public void TestShouldGetAllProducts() { // Arrange _queries.GetProducts() .Returns(SampleProducts.CreateProducts()); var sut = CreateProductInteractor(); // Act var result = sut.GetProducts(); // Assert Assert.AreEqual(3, result.Count); }
public void TestShouldGetProductFromName() { // Arrange var products = SampleProducts.CreateProducts(); // Act var result = Entity.Get <Product>("SecondProduct"); // Assert var product = products.SingleOrDefault(result.Compile()); Assert.IsNotNull(product); Assert.AreEqual(2, product.Id); }