Example #1
0
        public void BbobRunnerReturnsCorrectResult(int functionId, int instanceSeed, double x0, double x1, double x2, double expectedResult)
        {
            Assert.True(File.Exists(PythonBinary), "The python binary cannot be found. Please adopt its path in BbobRunnerTests.cs.");

            var parameters = new Dictionary <string, IAllele>();

            parameters["x0"] = new Allele <double>(x0);
            parameters["x1"] = new Allele <double>(x1);
            parameters["x2"] = new Allele <double>(x2);
            var bbobRunner = new BbobRunner(functionId, parameters, BbobRunnerTests.PythonBinary, BbobRunnerTests.BbobScript);

            var instance = BbobRunnerTests.CreateInstanceFile(instanceSeed);

            var runnerTask = bbobRunner.Run(instance, CancellationToken.None);

            runnerTask.Wait();
            var result = runnerTask.Result;

            result.Value.ShouldBe(expectedResult, "Expected different result.");
        }
Example #2
0
        public void BbobRunnerReturnsCorrectResult(int functionId, int instanceSeed, double x0, double x1, double x2, double expectedResult)
        {
            // Skip, if no python 2.7 binary was resolved.
            Skip.IfNot(TestUtils.TryToResolvePython27BinaryFromPath(out var pythonBinary));

            var parameters = new Dictionary <string, IAllele>
            {
                ["x0"] = new Allele <double>(x0),
                ["x1"] = new Allele <double>(x1),
                ["x2"] = new Allele <double>(x2),
            };
            var bbobRunner = new BbobRunner(functionId, parameters, pythonBinary.FullName, BbobRunnerTests.BbobScript);

            var instance = BbobRunnerTests.CreateInstanceFile(instanceSeed);

            var runnerTask = bbobRunner.Run(instance, CancellationToken.None);

            runnerTask.Wait();
            var result = runnerTask.Result;

            result.Value.ShouldBe(expectedResult, "Expected different result.");
        }
Example #3
0
 /// <inheritdoc/>
 public void Dispose()
 {
     BbobRunnerTests.DeleteInstanceFile();
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BbobRunnerTests"/> class.
 /// Behaves like the [TestInitialize] of MSTest framework.
 /// </summary>
 public BbobRunnerTests()
 {
     BbobRunnerTests.DeleteInstanceFile();
 }