mardi 27 juin 2017

NUnit Test override Extension C#

I have the following methods that I cannot change

static int A ( string var )
static int A ( this string var )

Since they are defined as static, in order to test them I thought to create public methods that call them like

public static int ATest ( string var )
{
   return A(var);
}
public static int ATestThis ( this string var )
{
   return A(var);
}

And then test them in that way

namespace test.NUnit
{
    [TestFixture]
    public class myFirstTest
    {
        [Test]
        public void TestOnA() {
            Assert.... // with ATest and ATestThis
        }
    }
}

However I obtained these two errors

Type 'Program' already defines a member called A with the same parameter types
The call is ambiguous between the following methods or properties

Do you have any idea?

Aucun commentaire:

Enregistrer un commentaire