public async Task Throw_NotFoundException_For_Get_User_Profiles_And_When_User_NotFound() { //Arrange Mock <IUserManagerService> userManagerService = new Mock <IUserManagerService>(); userManagerService.Setup(s => s.GetUsers( It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <int>(), It.IsAny <int>() )).Throws <NotFoundException>(); var sut = new FilterUserQueryHandler(userManagerService.Object, _mapper); //Act/Assert await Assert.ThrowsAsync <NotFoundException>(async() => { var res = (await sut.Handle(new FilterUserQuery(), default)); }); }
public async Task Should_Get_User_Profiles_With_Specific_Input_Filter_And_When_Users_Found() { //Arrange List <ApplicationUser> users = new List <ApplicationUser>() { new ApplicationUser { Email = String.Empty, UserName = String.Empty, FirstName = "Test", LastName = "Test", Id = 1, PasswordHash = String.Empty } }; Mock <IUserManagerService> userManagerService = new Mock <IUserManagerService>(); userManagerService.Setup(s => s.GetUsers( It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <int>(), It.IsAny <int>() )).ReturnsAsync(users); var sut = new FilterUserQueryHandler(userManagerService.Object, _mapper); //Act var result = (await sut.Handle(new FilterUserQuery(), default)).ToList(); //Assert result.ShouldNotBeNull(); result.ShouldBeAssignableTo <IEnumerable <UserDetailInfoDto> >(); result.Count.ShouldBe(1); }