private (MockHttpMessageHandler, MockedRequest[]) TriggerNotificationHooksForCommit_Setup(string commitId) { var author = new Author("author name", "*****@*****.**"); var abcMImplementation = new Manifest.MImplementation { Type = "file", Format = "jpad" }; var abcManifest = new Manifest { KeyPath = "a/b/c", Implementation = abcMImplementation }; var abcKeyPathData = new KeyPathData("a/b/c", "{ \"implementationFor\": \"a/b/c\" }", abcManifest); var abcKeyPathDiff = new KeyPathDiff(null, abcKeyPathData); var abdMImplementation = new Manifest.MImplementation { Type = "const", Value = "abd const value" }; var abdManifest = new Manifest { KeyPath = "a/b/d", Implementation = abdMImplementation }; var abdKeyPathData = new KeyPathData("a/b/d", null, abdManifest); var abdMImplementationOld = new Manifest.MImplementation { Type = "const", Value = "old abd const value" }; var abdManifestOld = new Manifest { KeyPath = "a/b/d", Implementation = abdMImplementationOld }; var abdKeyPathDataOld = new KeyPathData("a/b/d", null, abdManifestOld); var abdKeyPathDiff = new KeyPathDiff(abdKeyPathDataOld, abdKeyPathData); var abcKeyPathArray = new KeyPathDiff[] { abcKeyPathDiff }; var abcabdKeyPathArray = new KeyPathDiff[] { abcKeyPathDiff, abdKeyPathDiff }; var mockHttp = new MockHttpMessageHandler(); var hookRequests = new MockedRequest[4]; hookRequests[0] = MockHookRequest(mockHttp, "http://some-domain/awesome_hook", abcabdKeyPathArray, author); hookRequests[1] = MockHookRequest(mockHttp, "http://some-domain/another_awesome_hook", abcKeyPathArray, author); hookRequests[2] = MockHookRequest(mockHttp, "http://another-domain/ok_hook", abcabdKeyPathArray, author); hookRequests[3] = MockHookRequest(mockHttp, "http://fifth-domain/should_not_be_called_hook", abcKeyPathArray, author); var client = mockHttp.ToHttpClient(); InitializeHelpers(client); TriggerNotificationHooksForCommit_SetupGitStubs(commitId, abcManifest, abdManifest, abdManifestOld); return(mockHttp, hookRequests); }
public async Task GetKeyPathData_ReturnsExistingFileData() { var mImplementation = new Manifest.MImplementation { Type = "const", Value = "const value" }; var manifest = new Manifest { KeyPath = "a/b/c", Implementation = mImplementation }; var keyPathData = new KeyPathData("a/b/c", null, manifest); var commitId = "abcd"; var keyPath = "a/b/c"; var gitCommand = $"show {commitId}:manifests/{keyPath}.json"; var gitOutput = JsonConvert.SerializeObject(manifest); A.CallTo(() => fakeGit(gitCommand)).Returns(gitOutput); var result = await CallPrivateMethod <Task <KeyPathData?> >(hooksHelper, "GetKeyPathData", new object[] { keyPath, commitId }); AssertObjectEquality(keyPathData, result); }