public void CommandValidation_ValidateEmptyString_ReturnFalse()
        {
            string json = String.Empty;

            CommandValidation validation = new CommandValidation();

            Assert.AreEqual(validation.Validation(json), false);
        }
        public void CommandValidation_ValidateExampleJson_ReturnTrue()
        {
            const string json =
                "{\"CommandName\":\"delete\",\"Parameters\":[{\"Key\":\"name\",\"Value\":\"\"},{\"Key\":\"value\",\"Value\":\"\"}]}";

            CommandValidation validation = new CommandValidation();

            Assert.AreEqual(validation.Validation(json), true);
        }
Beispiel #3
0
        public ActionResult Index(string deviceId, string command)
        {
            RabbitQueue rabbit = new RabbitQueue();
            CommandValidation validation = new CommandValidation();

            if (validation.Validation(command))
            {
                rabbit.Producer(deviceId, command);
                rabbit.CreateTimeout(deviceId);
                if (LongPolling.Connections.Contains(deviceId))
                    LongPolling.JsonStrings[deviceId] = (rabbit.Consumer(deviceId));
            }
            else
            {
                return new HttpStatusCodeResult(400, "Validation error");
            }
            return new HttpStatusCodeResult(202, "Accepted");
        }