Ejemplo n.º 1
0
        public void GetCurrentPeriod_Success()
        {
            var httpClientMock       = new Mock <IBespokeHttpClient>();
            var serialisationService = new JsonSerializationService();
            var rp = new ReturnPeriod()
            {
                CollectionName   = "ILR1819",
                PeriodNumber     = 1,
                CalendarMonth    = 8,
                CalendarYear     = 2018,
                StartDateTimeUtc = new DateTime(2018, 8, 22),
                EndDateTimeUtc   = new DateTime(2018, 9, 04)
            };

            httpClientMock.Setup(x => x.GetDataAsync("testurl/api/returns-calendar/ILR1819/current")).ReturnsAsync(() => serialisationService.Serialize(rp));

            var pollyRegistryMock = new Mock <IReadOnlyPolicyRegistry <string> >();

            pollyRegistryMock.Setup(x => x.Get <IAsyncPolicy>("HttpRetryPolicy")).Returns(Policy.NoOpAsync);
            var apiSettings = new ApiSettings()
            {
                JobManagementApiBaseUrl = "testurl/api"
            };

            var service = new CollectionManagementService(httpClientMock.Object, apiSettings, new JsonSerializationService());
            var data    = service.GetCurrentPeriodAsync("ILR1819").Result;

            data.Should().NotBeNull();
            data.PeriodNumber.Should().Be(1);
        }