Hi, I would like to test this static method:
I am implementing the test like this:public static class UnitOfWorkExtensions
{
public static void SetSubCategory(this IOperationTracer tracer, string subCategory)
{
UnitOfWork unitOfWork = UnitOfWork.Current;
if (unitOfWork != null && unitOfWork.CorrelationId != null)
{
tracer.SetSubCategory(UnitOfWork.Current.CorrelationId, subCategory);
}
}
}
The test is failing and I don't have a clue why[TestMethod]
public void SetSubCategoryTest()
{
Mock.SetupStatic(typeof(UnitOfWorkExtensions));
IOperationTracer operationTracer = Mock.Create<
OperationTracer
>();
Mock.Arrange(() => operationTracer.SetSubCategory(null, "subCategory")).DoNothing().OccursNever();
UnitOfWorkExtensions.SetSubCategory(operationTracer, "subCategory");
Mock.Assert(operationTracer);
UnitOfWork.Current = new UnitOfWork();
UnitOfWork.Current.CorrelationId = "11111";
Mock.Arrange(() => operationTracer.SetSubCategory(null, "subCategory")).DoNothing().OccursOnce();
UnitOfWorkExtensions.SetSubCategory(operationTracer, "subCategory");
Mock.Assert(operationTracer);
}