public void FindProductById_Action_Fails() { // Arrange GenericServiceResponse <ProductDto> fakeResponse = null; mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable(); mockClientServicesProvider.Setup(x => x.ProductService.FindProductById(It.IsAny <int>())).Returns(fakeResponse).Verifiable(); var viewModel = new GenericItemViewModel <ProductDto>(); var action = new FindProductById <GenericItemViewModel <ProductDto> >(mockClientServicesProvider.Object) { OnComplete = model => viewModel = model }; // Act var result = action.Invoke(1); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(GenericItemViewModel <ProductDto>)); Assert.IsNotNull(result.Notifications); Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection)); Assert.IsTrue(result.Notifications.Count() == 1); Assert.IsTrue(result.HasErrors); Assert.IsNull(result.Item); }
public static void Setup(TestContext ctx) { RefreshDatabase(); _addProduct = new AddProduct("Name", "Description", new decimal(1.99)); var sut = new ProductService(new EntityFrameworkRepository(DbContext), new EntityFrameworkProductLocator(DbContext)); sut.Execute(_addProduct); var productId = DbContext.Products.Single().Id; var findProductById = new FindProductById(productId); _product = sut.Execute(findProductById); }
private ProductDto FindProductById(Guid id) { var command = new FindProductById(id); return(_productService.Execute(command)); }