Пример #1
0
        public void CreateInstancesIgnoresFilesNotInCnfFormat()
        {
            // Call method.
            var instances = LingelingUtils.CreateInstances(this._instanceFolder, 1, 42);

            // Check that no non-cnf file has been translated into an instance.
            var instancePaths = instances.Select(instance => instance.Path);

            instancePaths.Any(path => LingelingUtilsTests.NonCnfFileNames.Any(file => path.Contains(file)))
            .ShouldBeFalse("Not all non-cnf files have been ignored.");
        }
Пример #2
0
        public void CreateInstancesCorrectlyExtractsPathsToCnfFiles()
        {
            // Call method.
            var instances = LingelingUtils.CreateInstances(this._instanceFolder, 1, 42);

            // Check that file names of instances match the complete paths of all .cnf files.
            var expectedPaths = LingelingUtilsTests.CnfFileNames.Select(name => new FileInfo(Path.Combine(this._instanceFolder, name)).FullName);
            var instancePaths = instances.Select(instance => new FileInfo(instance.Path).FullName);

            instancePaths.ShouldBe(
                expectedPaths,
                true,
                $"{TestUtils.PrintList(instancePaths)} should have been equal to {TestUtils.PrintList(expectedPaths)}.");
        }
Пример #3
0
 public void CreateInstancesPrintsMessageIfItCannotOpenFolder()
 {
     TestUtils.CheckOutput(
         action: () =>
     {
         // Call CreateInstances with a non existant directory path.
         try
         {
             LingelingUtils.CreateInstances("foobarFolder", 1, 42);
         }
         catch (DirectoryNotFoundException)
         {
             // This is expected.
         }
     },
         check: consoleOutput =>
     {
         // Check that information about it is written to console.
         StringReader reader = new StringReader(consoleOutput.ToString());
         reader.ReadLine().ShouldContain("foobarFolder", "The problematic path did not get printed.");
         reader.ReadLine().ShouldBe("Cannot open folder.", "Cause of exception has not been printed.");
     });
 }
Пример #4
0
 public void CreateInstancesThrowsExceptionIfItCannotOpenFolder()
 {
     Exception exception =
         Assert.Throws <DirectoryNotFoundException>(
             () => { LingelingUtils.CreateInstances("foobarFolder", 1, 42); });
 }