public async Task Should_return_ok_if_several_participant_with_the_same_username_return_from_database() { var participants = new List <Participant> { new Participant { Id = Guid.NewGuid(), Username = "******" }, new Participant { Id = Guid.NewGuid(), Username = "******" }, }; _participantService .Setup(x => x.GetParticipantsByUsernameAsync(It.IsAny <string>())) .ReturnsAsync(participants); var result = await _controller.GetCurrentParticipant(); Assert.NotNull(result); Assert.IsAssignableFrom <OkObjectResult>(result); var okResult = (OkObjectResult)result; Assert.IsAssignableFrom <ParticipantResponse>(okResult.Value); var response = (ParticipantResponse)okResult.Value; Assert.AreEqual("SomeUsername", response.Username); Assert.AreEqual(participants[0].Id, response.Id); }
public async Task should_return_not_found_if_participant_is_found() { const string username = "******"; _participantService .Setup(x => x.GetParticipantsByUsernameAsync(username)) .ReturnsAsync(Enumerable.Empty <Participant>()); var result = await _controller.GetCurrentParticipant(); Assert.NotNull(result); Assert.IsAssignableFrom <NotFoundResult>(result); }