public void CreateInstancesIgnoresFilesNotInMpsFormat() { // Call method. var instances = GurobiUtils.CreateInstances(this._instanceFolder, 1, 42); // Check that no non-mps file has been translated into an instance. var instancePaths = instances.Select(instance => instance.Path); instancePaths.Any(path => GurobiUtilsTests.NonMpsFileNames.Any(file => path.Contains(file))) .ShouldBeFalse("Not all non-mps files have been ignored."); }
public void CreateInstancesCorrectlyExtractsPathsToMpsFiles() { // Call method. var instances = GurobiUtils.CreateInstances(this._instanceFolder, 1, 42); // Check that file names of instances match the complete paths of all .mps files. var expectedPaths = GurobiUtilsTests.MpsFileNames.Select(name => this._instanceFolder + Path.DirectorySeparatorChar + name); var instancePaths = instances.Select(instance => instance.Path); expectedPaths.ShouldBe( instancePaths, 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 { GurobiUtils.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>( () => { GurobiUtils.CreateInstances("foobarFolder", 1, 42); }); }