public async Task When_Polling_Results_In_An_Http_Error_The_Returned_PollState_Has_Delay_Set_To_The_Specified_Http_Error_Delay() { // Given: uint httpErrorDelay = 12345; var pollingPolicy = PollingDelays.DefaultPollingErrorDelays; pollingPolicy[HttpChannelPoller.PollingError.ErrorMakingHttpRequest] = httpErrorDelay; var testResponses = new List <Either <HttpError, string> >() { new Either <HttpError, string>(new HttpError(HttpStatusCode.BadRequest)) }; Func <string, Either <DeserializeError, TransportMessage> > deserializeTransportMessage = s => TransportMessageDeserializer.Deserialize(s, new Dictionary <string, Type> { { TestMessage.MessageName, typeof(TestMessage) } }); var initialPollState = BasicInitialPollState(pollingPolicy); // When: PollState newPollStateTask = await MessageEndpointPoller.Execute( initialPollState, new TestHttpService(testResponses), new CancellationToken(), GetHandlerForMessageType, deserializeTransportMessage); // Then Assert.NotNull(newPollStateTask); Assert.AreEqual(httpErrorDelay, newPollStateTask.DelayMs); }
public async Task Polling_From_Start_Works() { // Given: uint httpErrorDelay = 12345; var pollingPolicy = PollingDelays.DefaultPollingErrorDelays; pollingPolicy[HttpChannelPoller.PollingError.ErrorMakingHttpRequest] = httpErrorDelay; var loc = Path.Combine( TestContext.CurrentContext.TestDirectory, "http-responses\\sample.json"); var content = File.ReadAllText(loc); var testResponses = new List <Either <HttpError, string> >() { new Either <HttpError, string>(content) }; var initialPollState = BasicInitialPollState(pollingPolicy); Either <DeserializeError, TransportMessage> DeserializeTransportMessage(string s) => TransportMessageDeserializer.Deserialize( s, new Dictionary <string, Type> { { TestMessage.MessageName, typeof(TestMessage) } }); // When: PollState newPollStateTask = await MessageEndpointPoller.Execute( initialPollState, new TestHttpService(testResponses), new CancellationToken(), GetHandlerForMessageType, DeserializeTransportMessage); // Then //Assert.AreEqual(httpErrorDelay, newPollStateTask.DelayMs); Assert.AreEqual(4, TestMessageHandler.Counter); }