Sirmais
Sirmais

Reputation: 128

C# UnitTest Method Result

I would like to test this method using UnitTest, but I have no clue how to approach to this return type even the method does not make sens or anything

public Result ChangeVoucherStatus(long[] voucherIDs, GenericStatus newStatus, Context context)
{
    ... 
    return new Result(true, resMsg);
}

I am using Visual Studio 2012 and NUnit test adapter Any suggestions?

I have tested the void methods but this scared me.

Upvotes: 0

Views: 184

Answers (1)

Ruben de la Fuente
Ruben de la Fuente

Reputation: 695

with xunit

You can do something like that

[Fact]
public void TestChangeVoucherStatus(){

   var vocherIDs = ...;
   var newStatus = ...;
   var context = ...;

   var result = ChangeVoucherStatus(voucherIDs, newStatus, context);

   Assert.Equal(result.resMsg, "")

}

with nunit

[TestFixture]
class Test {
    [Test]
    public void TestChangeVoucherStatus(){

       var vocherIDs = ...;
       var newStatus = ...;
       var context = ...;

       var result = ChangeVoucherStatus(voucherIDs, newStatus, context);

       Assert.Equal(result.resMsg, "")

    }
...
}

Upvotes: 4

Related Questions