public void GetAllProducts_Action_Fails() { // Arrange GenericServiceResponse <IEnumerable <ProductDto> > fakeResponse = null; mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable(); mockClientServicesProvider.Setup(x => x.ProductService.GetAllProducts()).Returns(fakeResponse).Verifiable(); var viewModel = new GenericListViewModel <ProductDto>(); var action = new GetAllProducts <GenericListViewModel <ProductDto> >(mockClientServicesProvider.Object) { OnComplete = model => viewModel = model }; // Act var result = action.Invoke(); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(GenericListViewModel <ProductDto>)); Assert.IsNotNull(result.Notifications); Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection)); Assert.IsTrue(result.Notifications.Count() == 1); Assert.IsTrue(result.HasErrors); Assert.IsNotNull(result.Items); Assert.IsTrue(result.Items.Count() == 0); Assert.IsInstanceOfType(result.Items, typeof(IEnumerable <ProductDto>)); Assert.IsTrue(result.Items.ToList().Count() == 0); }
protected virtual void OnGetAllProducts(GetAllProductsEventArgs args) { EventHandler <GetAllProductsEventArgs> temp = GetAllProducts; if (temp != null) { GetAllProducts?.Invoke(this, args); } }