Created
May 18, 2010 18:10
-
-
Save atifaziz/405314 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IronPython 2.6.1 (2.6.10920.0) on .NET 4.0.30319.1 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import clr | |
>>> | |
>>> clr.AddReference('Elmah') | |
>>> from Elmah.Assertions import AssertionFactory | |
>>> from Elmah import ErrorMailModule, ErrorLogModule | |
>>> from Elmah.ErrorFilterModule import AssertionHelperContext | |
>>> | |
>>> clr.AddReference('System.Web') | |
>>> from System.Web import HttpException | |
>>> | |
>>> clr.AddReference('System.Xml') | |
>>> from System.Xml import XmlDocument | |
>>> | |
>>> xml = """ | |
... <or> | |
... <and> | |
... <equal binding="HttpStatusCode" | |
... value="404" type="Int32" /> | |
... <regex binding="FilterSourceType.Name" | |
... pattern="mail" /> | |
... </and> | |
... <and> | |
... <equal binding="Exception.Message" | |
... value="Padding is invalid and cannot be removed." | |
... type="String" /> | |
... <regex binding="FilterSourceType.Name" | |
... pattern="mail" /> | |
... </and> | |
... </or> | |
... """ | |
>>> | |
>>> config = XmlDocument() | |
>>> config.LoadXml(xml) | |
>>> | |
>>> assertion = AssertionFactory.Create(config.DocumentElement) | |
>>> | |
>>> mailmod = ErrorMailModule() | |
>>> logmod = ErrorLogModule() | |
>>> | |
>>> error = HttpException(404, None) | |
>>> context = AssertionHelperContext(mailmod, error, None) | |
>>> print assertion.Test(context) | |
True | |
>>> | |
>>> error = HttpException(500, None) | |
>>> context = AssertionHelperContext(mailmod, error, None) | |
>>> print assertion.Test(context) | |
False | |
>>> | |
>>> error = HttpException('Padding is invalid and cannot be removed.') | |
>>> context = AssertionHelperContext(mailmod, error, None) | |
>>> print assertion.Test(context) | |
True | |
>>> | |
>>> context = AssertionHelperContext(logmod, error, None) | |
>>> print assertion.Test(context) | |
False | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment