public void ConvertToConstraint_ConvertsForCustomWellKnownException() { var attributeData = CompiledSourceFileProvider.CompileAttribute("[ExpectedException(typeof(InvalidOperationException))]"); IExpectedExceptionModel expectedException = new ExpectedExceptionModel(attributeData, ParseExpression("typeof(InvalidOperationException)"), null, null, null); var constraint = expectedException.AsConstraintExpression(""); Assert.That(constraint, Is.EquivalentTo(ParseExpression("Throws.InvalidOperationException"))); }
public void ConvertToConstraint_ConvertsExpectedExceptionMessage() { var attributeData = CompiledSourceFileProvider.CompileAttribute("[ExpectedException(ExpectedMessage = \"Test Message\")]"); IExpectedExceptionModel expectedException = new ExpectedExceptionModel(attributeData, ParseExpression("Exception"), null, ParseExpression("\"Test Message\""), null); var constraint = expectedException.AsConstraintExpression(""); Assert.That(constraint, Is.EquivalentTo(ParseExpression("Throws.Exception.With.Message.EqualTo(\"Test Message\")"))); }
public void ConvertToConstraint_ConvertsForSimpleExceptionCase() { var attributeData = CompiledSourceFileProvider.CompileAttribute("[ExpectedException]"); IExpectedExceptionModel expectedException = new ExpectedExceptionModel(attributeData, IdentifierName("Exception"), null, null, null); var constraint = expectedException.AsConstraintExpression(""); Assert.That(constraint, Is.EquivalentTo(ParseExpression("Throws.Exception"))); }