0

I am trying to test a generic method but NUnit gives System.InvalidOperationException ... ContainsGenericParameters is true.

I am using Microsoft.VisualStudio.QualityTools.UnitTestFramework

There is the test code:

[Test]
    [Category("Private")]
    public async void TestConfirmedSendAsync()
    {
        var privProxy = new PrivateObject(_proxy);
        var task = (Task)privProxy.Invoke("ConfirmedAsyncTask");
        await task;
    }

And the method call is:

private async Task ConfirmedSendAsync<T>()

How can I make the generic call?

The only way I could make it (without breaking private) is by creating private methods for each type I need...

private async Task ConfirmedSendStringAsync() { await ConfirmedSendAsync<string>();}

And the test:

[Test]
    [Category("Private")]
    public async void TestConfirmedSendAsync()
    {
        var privProxy = new PrivateObject(_proxy);
        var task = (Task)privProxy.Invoke("ConfirmedAsyncTaskString");
        await task;
    }

0 Answers0