public void GetProductDetails_WithNonExistentId_ShouldReturnNull() { var mapper = AutoMapperConfig.Initialize(); string errorMessage = "ProductService GetProductDetails() method does not work properly."; var context = WatchShopDbContextInMemoryFactory.InitializeContext(); SeedData(context); this.productService = new ProductService(context, mapper); ProductServiceDetailsViewModel actualEntry = this.productService.GetProductDetails("ne i id"); Assert.True(actualEntry == null, errorMessage); }
public void GetProductDetails_WithExistentId_ShouldReturnCorrentResult() { var mapper = AutoMapperConfig.Initialize(); string errorMessage = "ProductService GetProductDetails() method does not work properly."; var context = WatchShopDbContextInMemoryFactory.InitializeContext(); SeedData(context); this.productService = new ProductService(context, mapper); ProductServiceDetailsViewModel expectedEntry = mapper.Map <ProductServiceDetailsViewModel>(context.Products.First()); ProductServiceDetailsViewModel actualEntry = this.productService.GetProductDetails(expectedEntry.Id); Assert.True(expectedEntry.Id == actualEntry.Id, errorMessage + " " + "Id is not returned properly"); Assert.True(expectedEntry.Description == actualEntry.Description, errorMessage + " " + "Description is not returned properly"); Assert.True(expectedEntry.Category.Name == actualEntry.Category.Name, errorMessage + " " + "Category is not returned properly"); Assert.True(expectedEntry.Model == actualEntry.Model, errorMessage + " " + "Model is not returned properly"); Assert.True(expectedEntry.Image == actualEntry.Image, errorMessage + " " + "Image is not returned properly"); Assert.True(expectedEntry.Price == actualEntry.Price, errorMessage + " " + "Price is not returned properly"); }