Exemplo n.º 1
0
        public void Remove_SupportsDisabledUnlisting()
        {
            // Arrange
            var fileSystem = new Mock <IFileSystem>();

            fileSystem
            .Setup(x => x.FileExists(CacheFileName))
            .Returns(true);
            fileSystem
            .Setup(x => x.OpenFile(CacheFileName))
            .Returns(() => new MemoryStream(Encoding.UTF8.GetBytes(MinimalCacheFile)));
            var target = new ServerPackageCache(fileSystem.Object, CacheFileName);

            // Act
            target.Remove(PackageId, PackageVersion, enableDelisting: false);

            // Assert
            Assert.Empty(target.GetAll());
        }
Exemplo n.º 2
0
        public void Remove_NoOpsWhenPackageDoesNotExist()
        {
            // Arrange
            var fileSystem = new Mock <IFileSystem>();

            fileSystem
            .Setup(x => x.FileExists(CacheFileName))
            .Returns(true);
            fileSystem
            .Setup(x => x.OpenFile(CacheFileName))
            .Returns(() => new MemoryStream(Encoding.UTF8.GetBytes(MinimalCacheFile)));
            var target = new ServerPackageCache(fileSystem.Object, CacheFileName);

            // Act
            target.Remove("Foo", PackageVersion, enableDelisting: false);

            // Assert
            var package = target.GetAll().FirstOrDefault();

            Assert.NotNull(package);
            Assert.Equal(PackageId, package.Id);
            Assert.Equal(PackageVersion, package.Version);
        }