public void TestDataUpdate()
        {
            Device device = new Device();
            device.Name = "TestDataUpdate" + new Random().Next();
            device.Working = true;
            devRep.Save(device);

            Data data = new Data();
            data.Name = "TestDataUpdate";
            data.Timestamp = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0)).Seconds;
            data.Value = new Random().Next();
            data.Device = device;
            dataRep.Save(data);

            string newName = "newName";
            long newTs = 1234;
            double value = 12345;
            data.Name = newName;
            data.Timestamp = newTs;
            data.Value = value;
            dataRep.Update(data.Id, data);


            Data another = dataRep.GetById(data.Id);
            Assert.AreEqual(newName, another.Name);
            Assert.AreEqual( newTs, another.Timestamp);
            Assert.AreEqual(value, another.Value);
        }
 public static Data GetData()
 {
     Data res = new Data();
     res.Name = "GeneratedData" + RandomIntModifier();
     res.Timestamp = RandomIntModifier();
     res.Value = RandomIntModifier();
     return res;
 }
 public static DataDTO Convert(Data from)
 {
     DataTypeDTO t = new DataTypeDTO();
     t.Id = 1;
     t.Name = "Temperature";
     DataDTO res = new DataDTO();
     res.Id = from.Id;
     res.Name = from.Name;
     res.Timestamp = from.Timestamp;
     res.Value = from.Value;
     res.Type = t;
     return res;
 }
        public void TestDataSave()
        {
            Device device = new Device();
            device.Name = "TestDataSave" + new Random().Next();
            device.Working = true;
            devRep.Save(ref device);

            Data data = new Data();
            data.Name = "TestDataSave1";
            data.Timestamp = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0)).Seconds;
            data.Value = new Random().Next();
            data.Device = device;
            dataRep.Save(ref data);

            Data another = dataRep.GetById(data.Id);

            Assert.AreEqual(another.Device.Id, data.Device.Id);

            foreach (var cur in device.Data)
                Assert.AreEqual(another.Id, cur.Id);
        }