public void GetAllOrganizations_Action_Fails() { // Arrange GenericServiceResponse <IEnumerable <OrganizationDto> > fakeResponse = null; mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable(); mockClientServicesProvider.Setup(x => x.OrganizationService.GetAllOrganizations()).Returns(fakeResponse).Verifiable(); var viewModel = new GenericListViewModel <OrganizationDto>(); var action = new GetAllOrganizations <GenericListViewModel <OrganizationDto> >(mockClientServicesProvider.Object) { OnComplete = model => viewModel = model }; // Act var result = action.Invoke(); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(GenericListViewModel <OrganizationDto>)); 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 <OrganizationDto>)); Assert.IsTrue(result.Items.ToList().Count() == 0); }
public async Task <IEnumerable <OrganizationViewModel> > Handle(GetAllOrganizations input) { var organizations = await _repository.GetAllAsync <Organization>(); return(_mapper.Map <IEnumerable <OrganizationViewModel> >(organizations)); }