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