public async Task GetRepositories_NoPullDogSettingsFound_ReturnsNotFound() { //Arrange var fakeMediator = Substitute.For <IMediator>(); fakeMediator .Send(Arg.Any <EnsureUserForIdentityCommand>()) .Returns(new User()); var fakeMapper = Substitute.For <IMapper>(); var fakeAesEncryptionHelper = Substitute.For <IAesEncryptionHelper>(); var controller = new PullDogApiController( fakeMediator, fakeMapper, fakeAesEncryptionHelper); controller.FakeAuthentication("some-identity-name"); //Act var result = await controller.GetRepositories() as NotFoundObjectResult; //Assert Assert.IsNotNull(result); }
public async Task GetRepositories_PullDogSettingsFound_ReturnsMappedRepositories() { //Arrange var fakeMediator = Substitute.For <IMediator>(); fakeMediator .Send(Arg.Any <EnsureUserForIdentityCommand>()) .Returns(new User() { PullDogSettings = new PullDogSettings() }); fakeMediator .Send(Arg.Any <GetRepositoriesForUserQuery>()) .Returns(new [] { new UserRepositoryResponse() }); var fakeMapper = Substitute.For <IMapper>(); var fakeAesEncryptionHelper = Substitute.For <IAesEncryptionHelper>(); var controller = new PullDogApiController( fakeMediator, fakeMapper, fakeAesEncryptionHelper); controller.FakeAuthentication("some-identity-name"); //Act var result = await controller.GetRepositories() as OkObjectResult; //Assert Assert.IsNotNull(result); var response = result.ToObject <RepositoriesResponse>(); Assert.AreEqual(1, response.Repositories.Length); }