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); }
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(); }
public void ExpectFailAndRetry() { /* ๐๐ป๐ป๐ช๐ท๐ฐ๐ฎ... */ SharedPactScafolding.BuildFailConsumerForId(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.ProcessSequenceItemAsync(actualRetryAfterResult).Result; /* ๐๐ผ๐ผ๐ฎ๐ป๐ฝ */ ConsumeTestYamlPact.MockProviderService.VerifyInteractions(); Assert.False(actualResult); Assert.Same(testSequenceItem, actualRetryAfterResult.Single().GetSequenceItem()); Assert.Contains(actualRetryAfterResult, item => item.ActionExecuteCount == 2); }
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); }