public async Task AGitHubSearchService_WillReturnAGitHubUser_WhenSearching()
        {
            Mock <IGitHubConnector> connector = new Mock <IGitHubConnector>();

            connector.Setup(c => c.FindUser(It.Is <string>(criteria => criteria == "test")))
            .Returns(Task.FromResult(new GitHubUser {
                Repositories = new List <GitHubRepository>()
            }));

            GitHubSearchService service = new GitHubSearchService(connector.Object);

            GitHubUser result = await service.FindUser("test");

            Assert.AreEqual(result.GetType(), typeof(GitHubUser));
        }
Example #2
0
        public async Task AGitHubConnector_WillReturnAGitHubUser_WhenSearching()
        {
            HttpResponseMessage expectedResponseFromGitHub = new HttpResponseMessage
            {
                Content = new StringContent(@"{login:'******'}")
            };

            HttpResponseMessage expectedRepositoriesResponse = new HttpResponseMessage
            {
                Content = new StringContent("[]")
            };

            Mock <IAppHttpClient> appHttpClient = new Mock <IAppHttpClient>();

            appHttpClient.SetupSequence(c => c.Get(It.IsAny <string>()))
            .ReturnsAsync(expectedResponseFromGitHub)
            .ReturnsAsync(expectedRepositoriesResponse);

            GitHubConnector connector = new GitHubConnector(appHttpClient.Object);
            GitHubUser      result    = await connector.FindUser("test");

            Assert.AreEqual(result.GetType(), typeof(GitHubUser));
        }