First Create a void method with a ref parameter in your Class Library Solution.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1
{
public class Class1
{
public void methodRef(ref int refvalue)
{
refvalue= refvalue + refvalue;
}
}
}
Out goal is to test this void method in unit test.
Calling the methodRef in Test Class.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ClassLibrary1;
namespace UnitTestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMetod3()
{
int refvalue = 10;
ClassLibrary1.Class1 obj = new ClassLibrary1.Class1();
obj.methodRef(ref refvalue);
int actualvalue = refvalue;
Assert.AreEqual(20, actualvalue);
}
}
}
Build the solution and Run TestMethod3. It will give the actual Result as 20 and Expected Result as 20.