public void Persist_RetainsSemVer2Version() { // Arrange var fileSystem = new Mock <IFileSystem>(); fileSystem .Setup(x => x.FileExists(CacheFileName)) .Returns(false); var memoryStream = new MemoryStream(); fileSystem .Setup(x => x.CreateFile(CacheFileName)) .Returns(memoryStream); var actual = new ServerPackageCache(fileSystem.Object, CacheFileName); actual.Add(new ServerPackage { Id = PackageId, Version = SemVer2Version }, enableDelisting: false); // Act actual.Persist(); // Assert var content = Encoding.UTF8.GetString(memoryStream.ToArray()); Assert.Contains(SemVer2VersionString, content); }
public void Exists_ReturnsTrueWhenPackageExists() { // Arrange var fileSystem = new Mock <IFileSystem>(); fileSystem .Setup(x => x.FileExists(CacheFileName)) .Returns(false); var target = new ServerPackageCache(fileSystem.Object, CacheFileName); target.Add(new ServerPackage { Id = "NuGet.Versioning", Version = new SemanticVersion("3.5.0-beta2") }); // Act var actual = target.Exists("NuGet.Versioning", new SemanticVersion("3.5.0-beta2")); // Assert Assert.True(actual); }
public void Exists_IsCaseInsensitive() { // Arrange var fileSystem = new Mock <IFileSystem>(); fileSystem .Setup(x => x.FileExists(CacheFileName)) .Returns(false); var target = new ServerPackageCache(fileSystem.Object, CacheFileName); target.Add(new ServerPackage { Id = "NuGet.Versioning", Version = new SemanticVersion("3.5.0-beta2"), }, enableDelisting: false); // Act var actual = target.Exists("nuget.versioning", new SemanticVersion("3.5.0-BETA2")); // Assert Assert.True(actual); }