protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); var commLayer = new CommLayer(); var commHandler = new CommHandler(commLayer); /* var blah = RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(blah); GlobalStaticVars.StaticRole = new Core(commHandler); ChatMessage msg = new ChatMessage(new DateTime(2012, 12, 18), "Llamautomatic", "This is a test message, generated at server-mock level"); mockServer.Raise(m => m.MessageSent += null, new ChatEventArgs(msg)); msg = new ChatMessage(new DateTime(2013, 11, 19), "Webs", "This is another test message"); mockServer.Raise(m => m.MessageSent += null, new ChatEventArgs(msg)); */ commLayer.Connect(Properties.Settings.Default.ServerIP, Properties.Settings.Default.ServerPort, Properties.Settings.Default.ServerPassword); GlobalStaticVars.StaticRole = new Core(commHandler); }
public void CommHandlerTest_Constructor_NullParams() { // Create objects var commHandler = new CommHandler(); // Check for empty CommHandler reference in Core Assert.AreEqual(commHandler.CommLayer, null); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); GlobalStaticVars.StaticCommLayer = new CommLayer(); var commHandler = new CommHandler(GlobalStaticVars.StaticCommLayer); GlobalStaticVars.StaticCore = new Core(commHandler); }
public void FullCoreTest_SendMessage() { var mockServer = new Mock<IServerMock>(); var commLayer = new CommLayer(mockServer.Object); var commHandler = new CommHandler(commLayer); Core c = new Core(commHandler); ChatMessage msg = new ChatMessage(new DateTime(2012, 12, 18), "Llamautomatic", "This is a test message"); mockServer.Raise(m => m.MessageSent += null, new ChatEventArgs(msg)); Queue<ChatMessage> msgList = c.GetMessageQueue(); ChatMessage msgResult = msgList.Dequeue(); Assert.AreEqual(msgResult.Speaker, msg.Speaker); Assert.AreEqual(msgResult.Timestamp, msg.Timestamp); Assert.AreEqual(msgResult.Text, msg.Text); }
public void CommHandlerTest_Constructor_ValidParams() { // Create objects var mockCommLayer = new Mock<ICommLayer>(); var commHandler = new CommHandler(mockCommLayer.Object); // Subscribe to CommHandler bool raised = false; commHandler.CoreListener += delegate { raised = true; }; // Raise MessageSent event in Server ChatMessage msg = new ChatMessage(new DateTime(2012, 12, 18), "Llamautomatic", "This is a test message"); mockCommLayer.Raise(m => m.CommHandler += null, new ChatEventArgs(msg)); // Check if CommHandler was successfully raised in response Assert.IsTrue(raised); }
/// <summary> /// Constructs an instance of Core /// Registers handlers to catch ChatMessage events /// </summary> public Core() { CommHandler = new CommHandler(); CommHandler.CoreListener += MessageHandler; MessageQueue = new Queue<ChatMessage>(); ServerMessages = new Dictionary<string, DateTime>(); // Create chatMessage table if it does not exist var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString")); var tableClient = storageAccount.CreateCloudTableClient(); MessageTable = tableClient.GetTableReference("chatMessages"); MessageTable.CreateIfNotExists(); // Create log table if it does not exist LogTable = tableClient.GetTableReference("serverLogs"); LogTable.CreateIfNotExists(); // Create cred table if it does not exist CredTable = tableClient.GetTableReference("serverSettings"); CredTable.CreateIfNotExists(); }