Added RedirectUsingNamedRoute
[castle.git] / Core / Castle.Core.Tests / DiagnosticsLoggerTestCase.cs
blob688bbdc075a1f9dff6a31a5b98b69c3f2970c331
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Core.Logging.Tests
17 using System;
18 using System.Diagnostics;
19 using System.Security.Principal;
20 using NUnit.Framework;
22 [TestFixture]
23 public class DiagnosticsLoggerTestCase
25 [SetUp]
26 public void Clear()
28 AssertAdmin();
29 if (EventLog.Exists("castle_testlog"))
31 EventLog.Delete("castle_testlog");
35 private void AssertAdmin()
37 WindowsPrincipal windowsPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
38 if(windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator)==false)
40 Assert.Ignore("This test case only valid when running as admin");
44 [Test]
45 public void SimpleUsage()
47 DiagnosticsLogger logger = new DiagnosticsLogger("castle_testlog", "test_source");
49 logger.Warn("my message");
50 logger.Error("my other message", new Exception("Bad, bad exception"));
52 EventLog log = new EventLog();
53 log.Log = "castle_testlog";
54 log.MachineName = ".";
56 Assert.AreEqual(2, log.Entries.Count);
58 logger.Close();