Moved Diagnostics utility under the /Trace folder; added ITraceable interface so...
[lwes-dotnet/github-mirror.git] / Org.Lwes.Tests / EventEmitterTests.cs
blob7bd0545e9da8858c2d2edaf8c4aeb282170e5627
1 namespace Org.Lwes.Tests
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.Net;
7 using System.Text;
8 using System.Threading;
10 using Microsoft.VisualStudio.TestTools.UnitTesting;
12 using Org.Lwes.Emitter;
13 using Org.Lwes.Listener;
15 [TestClass]
16 public class EventEmitterTests
18 #region Fields
20 Random _rand = new Random(Environment.TickCount);
22 #endregion Fields
24 #region Methods
26 [TestMethod]
27 public void AccessDefaultListener()
29 var e = new
31 EventName = "UserLogin",
32 Attributes = new
34 UserName = new { Name = "username", Token = TypeToken.STRING, Value = "bob" },
35 Password = new { Name = "password", Token = TypeToken.UINT64, Value = 0xfeedabbadeadbeefUL },
36 ClientIP = new { Name = "clientIP", Token = TypeToken.IP_ADDR, Value = IPAddress.Parse("127.0.0.1") },
37 Successful = new { Name = "successful", Token = TypeToken.BOOLEAN, Value = false }
41 // Create the event...
42 Event ev = new Event(e.EventName)
43 .SetValue(e.Attributes.UserName.Name, e.Attributes.UserName.Value)
44 .SetValue(e.Attributes.Password.Name, e.Attributes.Password.Value)
45 .SetValue(e.Attributes.ClientIP.Name, e.Attributes.ClientIP.Value)
46 .SetValue(e.Attributes.Successful.Name, e.Attributes.Successful.Value);
48 IEventEmitter emitter = EventEmitter.CreateDefault();
49 Assert.IsNotNull(emitter);
51 emitter.Emit(ev);
54 #endregion Methods