Inheritance: ICommHandler
コード例 #1
0
ファイル: Global.asax.cs プロジェクト: jpere/gswat
        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);
        }
コード例 #2
0
        public void CommHandlerTest_Constructor_NullParams()
        {
            // Create objects
            var commHandler = new CommHandler();

            // Check for empty CommHandler reference in Core
            Assert.AreEqual(commHandler.CommLayer, null);
        }
コード例 #3
0
ファイル: Global.asax.cs プロジェクト: ratdart/gswat
        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);
        }
コード例 #4
0
ファイル: FullCoreTest.cs プロジェクト: wrusse3/gswat
 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);
 }
コード例 #5
0
ファイル: CommHandlerTest.cs プロジェクト: wrusse3/gswat
        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);
        }
コード例 #6
0
ファイル: Core.cs プロジェクト: Pure-Battlefield/gswat
        /// <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();
        }