public async void GetName_OnEmptyQuery_BadRequest() { //Arrange var persistenceMock = new Mock <IFriendsPersistence>(); var mapperMock = new Mock <IMapper>(); //Act var controller = new FriendsController(_logger, persistenceMock.Object, mapperMock.Object); var response = await controller.GetName(null); //Assert Assert.IsType <BadRequestResult>(response); }
public async void GetName_OnValidQuery_OkRequestWithName() { //Arrange var query = "0123456789"; var dto = new ApplicationUser { UserName = query, Nickname = "I'm Mock!" }; var persistenceMock = new Mock <IFriendsPersistence>(); persistenceMock .Setup(p => p.Friends.FindByNameAsync(It.IsAny <string>())) .ReturnsAsync(dto); var mapperMock = new Mock <IMapper>(); //Act var controller = new FriendsController(_logger, persistenceMock.Object, mapperMock.Object); var response = await controller.GetName(query); //Assert Assert.IsType <OkObjectResult>(response); }