public void Test_Ctor_NoArgs() { using (FailOnEventAttribute failOnEventAttribute = new FailOnEventAttribute()) { Assert.That(failOnEventAttribute, Has.Property("EventLog").EqualTo(EDC.ReadiNow.Diagnostics.EventLog.Application)); Assert.That(failOnEventAttribute, Has.Property("FailingLevels").Not.Null); } }
public void Test_Ctor_Args() { IEventLog eventLog; EventLogLevel[] failureLevels; eventLog = new Mock <IEventLog>().Object; failureLevels = new[] { EventLogLevel.Information }; using (FailOnEventAttribute failOnEventAttribute = new FailOnEventAttribute(eventLog, failureLevels)) { Assert.That(failOnEventAttribute, Has.Property("EventLog").EqualTo(eventLog)); Assert.That(failOnEventAttribute, Has.Property("FailingLevels").EqualTo(failureLevels)); } }
public void Test_CustomFailsTest() { IEventLog eventLog; eventLog = EDC.ReadiNow.Diagnostics.EventLog.Application; using (FailOnEventAttribute failOnEventAttribute = new FailOnEventAttribute(new[] { EventLogLevel.Warning })) { failOnEventAttribute.BeforeTest(null); Assert.That(() => eventLog.WriteTrace("Test"), Throws.Nothing); Assert.That(() => eventLog.WriteInformation("Test"), Throws.Nothing); Assert.That(() => eventLog.WriteWarning("Test"), Throws.TypeOf <AssertionException>()); Assert.That(() => eventLog.WriteError("Test"), Throws.Nothing); failOnEventAttribute.AfterTest(null); } }