public void ExpectSuccess()
        {
            /* 𝓐𝓻𝓻𝓪𝓷𝓰𝓮... */
            SharedPactScafolding.BuildSuccessConsumerForId(ConsumeTestYamlPact, "00000001");

            var processorOptions = new ProcessSequenceItem.Options
            {
                state = new RunState {
                    YamlOptions = new YamlScript {
                        sequence_items = new[] { testSequenceItem }.ToList()
                    }
                },
                parent       = null,
                model        = new { Id = "00000001" },
                sequenceItem = testSequenceItem,
                breadcrumbs  = new Stack <KeyValuePair <string, ISequenceItemAction> >()
            };

            /* 𝓐𝓬𝓽 */
            var actualRetryAfterResult = new Stack <ISequenceItemAction>();

            var processor    = new ProcessSequenceItem(processorOptions);
            var actualResult = processor.SequenceItemDispatcherAsync(actualRetryAfterResult).Result;

            /* 𝓐𝓼𝓼𝓮𝓻𝓽 */
            ConsumeTestYamlPact.MockProviderService.VerifyInteractions();

            Assert.True(actualResult.IsSuccess);

            Assert.Empty(actualRetryAfterResult);
        }
Ejemplo n.º 2
0
        public void FansOutThree_ExpectedSuccess()
        {
            /* 𝓐𝓻𝓻𝓪𝓷𝓰𝓮 */

            ConsumeTestYamlPact.MockProviderService
            .Given("There is an active endpoint that provides a list of ids")
            .UponReceiving("A GET request to retrieve the list")
            .With(new ProviderServiceRequest
            {
                Method  = HttpVerb.Get,
                Path    = "/first",
                Headers = new Dictionary <string, object> {
                    { "Accept", "application/json" }
                },
            })
            .WillRespondWith(new ProviderServiceResponse
            {
                Status  = 200,
                Headers = new Dictionary <string, object> {
                    { "Content-Type", "application/json; charset=utf-8" }
                },
                Body = new List <object> {
                    new { Id = "00000001" },
                    new { Id = "00000002" },
                    new { Id = "00000003" },
                }
            });

            SharedPactScafolding.BuildSuccessConsumerForId(ConsumeTestYamlPact, "00000001");
            SharedPactScafolding.BuildSuccessConsumerForId(ConsumeTestYamlPact, "00000002");
            SharedPactScafolding.BuildSuccessConsumerForId(ConsumeTestYamlPact, "00000003");

            var testOptions = new Options {
                YamlDirect = MakeYamlSequence(Port, "expect-success")
            };


            /* 𝓐𝓬𝓽 */

            var provider = new HttpSequencer.HttpSequencer();
            var result   = provider.RunSequenceAsync(testOptions).Result;


            /* 𝓐𝓼𝓼𝓮𝓻𝓽 */

            Assert.Equal(0, result);

            ConsumeTestYamlPact.MockProviderService.VerifyInteractions();
        }
Ejemplo n.º 3
0
        public void RetryOnce_EndingWith_Success()
        {
            /* 𝓐𝓻𝓻𝓪𝓷𝓰𝓮... */

            /* ...the Pact server */
            SharedPactScafolding.BuildSuccessConsumerForId(ConsumeTestYamlPact, "00000001");

            /* ...the gubbins for the HttpSequencer component to work*/

            var testModel        = new { Id = "00000001" };
            var testSequenceItem = new SequenceItem
            {
                command            = "something-that-previously-failed",
                max_delayed_retrys = 1,
                send = new UrlRequest
                {
                    header = new KeyValueList {
                        new KeyValuePair <string, string>("Accept", "application/json")
                    },
                    http_method = "GET",
                    url         = $"http://localhost:{Port}/second/" + "{{model.Id}}"
                }
            };

            var dummyRunAfterList = new SequenceItem[] { };
            var dummyRunState     = new RunState {
                YamlOptions = new YamlScript {
                    sequence_items = new[] { testSequenceItem }.ToList()
                }
            };

            var testRetryList = new List <ISequenceItemAction>()
            {
                new SequenceItemSend(dummyRunState, testSequenceItem, testModel, dummyRunAfterList)
            };

            var processorOptions = new ProcessSequenceItem.Options
            {
                state = new RunState {
                    YamlOptions = new YamlScript {
                        sequence_items = new[] { testSequenceItem }.ToList()
                    }
                },
                parent       = null,
                model        = null,
                sequenceItem = null,
                breadcrumbs  = new Stack <KeyValuePair <string, ISequenceItemAction> >()
            };

            /* 𝓐𝓬𝓽 */
            var actualRetryAfterResult = new Stack <ISequenceItemAction>();

            var actualResult = new ProcessSequenceItem(processorOptions).SequenceItemRetryDispatcherAsync(
                new CancellationToken(),
                false,
                testRetryList,
                dummyRunState,
                actualRetryAfterResult,
                new Stack <KeyValuePair <string, ISequenceItemAction> >()).Result;


            /* 𝓐𝓼𝓼𝓮𝓻𝓽 */

            ConsumeTestYamlPact.MockProviderService.VerifyInteractions();

            Assert.True(actualResult.IsSuccess);

            Assert.Empty(actualRetryAfterResult);
        }