public async Task HydrateGhUserReposDisplayVm_IfNoReposAfterFilter_ShouldGetSimplyInitdRetClass() { // Arrange mockGHReposSvc.Setup(o => o.GetGitHubReposAsync( It.IsAny <HttpClient>(), It.IsAny <string>())).ReturnsAsync(() => new List <GhUserRepo> { new GhUserRepo { name = "test1", @private = true }, new GhUserRepo { name = "test2", @private = true } }); apiCallServices = new GitHubApiCallServices( mockHttpClientProvider.Object, mockHCAuthConfigr.Object, mockGHReposSvc.Object, mockGHPRsSvc.Object, mockCredentialsReader.Object); var ghUserReposSvcs = new GhUserReposServices(apiCallServices); // Act GhUserReposDisplayVm callResult = await ghUserReposSvcs.HydrateGhUserReposDisplayVmAsync("username"); Assert.IsInstanceOfType(callResult, typeof(GhUserReposDisplayVm)); Assert.AreEqual("username", callResult.GitHubUsername); Assert.IsNotNull(callResult.Repositories); Assert.IsInstanceOfType(callResult.Repositories, typeof(List <RepoListItem>)); Assert.AreEqual(0, callResult.Repositories.Count); }
public void GhUserReposServices_InstantiationWithNullParam_ShouldThrow() { // act var ghUserReposServices = new GhUserReposServices(null); // assert // should have thrown }
public void GhUserReposServices_InstantiationWithProperParam_ShouldPass() { // arrange var ghApiCallServices = new Mock <IGitHubApiCallServices>(); // act var ghUserReposServices = new GhUserReposServices(ghApiCallServices.Object); // assert Assert.IsNotNull(ghUserReposServices); Assert.IsInstanceOfType(ghUserReposServices, typeof(GhUserReposServices)); }
public async Task HydrateGhUserReposDisplayVm_InclPrivateRepos_ShouldPass() { // Arrange var ghUserReposSvcs = new GhUserReposServices(apiCallServices); // Act GhUserReposDisplayVm callResult = await ghUserReposSvcs.HydrateGhUserReposDisplayVmAsync("username", true); // if 'returnPrivateRepos' is true, I should get 3 back Assert.AreEqual(3, callResult.Repositories.Count); }
public async Task HydrateGhUserReposDisplayVm_CallWithEmptyOrWhiteSpGhUsernameParam_ShouldThrow() { // Arrange var mockedApiCallServices = new Mock <IGitHubApiCallServices>(); // Act var classInstance = new GhUserReposServices(mockedApiCallServices.Object); var callResult = await classInstance.HydrateGhUserReposDisplayVmAsync(" "); // Assert // should have thrown }
public async Task HydrateGhUserReposDisplayVm_MockRepoCallReturnsOne_ShouldGetHydratedViewModel() { // Arrange var ghUserReposSvcs = new GhUserReposServices(apiCallServices); // Act GhUserReposDisplayVm callResult = await ghUserReposSvcs.HydrateGhUserReposDisplayVmAsync("cmdrbeavis"); // Assert Assert.IsInstanceOfType(callResult, typeof(GhUserReposDisplayVm)); Assert.AreEqual("cmdrbeavis", callResult.GitHubUsername); Assert.IsNotNull(callResult.Repositories); Assert.IsInstanceOfType(callResult.Repositories, typeof(List <RepoListItem>)); Assert.AreEqual(2, callResult.Repositories.Count); Assert.IsTrue(callResult.Repositories[0].name.Contains("test1")); Assert.IsTrue(callResult.Repositories[1].name.Contains("test3")); }