public void RobustDelete_TemporaryLocked_Deletes_NoException() { using (var tempFolder = new TemporaryFolder("RobustDelete03")) { var fileName = Path.Combine(tempFolder.Path, "not_locked.txt"); FileAssert.DoesNotExist(fileName); var worker = new BackgroundWorker(); worker.DoWork += delegate { File.WriteAllText(fileName, @"temp file"); using (new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) { Thread.Sleep(1700); } }; worker.RunWorkerAsync(); while (!File.Exists(fileName)) { Application.DoEvents(); } Assert.DoesNotThrow(() => FileSystemUtils.RobustDelete(fileName)); FileAssert.DoesNotExist(fileName); } }
public void Test_delete_target_file() { CopyDir(sourceDir1, targetDir, NextStorage()); CopyDir(sourceDir2, targetDir, NextStorage()); FileAssert.DoesNotExist(dir.CreatePath("target", "file1")); }
public void TestCodeBasicHttpNetTCPSupported(string version) { var solutionPath = CopySolutionFolderToTemp("PACoreWCFSupport.sln", tempDir); TestSolutionAnalysis results = AnalyzeSolution(solutionPath, version); var testCaseName = "TC9CodeBasicHttpNetTCPSupported"; var project = results.ProjectResults.Where(prop => prop.CsProjectPath.EndsWith(testCaseName + ".csproj")).FirstOrDefault(); var projectDir = Directory.GetParent(project.CsProjectPath).FullName; var csProjContent = project.CsProjectContent; var startupText = File.ReadAllText(Path.Combine(projectDir, "Startup.cs")); var programText = File.ReadAllText(Path.Combine(projectDir, "Program.cs")); var service = File.ReadAllText(Path.Combine(projectDir, "IEchoService.cs")); string corewcfConfigPath = Path.Combine(projectDir, "corewcf_ported.config"); FileAssert.DoesNotExist(corewcfConfigPath); StringAssert.Contains(@"CoreWCF.Primitives", csProjContent); StringAssert.Contains(@"CoreWCF.Http", csProjContent); StringAssert.Contains(@"CoreWCF.NetTcp", csProjContent); StringAssert.Contains(@"Microsoft.AspNetCore", csProjContent); StringAssert.DoesNotContain(@"CoreWCF.ConfigurationManager", csProjContent); StringAssert.AreEqualIgnoringCase(Regex.Replace(ExpectedOutputConstants.WCFTC9CodeBasedStartupText, @"\r", ""), Regex.Replace(startupText, @"\r", "")); StringAssert.AreEqualIgnoringCase(Regex.Replace(ExpectedOutputConstants.WCFTC9CodeBasedProgramText, @"\r", ""), Regex.Replace(programText, @"\r", "")); StringAssert.Contains(@"using CoreWCF", service); }
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 TestStoreAtDefaultLocation() { FileAssert.DoesNotExist(_testLocation); FileStream openStream = File.Create(_testLocation); openStream.Close(); StorageSettings.StorageDefaultLocation = _testLocation; Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory; IDictionary <CharacterClass, IEnumerable <IBuild> > builds = new Dictionary <CharacterClass, IEnumerable <IBuild> >(); builds[CharacterClass.Barbarian] = new List <IBuild>() { BuildBuilder.BuildDefaultBuild() }; _manager = new StorageManager(); _manager.StoreAtDefaultLocation(builds); FileAssert.Exists(_testLocation); string[] lines = File.ReadAllLines(_testLocation); Assert.IsTrue(lines.Length > 0); Assert.IsFalse(string.IsNullOrEmpty(lines[0])); IBuildSerializer serializer = new BuildSerializer(); IDictionary <CharacterClass, IEnumerable <IBuild> > deserializedBuilds = serializer.Deserialize(_testLocation); Assert.AreEqual(1, deserializedBuilds[CharacterClass.Barbarian].Count()); Assert.AreEqual(BuildBuilder.BuildDefaultBuild(), deserializedBuilds[CharacterClass.Barbarian].First()); }
public void WhenBuildLayoutIsDisabled_BuildLayoutIsNotGenerated() { ProjectConfigData.GenerateBuildLayout = false; CreateAddressablePrefab("p1", CreateGroup("Group1")); BuildAndExtractLayout(); FileAssert.DoesNotExist(BuildLayoutGenerationTask.m_LayoutTextFile); }
public void DotNetPublish([Values(false, true)] bool isRelease) { const string runtimeIdentifier = "android.21-arm"; var proj = new XASdkProject { IsRelease = isRelease }; proj.SetProperty(KnownProperties.RuntimeIdentifier, runtimeIdentifier); var dotnet = CreateDotNetBuilder(proj); Assert.IsTrue(dotnet.Publish(), "first `dotnet publish` should succeed"); var publishDirectory = Path.Combine(FullProjectDirectory, proj.OutputPath, runtimeIdentifier, "publish"); var apk = Path.Combine(publishDirectory, $"{proj.PackageName}.apk"); var apkSigned = Path.Combine(publishDirectory, $"{proj.PackageName}-Signed.apk"); FileAssert.Exists(apk); FileAssert.Exists(apkSigned); Assert.IsTrue(dotnet.Publish(parameters: new [] { "AndroidPackageFormat=aab" }), $"second `dotnet publish` should succeed"); var aab = Path.Combine(publishDirectory, $"{proj.PackageName}.aab"); var aabSigned = Path.Combine(publishDirectory, $"{proj.PackageName}-Signed.aab"); FileAssert.DoesNotExist(apk); FileAssert.DoesNotExist(apkSigned); FileAssert.Exists(aab); FileAssert.Exists(aabSigned); }
public void DoesNotExistFailsWhenStringExists() { using (new TestFile("Test1.txt", "TestText1.txt")) { var ex = Assert.Throws <AssertionException>(() => FileAssert.DoesNotExist("Test1.txt")); Assert.That(ex.Message, Is.StringStarting(" Expected: not file exists")); } }
public void DoesNotExistFailsWhenStringExists() { using (var tf1 = new TestFile("Test1.txt", "TestText1.txt")) { var ex = Assert.Throws <AssertionException>(() => FileAssert.DoesNotExist(tf1.File.FullName)); Assert.That(ex.Message, Does.StartWith(" Expected: not file exists")); } }
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 IgnoresZipPackages() { File.Copy(GetFixtureResouce("Samples", "Acme.Core.1.0.0.0-bugfix.zip"), Path.Combine(rootDir, "Acme.Core.1.0.0.0-bugfix.zip")); var downloadPath = Path.Combine(rootDir, "DummyFile.nupkg"); Assert.Throws <Exception>(() => NuGetFileSystemDownloader.DownloadPackage("Acme.Core", new SemanticVersion("1.0.0.0-bugfix"), new Uri(rootDir), downloadPath) ); FileAssert.DoesNotExist(downloadPath); }
public void FileAssertsTest() { FileInfo fileInfo1 = new FileInfo(@"D:\development\Text1.txt"); FileInfo fileInfo2 = new FileInfo(@"D:\development\Text2.txt"); FileAssert.AreEqual(fileInfo1, fileInfo2); FileAssert.AreNotEqual(fileInfo1, new FileInfo(@"D:\Recovery.txt")); FileAssert.Exists(fileInfo1); FileAssert.DoesNotExist(new FileInfo(@"D:\development\Text3.txt")); }
public void TestCleaningIfSomethingExists() { ObjectCache.Instance.SetObject("testObj", new TestObject { Prop1 = "test", Prop2 = 1234 }); FileAssert.Exists(actualPath); ObjectCache.Instance.Clear(); FileAssert.DoesNotExist(actualPath); }
public void RemoveDocument_deleteDocument_true() { var sutFielService = new FileService(); var path = "C:/temp/testfile.txt"; File.Create(path).Dispose(); sutFielService.RemoveDocumentOnSource(path); FileAssert.DoesNotExist(path); }
public void Test3() { string[] arr = { "Mein", "dritter", "Test" }; var id = Utils.SpeichereObj(arr); var filename = Utils.BuildFileName(id); FileAssert.Exists(filename); Utils.DeleteObj(id); FileAssert.DoesNotExist(filename); }
public void IsCreatingLogFileWithDateRollingStyleIfFileDoesNotExists() { // Arrange var rollingFileSink = new RollingFileSink(new DirectoryInfo(_logsDirectoryPath), RollingStyle.Date); // Assert FileAssert.DoesNotExist(_rollingStyleDateLogFilePath); rollingFileSink.Write("Message"); FileAssert.Exists(_rollingStyleDateLogFilePath); }
public void TestCreatePdf() { var fileName = Path.Combine(TestHelper.TempPath, "TextPdf.pdf"); if (File.Exists(fileName)) { File.Delete(fileName); } FileAssert.DoesNotExist(fileName); var st = new StructuredText(); st.AddHeader1("Überschrift 1"); st.AddParagraph(TestHelper.Masstext1); var code = FileHelper.GetTextResource("code1.txt"); st.AddCode(code); st.AddParagraph(TestHelper.Masstext1); st.AddDefinitionListLine("Left1", "Right1"); st.AddDefinitionListLine("Left2", "Right2"); st.AddDefinitionListLine("Left3", "Right3"); st.AddDefinitionListLine("Left4", "Right4"); st.AddParagraph(TestHelper.Masstext1); st.AddTable("Tabelle", TestHelper.GetDataTable()); st.AddHeader1("Überschrift 2"); st.AddDefinitionListLine("Left1", "Right1"); st.AddDefinitionListLine("Left2", "Right2"); st.AddDefinitionListLine("Left3", "Right3"); st.AddDefinitionListLine("Left4", "Right4"); var f = new PdfTextFormatter { Title = "Testreport", StructuredText = st, DateString = $"Date created: {DateTime.Now:G}", Author = "Testautor" }; f.GetFormattedText(); f.SaveAsFile(fileName); FileAssert.Exists(fileName); TestHelper.OpenFile(fileName); }
public void PageGenerator_WithIgnoredFiles_IncludesCorrectlyButDoesntCopyIgnoredFileToDestination(string ignoredFilePath) { var p1 = PageGenerator.NewPage("Include.html", $"<include src=\"{ignoredFilePath}\"/>"); var p2 = PageGenerator.NewPage(ignoredFilePath, k_TestPage_1); PageGenerator.RenderToFile(); FileAssert.Exists(p1.DestinationHtmlPath); FileAssert.DoesNotExist(p2.DestinationHtmlPath); Assert.AreEqual(k_TestPage_1, p1.RenderedHtml, "Html differ"); }
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 Should_Delete_File_When_Starting_To_Track() { var existingFile = m_TestDirectory + "/Parent/Existing.txt"; Directory.CreateDirectory(m_TestDirectory + "/Parent"); File.WriteAllText(existingFile, "hello world"); using (var tracker = new TemporaryFileTracker()) { tracker.TrackFile(existingFile); FileAssert.DoesNotExist(existingFile); } }
public void FileService_RemoveDocument_DeletseDocument() { // Arrange var fileService = new FileService(); const string path = "C:/temp/testfile.txt"; // Act File.Create(path).Dispose(); fileService.RemoveDocumentOnSource(path); // Assert FileAssert.DoesNotExist(path); }
public void AllFiles() { _extractor.Directories = false; _extractor.Pattern = "*"; _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.Exists(Path.Combine(_outDir.FullName, "blah2.txt")); }
public void BuildAssetBundles_WhenBuildLogProvided_DoesNotCreatePerformanceLogReport() { IBundleBuildParameters buildParameters = GetBuildParameters(); IBundleBuildContent buildContent = GetBundleContent(); IBundleBuildResults results; var taskList = DefaultBuildTasks.Create(DefaultBuildTasks.Preset.AssetBundleCompatible); ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out results, taskList, new BuildLog()); string tepBuildLog = buildParameters.GetOutputFilePathForIdentifier("buildlogtep.json"); FileAssert.DoesNotExist(tepBuildLog); }
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 DeleteFiles_fileNamesListAndDirPath_filesDeletedAndReturnSize() { FileRemover fileRemover = new FileRemover(); long fSize = fileRemover.DeleteFiles(delFiles, dirPath); Assert.Multiple(() => { FileAssert.DoesNotExist(Path.Combine(dirPath, file1)); FileAssert.DoesNotExist(Path.Combine(dirPath, file2)); FileAssert.DoesNotExist(Path.Combine(dirPath, file3)); Assert.GreaterOrEqual(fSize, 0); }); }
public void RobustDelete_NotLocked_Deletes_NoException() { using (var tempFolder = new TemporaryFolder("RobustDelete01")) { var fileName = Path.Combine(tempFolder.Path, "not_locked.txt"); FileAssert.DoesNotExist(fileName); File.WriteAllText(fileName, @"temp file"); FileAssert.Exists(fileName); Assert.DoesNotThrow(() => FileSystemUtils.RobustDelete(fileName)); FileAssert.DoesNotExist(fileName); } }
public void TestStoreMatches() { string storeFile = _testStoresTarget + "//storetest.json"; FileAssert.DoesNotExist(storeFile); IMatchDataStore sut = new MatchDataStore(storeFile); IEnumerable <IMatch> matchesToStore = new List <IMatch> { new MatchBuilder().WithKills(1).WithRank(1).WithScore(1).WithId(1).WithMode(GameMode.Solo).WithPerspective(GamePerspective.FPP).Build(), new MatchBuilder().WithKills(2).WithRank(2).WithScore(2).WithId(2).WithMode(GameMode.Solo).WithPerspective(GamePerspective.FPP).Build(), new MatchBuilder().WithKills(3).WithRank(3).WithScore(3).WithId(3).WithMode(GameMode.Solo).WithPerspective(GamePerspective.FPP).Build() }; sut.StoreMatches(matchesToStore); FileAssert.Exists(storeFile); FileAssert.AreEqual(new FileInfo(TestContext.CurrentContext.TestDirectory + "//TestFiles/Stores/storetest_assert.json"), new FileInfo(storeFile)); }
public void CanAddAndRemoveSchemaObjectByGenericType() { var group = Settings.CreateGroup("TestGroup", false, false, false, null); var s = group.AddSchema <CustomTestSchema>(); Assert.IsNotNull(s); string guid; long lfid; Assert.IsTrue(AssetDatabase.TryGetGUIDAndLocalFileIdentifier(s, out guid, out lfid)); var path = AssetDatabase.GUIDToAssetPath(guid); FileAssert.Exists(path); Assert.IsTrue(group.RemoveSchema <CustomTestSchema>()); FileAssert.DoesNotExist(path); }
public void Delete_should_remove_entity() { var testClass = new TestClass { Id = 1, Name = "Test name", Description = "Test Description" }; _fileStorage.Store(testClass); FileAssert.Exists(_basePath + @"\TestClass\1"); _fileStorage.Delete(testClass); _fileStorage.Load <TestClass>(1).Should().BeNull(); FileAssert.DoesNotExist(_basePath + @"\TestClass\1"); }
public void ExecuteWorkDirTest() { using (var tempDir = TempDirectory.Create()) using (var runtime = new PowerShellRuntime("ExecuteWorkDirTest")) { var outPath = "workDirTest.txt"; FileSystem.DeleteFile(outPath); FileAssert.DoesNotExist(outPath); runtime.Execute($"'test' | Out-File workDirTest.txt"); FileAssert.Exists(outPath); outPath = Path.Combine(tempDir.TempPath, outPath); FileSystem.DeleteFile(outPath); FileAssert.DoesNotExist(outPath); runtime.Execute($"'test' | Out-File workDirTest.txt", tempDir.TempPath); FileAssert.Exists(outPath); } }