I want to put a Debug Assert into a function that I am giving to programmers so they make sure to pass the correct information into the routine when they code against it. The problem is I want my test to be able to see that the assert happens. The code in the routine will handle the invalid parameter correctly if it is compiled as is and sent to a user and the user will not get the assert because they get the released version.
What I want to do is have my tests run without the assert screen getting show while when the programmer runs it in the actual code, it gives them the assertion.
What I have done so far is:
The Assert screen still comes up. I am not sure what I am missing in this process. Can you guys help me out here? Is this something that is possible or do I just have to remove the assert and throw an exception instead?
David Parvin
What I want to do is have my tests run without the assert screen getting show while when the programmer runs it in the actual code, it gives them the assertion.
What I have done so far is:
using
System.Diagnostics;
[ClassInitialize()]
public
static
void
MyClassInitialize(
TestContext testContext)
{
Mock.Initialize(
typeof
(Debug));
Mock.Partial(
typeof
(Debug)).For<
bool
,
string
>((i, j) => Debug.Assert(i, j));
}
public
void
Test()
{
Mock.Arrange(() => Debug.Assert(Arg.AnyBool, Arg.AnyString)).DoNothing();
DoSomeFunctionThatAsserts();
}
The Assert screen still comes up. I am not sure what I am missing in this process. Can you guys help me out here? Is this something that is possible or do I just have to remove the assert and throw an exception instead?
David Parvin