Example #1
0
        public void TokenCrudTest()
        {
            var device1 = new Device {
                Token = "test1", TenantID = TestTenantID, UserID = TestUserID.ToString()
            };
            var device2 = new Device {
                Token = "test2", TenantID = TestTenantID, UserID = TestUserID.ToString()
            };

            _deviceDao.Save(device1);
            _deviceDao.Save(device2);

            var devices = _deviceDao.GetAll(TestTenantID, TestUserID.ToString());

            Assert.AreEqual(2, devices.Count);
            Assert.That(devices.Any(device => device.Token == "test1"));
            Assert.That(devices.Any(device => device.Token == "test2"));

            _deviceDao.UpdateToken("test1", "test1-renamed");

            device2.Badge = 5;
            _deviceDao.Save(device2);

            devices = _deviceDao.GetAll(TestTenantID, TestUserID.ToString());
            Assert.AreEqual(2, devices.Count);
            Assert.That(devices.All(device => device.Token != "test1"));
            Assert.That(devices.Any(device => device.Token == "test1-renamed"));
            Assert.AreEqual(5, devices.First(device => device.Token == "test2").Badge);

            _deviceDao.Delete("test1-renamed");
            _deviceDao.Delete("test2");

            devices = _deviceDao.GetAll(TestTenantID, TestUserID.ToString());
            Assert.AreEqual(0, devices.Count);
        }
Example #2
0
        public void TearDown()
        {
            var deviceDao = new DeviceDao();

            foreach (var device in deviceDao.GetAll(TestTenantID, TestUserID))
            {
                deviceDao.Delete(device.Token);
            }
        }
Example #3
0
 public void TearDown()
 {
     var deviceDao = new DeviceDao();
     foreach (var device in deviceDao.GetAll(TestTenantID, TestUserID))
     {
         deviceDao.Delete(device.Token);
     }
 }