Question

Under one Solution two projects, one Main, second UnitTestMain.

From project UnitTestMain need to call a method and pass somehow #define TEST to be processed.

Project UnitTestMain:

#define TEST
using System;
namespace UnitTest
{
    [TestClass]
    public class UnitTest
    {
        private Calculate calc = new Calculate();

        [TestMethod]
        public void Test()
        {
            calc.test());

        }
    }
}

Project Main

public bool test()
        {
            bool ok;
#if TEST
            ok = true;
#else
            ok = false;
#endif
        }

Method test return: false. But need true.

Was it helpful?

Solution

You need to go to the project properties you compile and :

enter image description here

define your TEST inside that field. The field is Conditional compilation symbols.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top