示例#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);
        }
示例#2
0
        public void TearDown()
        {
            var deviceDao = new DeviceDao();

            foreach (var device in deviceDao.GetAll(TestTenantID, TestUserID))
            {
                deviceDao.Delete(device.Token);
            }
        }
示例#3
0
        public void NotificationCrudTest()
        {
            var notificationDao = new NotificationDao();
            var deviceDao       = new DeviceDao();

            foreach (var device in deviceDao.GetAll(TestTenantID, TestUserID))
            {
                notificationDao.Save(device.ID, new PushNotification
                {
                    Module = PushModule.Projects,
                    Action = PushAction.Created,
                    Item   = new PushItem(PushItemType.Task, "task" + device.ID, "")
                });

                notificationDao.Save(device.ID, new PushNotification
                {
                    Module = PushModule.Projects,
                    Action = PushAction.InvitedTo,
                    Item   = new PushItem(PushItemType.Project, "project" + device.ID, "")
                });

                notificationDao.Save(device.ID, new PushNotification
                {
                    Module = PushModule.Projects,
                    Action = PushAction.Assigned,
                    Item   = new PushItem(PushItemType.Milestone, "milestone" + device.ID, "")
                });
            }

            List <PushNotification> notifications = notificationDao.GetNotifications(TestTenantID, TestUserID, "device_1", DateTime.MinValue, DateTime.MaxValue);

            Assert.AreEqual(3, notifications.Count);

            notificationDao.Delete(DateTime.MaxValue);

            notifications = notificationDao.GetNotifications(TestTenantID, TestUserID, "device_1", DateTime.MinValue, DateTime.MaxValue);
            Assert.AreEqual(0, notifications.Count);
        }
示例#4
0
 public void TearDown()
 {
     var deviceDao = new DeviceDao();
     foreach (var device in deviceDao.GetAll(TestTenantID, TestUserID))
     {
         deviceDao.Delete(device.Token);
     }
 }
示例#5
0
        public void NotificationCrudTest()
        {
            var notificationDao = new NotificationDao();
            var deviceDao = new DeviceDao();
            foreach (var device in deviceDao.GetAll(TestTenantID, TestUserID))
            {
                notificationDao.Save(device.ID, new PushNotification
                    {
                        Module = PushModule.Projects,
                        Action = PushAction.Created,
                        Item = new PushItem(PushItemType.Task, "task" + device.ID, "")
                    });

                notificationDao.Save(device.ID, new PushNotification
                    {
                        Module = PushModule.Projects,
                        Action = PushAction.InvitedTo,
                        Item = new PushItem(PushItemType.Project, "project" + device.ID, "")
                    });

                notificationDao.Save(device.ID, new PushNotification
                    {
                        Module = PushModule.Projects,
                        Action = PushAction.Assigned,
                        Item = new PushItem(PushItemType.Milestone, "milestone" + device.ID, "")
                    });
            }

            List<PushNotification> notifications = notificationDao.GetNotifications(TestTenantID, TestUserID, "device_1", DateTime.MinValue, DateTime.MaxValue);
            Assert.AreEqual(3, notifications.Count);

            notificationDao.Delete(DateTime.MaxValue);

            notifications = notificationDao.GetNotifications(TestTenantID, TestUserID, "device_1", DateTime.MinValue, DateTime.MaxValue);
            Assert.AreEqual(0, notifications.Count);
        }