コード例 #1
0
        public async Task IsValidAsync_State_DestinationPath_HasInvalidCharacters()
        {
            var state = new Mocks.LibraryInstallationState
            {
                ProviderId      = "filesystem",
                Name            = "http://glyphlist.azurewebsites.net/img/images/Flag.png",
                DestinationPath = "|lib"
            };

            ILibraryOperationResult result = await state.IsValidAsync(_dependencies);

            Assert.IsFalse(result.Success);
            Assert.AreEqual(result.Errors.Count, 1);
            Assert.AreEqual("LIB012", result.Errors.First().Code);
        }
コード例 #2
0
        public async Task IsValidAsync_State_FileSystem_FilesDoNotExist()
        {
            var state = new Mocks.LibraryInstallationState
            {
                ProviderId      = "filesystem",
                Name            = "http://glyphlist.azurewebsites.net/img/images/Flag.png",
                DestinationPath = "lib",
                Files           = new[] { "foo.png" }
            };

            ILibraryOperationResult result = await state.IsValidAsync(_dependencies);

            // FileSystemProvider supports renaming, therefore validation does not fail
            Assert.IsTrue(result.Success);
        }
コード例 #3
0
        public async Task IsValidAsync_State_FileSystem_LibraryIdDoesNotExist()
        {
            var state = new Mocks.LibraryInstallationState
            {
                ProviderId      = "filesystem",
                Name            = "lib",
                DestinationPath = "lib",
            };

            ILibraryOperationResult result = await state.IsValidAsync(_dependencies);

            Assert.IsFalse(result.Success);
            Assert.AreEqual(result.Errors.Count, 1);
            Assert.AreEqual(result.Errors.First().Code, "LIB002");
        }
コード例 #4
0
        public async Task IsValidAsync_State_HasNoProvider()
        {
            var state = new Mocks.LibraryInstallationState
            {
                Name = "_lib_",
                DestinationPath = "_path_",
                Files = new List<string>() { "a", "b" },
            };

            ILibraryOperationResult result = await state.IsValidAsync(_dependencies);

            Assert.IsFalse(result.Success);
            Assert.AreEqual(result.Errors.Count, 1);
            Assert.AreEqual(result.Errors.First().Code, "LIB007");
        }
コード例 #5
0
        public async Task IsValidAsync_State_FileSystem_LibraryIdHasInvalidPathCharacters()
        {
            var state = new Mocks.LibraryInstallationState
            {
                ProviderId = "filesystem",
                Name = "|lib_",
                DestinationPath = "_path_",
                Files = new List<string>() { "a", "b" },
            };

            ILibraryOperationResult result = await state.IsValidAsync(_dependencies);

            Assert.IsFalse(result.Success);
            Assert.AreEqual(result.Errors.Count, 1);
            Assert.AreEqual(result.Errors.First().Code, "LIB002");
        }
コード例 #6
0
        public async Task IsValidAsync_State_HasUnknownLibraryFile()
        {
            var state = new Mocks.LibraryInstallationState
            {
                ProviderId = "unpkg",
                Name = "jquery",
                Version = "3.3.1",
                DestinationPath = "_path_",
                Files = new List<string>() { "a", "b" },
            };

            ILibraryOperationResult result = await state.IsValidAsync(_dependencies);

            // IsValidAsync does not validate library files
            // Issue https://github.com/aspnet/LibraryManager/issues/254 should fix that
            Assert.IsTrue(result.Success);
        }