Ejemplo n.º 1
0
        public async Task NoAhkMonitorConfigYaml1()
        {
            var gitHubMock = GitHubClientMockFactory.CreateCustom()
                             .WithAhkMonitorConfigYamlContent(c => c.ThrowsAsync(new Octokit.NotFoundException(string.Empty, System.Net.HttpStatusCode.NotFound)));

            var eh     = new TestHandler(gitHubMock.CreateFactory(), MemoryCacheMockFactory.Instance);
            var result = await eh.Execute(SampleData.BranchCreate.Body);

            Assert.IsTrue(result.Result.Contains("no ahk-monitor.yml or disabled", System.StringComparison.InvariantCultureIgnoreCase));
            gitHubMock.GitHubClientMock.Verify(c =>
                                               c.Repository.Content.GetAllContentsByRef(It.IsAny <long>(), ".github/ahk-monitor.yml", It.IsAny <string>()),
                                               Times.Once());
        }
Ejemplo n.º 2
0
        public async Task AhkMonitorConfigYamlInvalid()
        {
            var gitHubMock = GitHubClientMockFactory.CreateCustom()
                             .WithAhkMonitorConfigYamlContent(c => c.ReturnsAsync(new[] { GitHubMockData.CreateAhkMonitorYamlFileContent("not valid content") }));

            var eh     = new TestHandler(gitHubMock.CreateFactory(), MemoryCacheMockFactory.Instance);
            var result = await eh.Execute(SampleData.BranchCreate.Body);

            Assert.IsTrue(result.Result.Contains("no ahk-monitor.yml or disabled", System.StringComparison.InvariantCultureIgnoreCase));
            gitHubMock.GitHubClientMock.Verify(c =>
                                               c.Repository.Content.GetAllContentsByRef(It.IsAny <long>(), ".github/ahk-monitor.yml", It.IsAny <string>()),
                                               Times.Once());
        }
Ejemplo n.º 3
0
        public async Task NeptunFileNotFound()
        {
            var gitHubMock = GitHubClientMockFactory.CreateCustom()
                             .WithNeptunTxtContent(c => c.ThrowsAsync(new Octokit.NotFoundException(string.Empty, System.Net.HttpStatusCode.NotFound)));

            var eh = new TestHandler(gitHubMock.CreateFactory(), MemoryCacheMockFactory.Instance);
            await eh.Execute(SampleData.BranchCreate.Body);

            var result = await eh.GetNeptunForTest();

            Assert.IsNull(result);
            gitHubMock.GitHubClientMock.Verify(c =>
                                               c.Repository.Content.GetAllContentsByRef(It.IsAny <long>(), "neptun.txt", It.IsAny <string>()),
                                               Times.Once());
        }
Ejemplo n.º 4
0
        public async Task NeptunFileReadCorrectly(string textFileValue, string expected)
        {
            var gitHubMock = GitHubClientMockFactory.CreateCustom()
                             .WithNeptunTxtContent(textFileValue);

            var eh = new TestHandler(gitHubMock.CreateFactory(), MemoryCacheMockFactory.Instance);
            await eh.Execute(SampleData.BranchCreate.Body);

            var result = await eh.GetNeptunForTest();

            Assert.AreEqual(expected, result);
            gitHubMock.GitHubClientMock.Verify(c =>
                                               c.Repository.Content.GetAllContentsByRef(It.IsAny <long>(), "neptun.txt", It.IsAny <string>()),
                                               Times.Once());
        }