jeudi 2 mai 2019

BadImageFormatException when testing AutoCAD API with NUnit

I created a DLL library for AutoCAD, using AutoCAD API. Now I'm creating another project in the same Visual Studio solution so I can unit test some methods I created for the library.

I created the project and installed NUnit 3.11

I created I class with a method which calls a method from the AutoCAD plugin project. When executing the tests I get ´System.BadImageFormatException´ trying to load ´Acdbmgd, Version=22.0.0.0´ even if I import it to the testing project.

I saw this post BadImageFormatException thrown when running NUnit tests on TeamCity with a similar problem. I tried changing the project's configuration from AnyCPU to x86, but I still get that error.

namespace UnitTesting {
    [TestFixture]
    public class UnitTesting {

        [TestCase("80", true)]
        [TestCase("240", true)]
        [TestCase("0", false)]
        [TestCase("33", false)]
        [TestCase("5", false)]
        [TestCase("-10", false)]
        [TestCase("text", false)]
        public void CorrectDiamTest(string value, bool result) {
            bool myCalc = Main.CorrectDiam(value);
            Assert.That(myCalc, Is.EqualTo(result));
        }

    }
}

Aucun commentaire:

Enregistrer un commentaire