コード例 #1
0
 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);
     }
 }
コード例 #2
0
        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));
            }
        }
コード例 #3
0
        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);
            }
        }