public void Get(IDateTimeProvider timeProvider, ILogger <DataFilePathProvider> logger, IFileSystem fileSystem) { var settings = Substitute.ForPartsOf <AutoSettings>(); fileSystem.GetTempDirectoryPath().Returns(Path.GetTempPath()); var sut = new DataFilePathProvider(settings, timeProvider, logger, fileSystem); string resultDir = TestContext.CurrentContext.TestDirectory; var expectedFiles = new[] { "collect_deadlock_data_123.xel", "collect_long_locks_data_123dfds.xel", "ts_sqlprofiler_05_sec_asdv.xel" }; string xEventsDir = CreateTestFiles(timeProvider, expectedFiles); var now = DateTime.UtcNow.AddHours(1); timeProvider.UtcNow.Returns(now); settings.EventsDataDirectoryTemplate.Returns(xEventsDir); List <string> files = new List <string>(); foreach (string dir in sut.GetDailyExtEventsDirs()) { resultDir = dir; files.AddRange(Directory.EnumerateFiles(dir).Select(Path.GetFileName)); } files.Should().BeEquivalentTo(expectedFiles); DirectoryAssert.DoesNotExist(resultDir); }
public void TestFileExists() { FileInfo file = new FileInfo("111.txt"); FileAssert.Exists(file); DirectoryAssert.DoesNotExist("11"); }
public void FindNonExistingFolder() { string folder = @"C:\tempp"; DirectoryAssert.DoesNotExist(folder); Assert.IsFalse(FileSystemHelper.FolderVerification(folder)); }
public IEnumerator EnableSemanticSegmentation_GeneratesCorrectDataset([Values(true, false)] bool enabled) { SemanticSegmentationLabeler semanticSegmentationLabeler = null; SetupCamera(pc => { semanticSegmentationLabeler = new SemanticSegmentationLabeler(CreateSemanticSegmentationLabelConfig()); pc.AddLabeler(semanticSegmentationLabeler); }, enabled); string expectedImageFilename = $"segmentation_{Time.frameCount}.png"; this.AddTestObjectForCleanup(TestHelper.CreateLabeledPlane()); yield return(null); DatasetCapture.ResetSimulation(); if (enabled) { var capturesPath = Path.Combine(DatasetCapture.OutputDirectory, "captures_000.json"); var capturesJson = File.ReadAllText(capturesPath); var imagePath = $"{semanticSegmentationLabeler.semanticSegmentationDirectory}/{expectedImageFilename}"; StringAssert.Contains(imagePath, capturesJson); } else { DirectoryAssert.DoesNotExist(DatasetCapture.OutputDirectory); } }
public void Should_BePossibleTo_SaveAndCompareWithDump_WithOverlengthDumpName_WhenAllElementsSelected() { var customForm = new WebForm(); customForm.SetElementsForDump(WebForm.ElementsFilter.AllElements); var maxElementNameLength = (int)customForm.Dump.GetType().GetMethod("GetMaxNameLengthOfDumpElements", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(customForm.Dump, new object[] { }); var imageExtensioLength = ((ImageFormat)customForm.Dump.GetType().GetProperty("ImageFormat", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(customForm.Dump)).Extension.Length; var maxLength = (int)customForm.Dump.GetType().GetProperty("MaxFullFileNameLength", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(customForm.Dump); var pathToDumpLength = PathToDumps.Length; var dumpName = new string('A', maxLength - pathToDumpLength - maxElementNameLength - imageExtensioLength); var overlengthDumpName = dumpName + "_BCDE"; var overlengthPathToDump = CleanUpAndGetPathToDump(overlengthDumpName); var pathToDump = CleanUpAndGetPathToDump(dumpName); Assert.DoesNotThrow(() => customForm.Dump.Save(overlengthDumpName)); overlengthPathToDump.Refresh(); DirectoryAssert.DoesNotExist(overlengthPathToDump); pathToDump.Refresh(); DirectoryAssert.Exists(pathToDump); Assert.That(customForm.Dump.Compare(dumpName), Is.EqualTo(0), "Some elements should be failed to take image, but difference should be around zero"); }
public void PatientBothDirs() { _extractor.PerPatient = true; _extractor.Directories = true; _extractor.Pattern = "$p"; _extractor.Check(new ThrowImmediatelyCheckNotifier()); FileAssert.DoesNotExist(Path.Combine(_outDir.FullName, "blah.txt")); FileAssert.DoesNotExist(Path.Combine(_outDir.FullName, "blah2.txt")); _extractor.MovePatient("Sub1", "Rel1", _outDir, new ThrowImmediatelyDataLoadEventListener() { ThrowOnWarning = true }, new GracefulCancellationToken()); _extractor.MovePatient("Sub2", "Rel2", _outDir, new ThrowImmediatelyDataLoadEventListener() { ThrowOnWarning = true }, new GracefulCancellationToken()); FileAssert.DoesNotExist(Path.Combine(_outDir.FullName, "blah.txt")); FileAssert.DoesNotExist(Path.Combine(_outDir.FullName, "blah2.txt")); DirectoryAssert.Exists(Path.Combine(_outDir.FullName, "Rel1")); DirectoryAssert.Exists(Path.Combine(_outDir.FullName, "Rel2")); DirectoryAssert.DoesNotExist(Path.Combine(_outDir.FullName, "Sub1")); DirectoryAssert.DoesNotExist(Path.Combine(_outDir.FullName, "Sub2")); }
public void AfterDeleteFolderDoesNotExist() { var folder = MakeTempFolder(); DirectoryAssert.Exists(folder.FullPath); folder.TryDelete(); DirectoryAssert.DoesNotExist(folder.FullPath); }
public void TestUnmountUncDir() { var dir = (string)_config.target; _context.CakeContext.UnmountUncDir(dir); DirectoryAssert.DoesNotExist(dir); }
public void CreateNonExistingFolder() { string folder = @"C:\temp\foldertesting"; DirectoryAssert.DoesNotExist(folder); Assert.IsTrue(FileSystemHelper.FolderCreation(folder)); DirectoryAssert.Exists(folder); }
public void LongPath() { var file = NewFile(fileName: "foo".PadRight(MaxFileName, 'N')); var task = CreateTask(); Assert.IsTrue(task.Execute(), "task.Execute() should have succeeded."); Assert.AreEqual(1, task.RemovedDirectories.Length, "Changes should have been made."); DirectoryAssert.DoesNotExist(tempDirectory); }
public void NoExist() { Directory.Delete(tempDirectory); var task = CreateTask(); Assert.IsTrue(task.Execute(), "task.Execute() should have succeeded."); Assert.AreEqual(0, task.RemovedDirectories.Length, "No changes should have been made."); DirectoryAssert.DoesNotExist(tempDirectory); }
public void FileChecks() { var realFilePath = Assembly.GetExecutingAssembly().Location; var realFileInfo = new FileInfo(realFilePath); var realDirectoryPath = Path.GetDirectoryName(realFilePath); var realDirectoryInfo = new DirectoryInfo(realDirectoryPath); var nonexistantFilePath = "E:/fake.folder/this.is.fake"; var nonexistantFileInfo = new FileInfo(nonexistantFilePath); var nonexistantDirectoryPath = Path.GetDirectoryName(nonexistantFilePath); var nonexistantDirectoryInfo = new DirectoryInfo(nonexistantDirectoryPath); // Constraint-style asserts: Assert.That(realFilePath, Does.Exist); Assert.That(realFileInfo, Does.Exist); Assert.That(nonexistantFilePath, Does.Not.Exist); Assert.That(nonexistantFileInfo, Does.Not.Exist); Assert.That(realDirectoryPath, Does.Exist); Assert.That(realDirectoryInfo, Does.Exist); Assert.That(nonexistantDirectoryPath, Does.Not.Exist); Assert.That(nonexistantDirectoryInfo, Does.Not.Exist); Assert.That(realDirectoryInfo, Is.Not.Empty); Assert.That("/folder1/./junk/../folder2", Is.SamePath("/folder1/folder2")); Assert.That("/folder1/./junk/../folder2/..", Is.Not.SamePath("/folder1/folder2")); Assert.That("/folder1/./junk/../folder2", Is.SamePath("/FOLDER1/folder2").IgnoreCase); Assert.That("/folder1/./junk/../folder2", Is.Not.SamePath("/FOLDER1/folder2").RespectCase); Assert.That("/folder1/./junk/../folder2/./foo", Is.SamePathOrUnder("/folder1/folder2")); Assert.That("/folder1/./junk/../folder2/./foo", Is.SubPathOf("/folder1")); // Classic-style asserts: // see: https://github.com/nunit/docs/wiki/File-Assert FileAssert.Exists(realFileInfo); FileAssert.Exists(realFilePath); FileAssert.DoesNotExist(nonexistantFileInfo); FileAssert.DoesNotExist(nonexistantFilePath); DirectoryAssert.Exists(realDirectoryPath); DirectoryAssert.Exists(realDirectoryInfo); DirectoryAssert.DoesNotExist(nonexistantDirectoryPath); DirectoryAssert.DoesNotExist(nonexistantDirectoryInfo); }
public void SilentInstallerTest(MSIInstaller installer) { string actualProductName = installer.ProductName.Replace("-oss", ""); // Install TestContext.Out.WriteLine($"Installing {actualProductName}..."); int installExitCode = installer.Install().ExitCode; TestContext.Out.WriteLine($" -> installation finished with exit code {installExitCode}"); Assert.That(installExitCode, Is.EqualTo(0), "Product installed successfully (exit code 0)"); // TODO Enable immutable dir check once stack version value is determined //string immutablePath = Path.Combine(pathsProvider.ElasticImmutableRoot, "Beats", stackVersion, actualProductName); //TestContext.Out.WriteLine($" -> checking immutable path exists: {immutablePath}"); //DirectoryAssert.Exists(immutablePath, $"Immutable path {immutablePath} exists after installation"); try { foreach (string mutableDir in installer.ProductConfig.MutableDirs) { string mutablePath = Path.Combine(pathsProvider.ElasticMutableRoot, "Beats", actualProductName, mutableDir); TestContext.Out.WriteLine($" -> checking mutable path exists: {mutablePath}"); DirectoryAssert.Exists(mutablePath, $"Mutable path {mutablePath} exists after installation"); } ServiceController service = ServiceController.GetServices().FirstOrDefault(service => service.ServiceName == actualProductName); TestContext.Out.WriteLine($" -> checking service '{actualProductName}' exists"); Assert.That(service, Is.Not.Null, $"Service named '{actualProductName}' exists"); } finally { // Uninstall TestContext.Out.WriteLine($"Uninstalling {actualProductName}..."); int uninstallExitCode = installer.Uninstall().ExitCode; TestContext.Out.WriteLine($" -> uninstall finished with exit code {uninstallExitCode}."); Assert.That(uninstallExitCode, Is.EqualTo(0), "Product uninstalled successfully (exit code 0)"); // TODO Enable immutable dir check once stack version value is determined //TestContext.Out.WriteLine($" -> checking immutable path no longer exists: {immutablePath}"); //DirectoryAssert.Exists(immutablePath, $"Immutable path {immutablePath} no longer exists after uninstall"); foreach (string mutableDir in installer.ProductConfig.MutableDirs) { string mutablePath = Path.Combine(pathsProvider.ElasticMutableRoot, "Beats", actualProductName, mutableDir); TestContext.Out.WriteLine($" -> checking mutable path no longer exists: {mutablePath}"); DirectoryAssert.DoesNotExist(mutablePath, $"Mutable path {mutablePath} no longer exists after uninstall"); } ServiceController service = ServiceController.GetServices().FirstOrDefault(service => service.ServiceName == actualProductName); TestContext.Out.WriteLine($" -> checking service '{actualProductName}' no longer exists"); Assert.That(service, Is.Null, $"Service named '{actualProductName}' no longer exists"); } TestContext.Out.WriteLine($"[PASSED] {installer.ProductName} MSI silent install/uninstall"); }
public void Test_delete_subdirectory() { dir.CreateDir("sourceDir1", "subdir1"); CopyDir(sourceDir1, targetDir, NextStorage()); DirectoryAssert.Exists(dir.CreatePath("target", "subdir1")); CopyDir(sourceDir2, targetDir, NextStorage()); DirectoryAssert.DoesNotExist(dir.CreatePath("target", "subdir1")); }
public async Task RemoveLibrary() { var id = new LibraryId("nuget.org", "Newtonsoft.Json", "12.0.2"); DirectoryAssert.Exists(_sut.GetPackageLocation(id)); await _sut.RemoveLibraryAsync(id, CancellationToken.None); DirectoryAssert.DoesNotExist(Path.GetDirectoryName(_sut.GetPackageLocation(id))); }
public void ReadonlyFile() { var file = NewFile(); File.SetAttributes(file, FileAttributes.ReadOnly); var task = CreateTask(); Assert.IsTrue(task.Execute(), "task.Execute() should have succeeded."); Assert.AreEqual(1, task.RemovedDirectories.Length, "Changes should have been made."); DirectoryAssert.DoesNotExist(tempDirectory); }
public void Should_BeImpossibleTo_SaveFormDump_WithInvalidExtension(string imageExtension) { var form = new LiteWebForm(imageExtension); var dumpName = $"Test {imageExtension} extension"; var pathToDump = CleanUpAndGetPathToDump(dumpName); Assert.Throws <NotSupportedException>(() => form.Dump.Save(dumpName)); pathToDump.Refresh(); DirectoryAssert.DoesNotExist(pathToDump); }
public void AssertionsMix() { Assert.True(true); Assert.False(false); StringAssert.DoesNotContain("DCB", "ABCDEFG"); CollectionAssert.AllItemsAreNotNull(new List <int>() { 1, 2, 3, 4, 5, 6 }); FileAssert.DoesNotExist("somefile.txt"); DirectoryAssert.DoesNotExist("abcd"); }
public void ExtractAll_MacOSFiles() { using (var zip = ZipArchive.Create(stream)) { zip.AddEntry("a/.DS_Store", "a", encoding); zip.AddEntry("b/__MACOSX/b.txt", "b", encoding); zip.AddEntry("c/__MACOSX", "c", encoding); } bool changes = ExtractAll(stream); Assert.IsFalse(changes, "ExtractAll should *not* report changes."); DirectoryAssert.DoesNotExist(tempDir); }
public void LongPath() { if (LongPathsSupported) { Assert.Ignore("This environment supports long paths"); } var file = NewFile(fileName: "foo".PadRight(MaxFileName, 'N')); var task = CreateTask(); Assert.IsTrue(task.Execute(), "task.Execute() should have succeeded."); Assert.AreEqual(1, task.RemovedDirectories.Length, "Changes should have been made."); DirectoryAssert.DoesNotExist(tempDirectory); Assert.IsTrue(StringAssertEx.ContainsText(messages.Select(m => m.Message), $"Trying long path: {Files.LongPathPrefix}"), "A long path should be encountered."); }
public void LongPath() { if (!IsWindows) { Assert.Ignore("MAX_PATH only applies on Windows"); } var file = NewFile(fileName: "foo".PadRight(250, 'N')); var task = CreateTask(); Assert.IsTrue(task.Execute(), "task.Execute() should have succeeded."); Assert.AreEqual(1, task.RemovedDirectories.Length, "Changes should have been made."); DirectoryAssert.DoesNotExist(tempDirectory); Assert.IsTrue(StringAssertEx.ContainsText(messages.Select(m => m.Message), $"Trying long path: {Files.LongPathPrefix}"), "A long path should be encountered."); }
public void BindingCheckHiddenFiles() { var binding = new XamarinAndroidBindingProject { ProjectName = "Binding", IsRelease = true, }; binding.AndroidClassParser = "class-parse"; binding.Jars.Add(new AndroidItem.LibraryProjectZip("Jars\\mylibrary.aar") { WebContentFileNameFromAzure = "mylibrary.aar" }); binding.Jars.Add(new AndroidItem.EmbeddedJar("Jars\\svg-android.jar") { WebContentFileNameFromAzure = "javaBindingIssue.jar" }); var path = Path.Combine("temp", TestName); using (var bindingBuilder = CreateDllBuilder(Path.Combine(path, binding.ProjectName))) { Assert.IsTrue(bindingBuilder.Build(binding), "binding build should have succeeded"); var proj = new XamarinAndroidApplicationProject { ProjectName = "App", }; proj.OtherBuildItems.Add(new BuildItem("ProjectReference", $"..\\{binding.ProjectName}\\{binding.ProjectName}.csproj")); proj.AndroidManifest = $@"<?xml version=""1.0"" encoding=""utf-8""?> <manifest xmlns:android=""http://schemas.android.com/apk/res/android"" xmlns:tools=""http://schemas.android.com/tools"" android:versionCode=""1"" android:versionName=""1.0"" package=""{proj.PackageName}""> <uses-sdk /> <application android:label=""{proj.ProjectName}"" tools:replace=""android:label""> </application> </manifest>"; using (var b = CreateApkBuilder(Path.Combine(path, proj.ProjectName))) { Assert.IsTrue(b.Build(proj), "Build should have succeeded."); var assemblyMap = b.Output.GetIntermediaryPath(Path.Combine("lp", "map.cache")); FileAssert.Exists(assemblyMap); var libraryProjects = Path.Combine(Root, b.ProjectDirectory, proj.IntermediateOutputPath, "lp"); var assemblyIdentityMap = b.Output.GetAssemblyMapCache(); var assemblyIdentityName = Builder.UseDotNet ? "mylibrary.aar" : $"{binding.ProjectName}.dll"; var assemblyIdentity = assemblyIdentityMap.IndexOf(assemblyIdentityName).ToString(); var dsStorePath = Path.Combine(libraryProjects, assemblyIdentity, "jl"); DirectoryAssert.Exists(dsStorePath); FileAssert.DoesNotExist(Path.Combine(dsStorePath, ".DS_Store")); DirectoryAssert.DoesNotExist(Path.Combine(dsStorePath, "_MACOSX")); var svgJar = Builder.UseDotNet ? Path.Combine(libraryProjects, assemblyIdentityMap.IndexOf($"{binding.ProjectName}.aar").ToString(), "jl", "libs", "FD575F2BC294C4A9.jar") : Path.Combine(dsStorePath, "svg-android.jar"); FileAssert.Exists(svgJar); } } }
public void OneFile() { _extractor.Directories = false; _extractor.Pattern = "blah.*"; _extractor.Check(new ThrowImmediatelyCheckNotifier()); FileAssert.DoesNotExist(Path.Combine(_outDir.FullName, "blah.txt")); FileAssert.DoesNotExist(Path.Combine(_outDir.FullName, "blah2.txt")); _extractor.MoveAll(_outDir, new ThrowImmediatelyDataLoadEventListener(), new GracefulCancellationToken()); FileAssert.Exists(Path.Combine(_outDir.FullName, "blah.txt")); FileAssert.DoesNotExist(Path.Combine(_outDir.FullName, "blah2.txt")); DirectoryAssert.DoesNotExist(Path.Combine(_outDir.FullName, "Sub1")); DirectoryAssert.DoesNotExist(Path.Combine(_outDir.FullName, "Sub2")); }
public void ValidateScriptDomainAppBase() { _sut.DisplayName = GetType().Assembly.Location; _sut.ReadAssemblyContent = () => File.ReadAllBytes(GetType().Assembly.Location); _sut.Configuration = new AssemblyScriptConfiguration(typeof(StepWithSubDomain).Name, nameof(StepWithSubDomain.ShowAppBase)); _sut.Execute(new DbCommandProxy(_command.Object), _variables, _log.Object); Assert.AreEqual(2, _executedScripts.Count); var assemblyFileName = _executedScripts[0]; FileAssert.DoesNotExist(assemblyFileName); Assert.AreEqual(Path.GetFileName(assemblyFileName), Path.GetFileName(GetType().Assembly.Location)); var appBase = _executedScripts[1]; DirectoryAssert.DoesNotExist(appBase); Assert.AreEqual(appBase, Path.GetDirectoryName(assemblyFileName)); }
public void UnlinkSourceSdkProject() { // Arrange var dllPath = Path.Combine(Constants.TestBasePath, @"Package.Sdk\1.0.0\lib\netstandard2.0\Package.Sdk.dll"); Directory.CreateDirectory(Path.GetDirectoryName(dllPath)); File.WriteAllText(dllPath, ""); var csprojPath = Path.Combine(Constants.TestSoltuionSrc, @"Package.Sdk\Package.Sdk.csproj"); var console = new NuGet.CommandLine.Console(); var linkArgs = new UnlinkArgs { CurrentDirectory = Path.GetDirectoryName(csprojPath), Console = console, }; var runner = new UnlinkCommandRunner(linkArgs); // Act runner.Unlink(); // Assert DirectoryAssert.DoesNotExist(Path.Combine(Constants.TestBasePath, LinkCommandRunner.BasePath, @"Package.Sdk\1.0.0")); }
public void Should_Create_And_Delete_Directory() { using (var trackerA = new TemporaryFileTracker()) { trackerA.CreateDirectory(m_TestDirectory + "/Parent/Child"); using (var trackerB = new TemporaryFileTracker()) { File.Create(trackerB.TrackFile(m_TestDirectory + "/Parent/Child/File.txt")).Dispose(); File.Create(trackerB.TrackFile(m_TestDirectory + "/Parent/File.txt")).Dispose(); DirectoryAssert.Exists(m_TestDirectory + "/Parent/Child"); FileAssert.Exists(m_TestDirectory + "/Parent/Child/File.txt"); FileAssert.Exists(m_TestDirectory + "/Parent/File.txt"); } FileAssert.DoesNotExist(m_TestDirectory + "/Parent/Child/File.txt"); FileAssert.DoesNotExist(m_TestDirectory + "/Parent/File.txt"); DirectoryAssert.Exists(m_TestDirectory + "/Parent/Child"); } DirectoryAssert.DoesNotExist(m_TestDirectory + "/Parent/Child"); DirectoryAssert.DoesNotExist(m_TestDirectory + "/Parent"); DirectoryAssert.Exists(m_TestDirectory); }
public void DoesNotExistPassesWhenStringDoesNotExist() { DirectoryAssert.DoesNotExist(BAD_DIRECTORY); }
public void DoesNotExistPassesWhenDirectoryInfoDoesNotExist() { DirectoryAssert.DoesNotExist(new DirectoryInfo(BAD_DIRECTORY)); }
public void DoesNotExistFailsWhenStringIsNull() { var ex = Assert.Throws <ArgumentNullException>(() => DirectoryAssert.DoesNotExist((string)null)); Assert.That(ex.Message, Does.StartWith("The actual value must be a non-null string or DirectoryInfo")); }
public void DoesNotExistFailsWhenStringIsEmpty() { var ex = Assert.Throws <ArgumentException>(() => DirectoryAssert.DoesNotExist(string.Empty)); Assert.That(ex.Message, Does.StartWith("The actual value cannot be an empty string")); }