Esempio n. 1
0
        public void When_one_trigger_callback_is_registered_Then_the_callback_is_notified_the_request_succeeds()
        {
            ConfigurationManagerExtensions.AddFakeAppServiceRuntimeSettings();

            var packageUri = Any.Uri();

            var callbackPath = Any.UriPath();

            using (var mockService = new MockService()
                                     .OnRequest(r => r.Path.ToString() == "/" + callbackPath)
                                     .RespondWith(r => r.StatusCode = 200))
            {
                var callbackUri = mockService.GetBaseAddress() + callbackPath;

                using (var server = Microsoft.Owin.Testing.TestServer.Create <Startup>())
                {
                    server.HttpClient.PutAsync(String.Format("/api/Trigger?triggerId={0}", Any.Guid()),
                                               Any.Azure.AppServiceTrigger.MyGetConnectorTriggerBody(callbackUri).ToJsonStringContent())
                    .Wait();

                    server
                    .HttpClient
                    .AsMyGetTriggerSource()
                    .PostAsync("/api/MyGetWebhook/",
                               Any.MyGet.WebHooks.PackageAddedPayload(packageUri).ToJsonStringContent("application/vnd.myget.webhooks.v1+json"))
                    .Result
                    .ShouldSucceed();
                }
            }
        }
Esempio n. 2
0
        public void When_one_trigger_callback_is_registered_but_target_is_not_available_Then_the_request_succeeds()
        {
            var packageUri = Any.Uri();

            ConfigurationManagerExtensions.AddFakeAppServiceRuntimeSettings();

            using (var server = Microsoft.Owin.Testing.TestServer.Create <Startup>())
            {
                server.HttpClient.PutAsync(String.Format("/api/Trigger?triggerId={0}", Any.Guid()),
                                           Any.Azure.AppServiceTrigger.MyGetConnectorTriggerBody(Any.Uri().ToString()).ToJsonStringContent())
                .Wait();

                server.HttpClient
                .AsMyGetTriggerSource()
                .PostAsync("/api/MyGetWebhook/",
                           Any.MyGet.WebHooks.PackageAddedPayload(packageUri).ToJsonStringContent("application/vnd.myget.webhooks.v1+json"))
                .Result
                .ShouldSucceed();
            }
        }