Exemplo n.º 1
0
        public void SeedsToUseReturnsCorrectNumberOfSeeds()
        {
            var numberOfSeeds = 6;
            var seedsToUse    = LingelingUtils.SeedsToUse(numberOfSeeds, 42);

            seedsToUse.Count().ShouldBe(numberOfSeeds);
        }
Exemplo n.º 2
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.");
        }
Exemplo n.º 3
0
 public void CreateParameterTreeThrowsNoException()
 {
     try
     {
         var parameterTree = LingelingUtils.CreateParameterTree();
     }
     catch (Exception exception)
     {
         Assert.True(false, $"Exception: {exception.Message}");
     }
 }
Exemplo n.º 4
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)}.");
        }
Exemplo n.º 5
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.");
     });
 }
Exemplo n.º 6
0
 public void CreateInstancesThrowsExceptionIfItCannotOpenFolder()
 {
     Exception exception =
         Assert.Throws <DirectoryNotFoundException>(
             () => { LingelingUtils.CreateInstances("foobarFolder", 1, 42); });
 }