jeudi 18 avril 2019

C# reference to the method in external DLL returns an error

I am using NUnit to test a DLL developed by another group but have errors when trying to call a method in this external DLL which was set as reference in my test project. The error is: 'UT' is a namespace but is used like a type. I tried several ways but no one is working. How can I reference it correctly?

The method I try with this one worked with another class I developed, when the latter was in the same namespace. Now, with the external DLL, it simply shows error before the compile.

This is my procedure:

using NUnit.Framework;

namespace UnitTesting.GettingStarted.Tests
{

    [TestFixture]
    public class TestUT
     {
        [TestCase("A12345", "CII", "10000")]

public void TestAccessVerification(string psCodeUsager, string psCodeApp, string psCodeFonction)
        {
            UT systemUnderTest = new UT();
            Assert.IsTrue(systemUnderTest.VerifierAcces(psCodeUsager, psCodeApp, psCodeFonction));
        }
    }
}

The source code in the DLL is something like this:

using ...;

namespace GZM
{
    public class UT
    {
        public static bool VerifierAcces(string psCodeUsager, string psCodeApp, string psCodeFonction)
        {
            ... // returns true or false
        {
    {        
{

The error happens at the line:

UT systemUnderTest = new UT();

where both 'UT' are underlined with an error 'UT' is a namespace but is used like a type.

But, if I go with:

var systemUnderTest = new GZM.UT();

the error will happen in the next line and

systemUnderTest.VerifierAcces

will be underlined with the message "Member 'UT.VerifierAcces(string, string, string) cannot be accessed with an instance reference; qualify it with a type name instead."

Normally, my test should work and return True, but I cannot even start it because of the errors in the calling procedure.

Aucun commentaire:

Enregistrer un commentaire