Ejemplo n.º 1
0
        public void GetAvailableCollections_Success()
        {
            var httpClientMock       = new Mock <IBespokeHttpClient>();
            var serialisationService = new JsonSerializationService();
            var items = new List <Collection>()
            {
                new Collection()
                {
                    CollectionTitle = "ILR1819",
                    CollectionType  = "ILR",
                    IsOpen          = true
                },
                new Collection()
                {
                    CollectionTitle = "ILR1718",
                    CollectionType  = "ILR",
                    IsOpen          = true
                },
            };

            httpClientMock.Setup(x => x.GetDataAsync("testurl/api/collections/10000/ILR")).ReturnsAsync(() => serialisationService.Serialize(items));

            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.GetAvailableCollectionsAsync(10000, "ILR").Result;

            data.Count().Should().Be(2);
            data.Any(x => x.CollectionName == "ILR1819" && x.IsOpen == true).Should().BeTrue();
            data.Any(x => x.CollectionName == "ILR1718" && x.IsOpen == true).Should().BeTrue();
        }