Esempio n. 1
0
 public void TargetFrameworkDirectories()
 {
     foreach (var dir in XamarinAndroid.TargetFrameworkDirectories)
     {
         DirectoryAssert.Exists(dir);
     }
 }
Esempio n. 2
0
        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");
        }
Esempio n. 3
0
        public void CreateExistingFolder()
        {
            string folder = @"C:\temp";

            DirectoryAssert.Exists(folder);
            Assert.IsFalse(FileSystemHelper.FolderCreation(folder));
        }
Esempio n. 4
0
        public void FindExistingFolder()
        {
            string folder = @"C:\temp";

            DirectoryAssert.Exists(folder);
            Assert.IsTrue(FileSystemHelper.FolderVerification(folder));
        }
Esempio n. 5
0
        public void FolderExists()
        {
            var folder = MakeTempFolder();

            Assert.That(folder.FullPath, Is.Not.Empty);
            DirectoryAssert.Exists(folder.FullPath);
        }
Esempio n. 6
0
        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"));
        }
Esempio n. 7
0
        public void DirectoryExistsTest()
        {
            // Test OK.
            DirectoryAssert.Exists(new DirectoryInfo(@"M:\work\TestA1"));

            // Test OK.
            DirectoryAssert.Exists(@"M:\work\TestA1");
        }
Esempio n. 8
0
        public void CreateNonExistingFolder()
        {
            string folder = @"C:\temp\foldertesting";

            DirectoryAssert.DoesNotExist(folder);
            Assert.IsTrue(FileSystemHelper.FolderCreation(folder));
            DirectoryAssert.Exists(folder);
        }
Esempio n. 9
0
        public void AfterDeleteFolderDoesNotExist()
        {
            var folder = MakeTempFolder();

            DirectoryAssert.Exists(folder.FullPath);
            folder.TryDelete();
            DirectoryAssert.DoesNotExist(folder.FullPath);
        }
Esempio n. 10
0
        public void ResolveNpmRoot()
        {
            var actual = _sut.ResolveNpmRoot();

            Console.WriteLine(actual);
            actual.ShouldNotBeNull();
            DirectoryAssert.Exists(actual);
        }
        public void FindAboveCurrentDirectory()
        {
            Directory.CreateDirectory("foo");
            Directory.CreateDirectory("bar");
            Environment.CurrentDirectory = Path.Combine(Environment.CurrentDirectory, "bar");

            DirectoryAssert.Exists(Helpers.FindDirectory("foo"));
        }
Esempio n. 12
0
        public void DirectoryAssertsTest()
        {
            DirectoryInfo dirInfo1 = new DirectoryInfo(@"D:\development\Folder1");
            DirectoryInfo dirInfo2 = new DirectoryInfo(@"D:\development\Folder2");

            DirectoryAssert.AreNotEqual(dirInfo1, dirInfo2);
            DirectoryAssert.Exists(dirInfo1);
        }
Esempio n. 13
0
 public void Setup()
 {
     // appears to be run before each test
     if (!System.IO.Directory.Exists("TestData"))
     {
         System.IO.Directory.SetCurrentDirectory("..\\..\\..");
     }
     DirectoryAssert.Exists("TestData", "Error: Unable to locate TestData folder.");
 }
Esempio n. 14
0
        public void CanAccessWorkDirectory()
        {
            Assert.NotNull(_fixtureContext.WorkDirectory);
#if !PORTABLE
            DirectoryAssert.Exists(_fixtureContext.WorkDirectory);
#endif
            Assert.That(_setupContext.WorkDirectory, Is.EqualTo(_fixtureContext.WorkDirectory));
            Assert.That(TestExecutionContext.CurrentContext.WorkDirectory, Is.EqualTo(_setupContext.WorkDirectory));
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        public void TestMountUncDir()
        {
            var source = (string)_config.source;
            var target = (string)_config.target;

            _context.CakeContext.MountUncDir(source, target);

            DirectoryAssert.Exists(target);
        }
Esempio n. 17
0
        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");
        }
Esempio n. 18
0
        public void TestConstructorCreatesDirectory()
        {
            if (_cacheDirectory.Exists)
            {
                _cacheDirectory.Delete();
            }
            IImageCache cache = new ImageCache();

            DirectoryAssert.Exists(_cacheDirectory);
        }
Esempio n. 19
0
        public void CreateFolder_Create_True()
        {
            var sut  = new FileService();
            var path = "C:/temp/test";

            sut.CreateValutaFolderIfNotExists(path);

            DirectoryAssert.Exists(path);
            Directory.Delete(path);
        }
Esempio n. 20
0
        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"));
        }
Esempio n. 21
0
        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)));
        }
Esempio n. 22
0
        static void AssertDirectory(string path, int expectedChildCount)
        {
            path = Path.Join(Tmp, path);

            DirectoryAssert.Exists(path);

            var actualChildCount = Directory.GetFileSystemEntries(path).Length;

            Assert.AreEqual(expectedChildCount, actualChildCount);
        }
