Exemplo n.º 1
0
        public async Task InvalidPayloadReturnsError()
        {
            var eh     = new TestHandler(GitHubClientMockFactory.CreateDefault().CreateFactory(), MemoryCacheMockFactory.Instance);
            var result = await eh.Execute("{a:1}");

            Assert.IsTrue(result.Result.Contains("payload error", System.StringComparison.InvariantCultureIgnoreCase));
        }
Exemplo n.º 2
0
        public async Task EnabledAndHandlerCalled()
        {
            var gitHubMock = GitHubClientMockFactory.CreateDefault();
            var eh         = new TestHandler(gitHubMock.CreateFactory(), MemoryCacheMockFactory.Instance);
            var result     = await eh.Execute(SampleData.BranchCreate.Body);

            Assert.IsTrue(result.Result.Contains("TestHandler ok", System.StringComparison.InvariantCultureIgnoreCase));
            gitHubMock.GitHubClientMock.Verify(c =>
                                               c.Repository.Content.GetAllContentsByRef(It.IsAny <long>(), ".github/ahk-monitor.yml", It.IsAny <string>()),
                                               Times.Once());
        }
Exemplo n.º 3
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());
        }
Exemplo n.º 4
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());
        }
Exemplo n.º 5
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());
        }