public void BadMessageIsIgnored()
        {
            int requestReceived = 0;
            string badMessage = "ha ha, not a Json request!";
            FakeWebsocket w = new FakeWebsocket();
            IRequestManager totest = new JsonLayer(w);
            totest.OnRequest += (sender, message) => requestReceived++;
            //Test when we receive shitty data
            w.SimulateReceived(badMessage);

            Assert.AreEqual(0, requestReceived);
        }
Example #2
0
 static void Main(string[] args)
 {
     logger.Info("Starting application");
     projectManager = new ProjectManager(new FilePersister());
     IWebsocket connection = new RequestFlickerService("SplitonSync");
     IRequestManager requestManager = new JsonLayer(connection);
     requestManager.OnRequest += ProducerOnOnRequest;
     while (true)
     {
         Thread.Sleep(300000);
         NLog.LogManager.GetCurrentClassLogger().Info("I am still alive!(Providing some infos here...)");
     }
 }
        public void GoodRequestIsForwarded()
        {
            var requestReceived = new RequestMessage();

            FakeWebsocket w = new FakeWebsocket();
            IRequestManager totest = new JsonLayer(w);
            totest.OnRequest += (sender, message) => requestReceived = message;
            //Test when we receive good data
            var synchRequest = new SplitonSynchRequest();
            synchRequest.lastUpdated = DateTime.Parse("2000-02-02").JavascriptTicks();
            synchRequest.projectId = "projectwq";
            synchRequest.toUpdate = new List<UpdatableElement>() { GetFakeTransaction(1) };
            var request = new RequestMessage();
            request.id = 12;
            request.request = synchRequest;
            string serializeRequest = JsonConvert.SerializeObject(request);
            Write("Simulating a string request from websocket connection ...");
            w.SimulateReceived(serializeRequest);

            Assert.AreEqual(request.id, requestReceived.id);
            Assert.AreEqual(request.request.lastUpdated, requestReceived.request.lastUpdated);
            Assert.AreEqual(request.request.projectId, requestReceived.request.projectId);
            Assert.AreEqual(request.request.toUpdate, requestReceived.request.toUpdate);
        }