Created
August 16, 2020 04:52
-
-
Save Kevin-Bronsdijk/d9c189e5a9521e26fd42bba61c70af0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void Example2_GetProducts_WhenPassingAValidCategory_ThenShouldReturnProducts() | |
{ | |
// setup repository mock | |
var products = new List<Product> | |
{ | |
new Product { Id = 1, Name = "Product 1" }, | |
new Product { Id = 2, Name = "Product 2" } | |
}; | |
IProductCatalogRepository repository = Substitute.For<IProductCatalogRepository>(); | |
repository.GetProducts(Arg.Is("ElectronicDevices")).Returns(products); | |
// create object under test | |
var testSubject = new ProductCatalogService(repository); | |
// assert | |
var result = testSubject.GetProducts(Category.ElectronicDevices); | |
Assert.IsNotNull(result); | |
Assert.IsTrue(result.ToList().Count != 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment