예제 #1
0
        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);
        }
예제 #2
0
        private async Task <Dictionary <string, KeyPathDiff> > GetKeyPathsDiffs(IEnumerable <string> keyPaths, string commitId)
        {
            var keyPathsDataDict = new Dictionary <string, KeyPathDiff>(keyPaths.Count());

            foreach (var keyPath in keyPaths)
            {
                var newValue = await GetKeyPathData(keyPath, commitId);

                var oldValue = await GetOldKeyPathData(keyPath, commitId);

                var keyPathDiff = new KeyPathDiff(oldValue, newValue);

                keyPathsDataDict.Add(keyPath, keyPathDiff);
            }

            return(keyPathsDataDict);
        }