Esempio n. 23
0
        public void Should_BePossibleTo_SaveFormDump_WithDefaultName()
        {
            var form       = new WebForm();
            var pathToDump = CleanUpAndGetPathToDump(form.Name.Replace("/", " "));

            Assert.DoesNotThrow(() => form.Dump.Save());
            pathToDump.Refresh();
            DirectoryAssert.Exists(pathToDump);
            Assert.Greater(pathToDump.GetFiles().Length, 0, "Dump should contain some files");
        }
Esempio n. 24
0
 public void TestLogWriterAdded()
 {
     if (_log.GetLogWriter(WRITER_NAME) is LogFileWriter writer)
     {
         DirectoryAssert.Exists(writer.LogDirectory);
     }
     else
     {
         Assert.Fail($"LogWriter {WRITER_NAME} is not a LogFileWriter type.");
     }
 }
Esempio n. 25
0
        public void Should_BePossibleTo_SaveFormDump_WithSubfoldersInName()
        {
            var form       = new WebForm();
            var dumpName   = $"SubFolder1\\SubFolder2";
            var pathToDump = CleanUpAndGetPathToDump(dumpName);

            Assert.DoesNotThrow(() => form.Dump.Save(dumpName));
            pathToDump.Refresh();
            DirectoryAssert.Exists(pathToDump);
            Assert.Greater(pathToDump.GetFiles().Length, 0, "Dump should contain some files");
        }
Esempio n. 26
0
 private void ConstructorOutputs(FileSystemAdministrativeTools fsat)
 {
     steamPath     = fsat.SteamPath;
     steamUserId   = fsat.SteamUserId;
     steamUserName = fsat.SteamUserName;
     System.Diagnostics.Trace.WriteLine(steamPath);
     System.Diagnostics.Trace.WriteLine(steamUserId);
     System.Diagnostics.Trace.WriteLine(steamUserName);
     Assert.IsNotEmpty(steamUserName);
     Assert.IsNotEmpty(steamUserId);
     DirectoryAssert.Exists(steamPath);
 }
        public void MultipleTryBuildTest(string folder)
        {
            var testFolder = Path.Combine(TestDataFolder, folder);

            DirectoryAssert.Exists(testFolder);

            var logFiles = Directory.GetFiles(testFolder, "*.txt");

            var capturedPackets = new List <CapturedPacket>();

            foreach (var logFile in logFiles)
            {
                capturedPackets.AddRange(TcpImporterTestUtils.ReadCapturedPackets(logFile, null));
            }

            capturedPackets = capturedPackets.OrderBy(x => x.CreatedTimeStamp).ToList();

            var handHistories = new List <HandHistory>();

            var packetManager    = new PPPokerPacketManager();
            var handBuilder      = new PPPHandBuilder();
            var debugPPPImporter = new DebugPPPImporter();

            foreach (var capturedPacket in capturedPackets)
            {
                if (!packetManager.TryParse(capturedPacket, out IList <PPPokerPackage> packages))
                {
                    continue;
                }

                foreach (var package in packages)
                {
                    if (!PPPImporterStub.IsAllowedPackage(package))
                    {
                        continue;
                    }

                    package.Timestamp = capturedPacket.CreatedTimeStamp;

                    debugPPPImporter.LogPackage(capturedPacket, package);

                    if (handBuilder.TryBuild(package, out HandHistory handHistory))
                    {
                        handHistories.Add(handHistory);
                        LogProvider.Log.Info($"Hand #{handHistory.HandId} has been sent. [{package.ClientPort}]");
                    }
                }
            }

            WriteHandHistoriesToFile(handHistories);

            Assert.IsTrue(handHistories.Count > 0);
        }
        public void FileService_CreateFolder_SuccessfulCreated()
        {
            // Arrange
            var          fileService = new FileService();
            const string path        = "C:/temp/test";

            // Act
            fileService.CreateValutaFolderIfNotExists(path);

            // Assert
            DirectoryAssert.Exists(path);
            Directory.Delete(path);
        }
        public async Task DownloadVizDatasourceFilesAsyncTest()
        {
            var svc     = GetService();
            var options = GetOptions();

            if (Directory.Exists(options.CurrentValue.DatasourceFilesPath))
            {
                Directory.Delete(options.CurrentValue.DatasourceFilesPath, true);
            }
            await svc.DownloadVizDatasourceFilesAsync();

            DirectoryAssert.Exists(options.CurrentValue.DatasourceFilesPath);
        }
        public void DevoCopiarImagens()
        {
            //string destino = CopiarImagens.Executar();
            CopiarImagens.Executar("pastaTeste");

            // Verifica se a pasta com o nome informado pelo usuário existe
            DirectoryAssert.Exists(@"C:/pastaTeste");

            // Verifica se as imagens foram copiadas
            DirectoryInfo di = new DirectoryInfo(@"C:/pastaTeste");

            Assert.That(di.GetFiles().Length > 0);
        }