示例#1
0
        public void GenerateRandomRules1()
        {
            string jsonRaw = System.IO.File.ReadAllText("testinput1.json");

            //seed random
            DataGen dg = new DataGen(1345678);

            var            dataSchemaFileContent = JsonConvert.DeserializeObject <DataSchema>(jsonRaw);
            List <JObject> dataStreams           = new List <JObject>();

            dg.GenerateRandomData(dataStreams, dataSchemaFileContent.dataSchema[0]);
            dg.GenerateDataRules(dataStreams, dataSchemaFileContent.dataSchema[0], 1);
            DateTime now = DateTime.Now;

            dataStreams[0]["sensordetails"]["timestamp"] = now;

            JObject expectedData = JsonConvert.DeserializeObject <JObject>(System.IO.File.ReadAllText("testrulesexpecteddata1.json"));

            expectedData["sensordetails"]["timestamp"] = now;

            //Assert.AreEqual(expectedData, dataStreams[0]);

            Assert.IsTrue(JToken.DeepEquals(expectedData, dataStreams[0]));
        }