Есть ли какой-либо способ утверждать правильное поведение метода?
I have a method that i need to test all of its branches. I can't find a way to assert the or verify the test is correct because both branches have almost the same behavior. btw - I can't change the given code I have tried verifying End and Write are called but they are being called in both scenarios. if (m_FailedOnInitialize) { if (!ctx.Request.IsLocal) { ctx.Response.Write("Failed on initialization"); ctx.Response.End(); } else { ctx.Response.Write(m_FirstError.ToString()); ctx.Response.End(); } }
Что я уже пробовал:
*m_FailedOnInitialize Is Static field, i set it to be "true" ctx.Request.IsLocal is set to be true\false in each test To assert the behavior i use Typemock's verification Isolate.Verify.WasCalled(() => ctx.Response.write("")); Isolate.Verify.WasNotCalled(() => ctx.Response.End());