public void GetAllCurrencies_Action_Fails() { // Arrange GenericServiceResponse <IEnumerable <CurrencyDto> > fakeResponse = null; mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable(); mockClientServicesProvider.Setup(x => x.CurrencyService.GetAllCurrencies()).Returns(fakeResponse).Verifiable(); var viewModel = new GenericListViewModel <CurrencyDto>(); var action = new GetAllCurrencies <GenericListViewModel <CurrencyDto> >(mockClientServicesProvider.Object) { OnComplete = model => viewModel = model }; // Act var result = action.Invoke(); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(GenericListViewModel <CurrencyDto>)); 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 <CurrencyDto>)); Assert.IsTrue(result.Items.ToList().Count() == 0); }
public void GetAllEmployees_Action_Success() { // Arrange var fakeResponse = new GenericServiceResponse <IEnumerable <EmployeeDto> > { Result = TestHelper.EmployeeDtos() }; mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable(); mockClientServicesProvider.Setup(x => x.EmployeeService.GetAllEmployees()).Returns(fakeResponse).Verifiable(); var viewModel = new GenericListViewModel <EmployeeDto>(); var action = new GetAllEmployees <GenericListViewModel <EmployeeDto> >(mockClientServicesProvider.Object) { OnComplete = model => viewModel = model }; // Act var result = action.Invoke(); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(GenericListViewModel <EmployeeDto>)); Assert.IsNotNull(result.Notifications); Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection)); Assert.IsTrue(result.Notifications.Count() == 0); Assert.IsFalse(result.HasErrors); Assert.IsNotNull(result.Items); Assert.IsInstanceOfType(result.Items, typeof(IEnumerable <EmployeeDto>)); Assert.IsTrue(result.Items.ToList().Count() == TestHelper.EmployeeDtos().Count()); }
public T Invoke() { return(Execute(() => { var model = new GenericListViewModel <TaskDto>(); var serviceResult = ServiceProvider.TaskService.GetAllTasks(); if (serviceResult == null || serviceResult.Result == null || serviceResult.Notifications.HasErrors()) { var errorMessage = "Sorry, an unexpected error occurred."; model.Notifications.AddError(errorMessage); } else { model.Items = serviceResult.Result; } return OnComplete(model); }, this.GetType().Name)); }
protected GetListAction(IServiceProviderBusiness clientServices) : base(clientServices) { ViewModel = new GenericListViewModel <K>(); }
protected GetListAction(IServiceProviderCore serviceProvider) : base(serviceProvider) { ViewModel = new GenericListViewModel <K>(); }
public PaymentViewModel() { GenericList = new GenericListViewModel(); }