Exemplo n.º 1
0
        public async Task GetLibraryAsync_Success()
        {
            Mocks.WebRequestHandler fakeRequestHandler = new Mocks.WebRequestHandler().SetupFiles("[email protected]", "jquery/[email protected]");
            JsDelivrCatalog         sut = SetupCatalog(fakeRequestHandler);

            CancellationToken token   = CancellationToken.None;
            ILibrary          library = await sut.GetLibraryAsync("jquery", "3.3.1", token);

            Assert.IsNotNull(library);
            Assert.AreEqual("jquery", library.Name);
            Assert.AreEqual("3.3.1", library.Version);

            ILibrary libraryGH = await sut.GetLibraryAsync("jquery/jquery", "3.3.1", token);

            Assert.IsNotNull(libraryGH);
            Assert.AreEqual("jquery/jquery", libraryGH.Name);
            Assert.AreEqual("3.3.1", libraryGH.Version);
        }
Exemplo n.º 2
0
        public async Task GetLibraryAsync_Success()
        {
            var fakeCache = new Mock <ICacheService>();

            fakeCache.SetupLibraryFiles("[email protected]", "fake/[email protected]");
            JsDelivrCatalog sut = SetupCatalog(cacheService: fakeCache.Object);

            CancellationToken token   = CancellationToken.None;
            ILibrary          library = await sut.GetLibraryAsync("fakeLibrary", "3.3.1", token);

            Assert.IsNotNull(library);
            Assert.AreEqual("fakeLibrary", library.Name);
            Assert.AreEqual("3.3.1", library.Version);

            ILibrary libraryGH = await sut.GetLibraryAsync("fake/fakeLibrary", "3.3.1", token);

            Assert.IsNotNull(libraryGH);
            Assert.AreEqual("fake/fakeLibrary", libraryGH.Name);
            Assert.AreEqual("3.3.1", libraryGH.Version);
        }
Exemplo n.º 3
0
        public async Task GetLibraryAsync_InvalidLibraryId()
        {
            JsDelivrCatalog sut = SetupCatalog();

            await Assert.ThrowsExceptionAsync <InvalidLibraryException>(() => sut.GetLibraryAsync("invalid_id", "", CancellationToken.None));
        }
Exemplo n.º 4
0
        public async Task GetLibraryAsync_CacheRequestFails_ShouldThrow()
        {
            var fakeCacheService = new Mock <ICacheService>();

            fakeCacheService.SetupBlockRequests();
            JsDelivrCatalog sut = SetupCatalog(cacheService: fakeCacheService.Object);

            await Assert.ThrowsExceptionAsync <InvalidLibraryException>(async() => await sut.GetLibraryAsync("fakeLibrary", "1.1.1", CancellationToken.None));
        }