コード例 #1
0
        public void Message_Can_Be_Changed()
        {
            // create some messages
            Messages_Can_Be_Sent();

            // change the message
            var organization = new LinqMetaData().Organization.First(x => x.Locations.Any(y => y.Devices.Any()));
            var device       = organization.Locations.First(x => x.Devices.Any()).Devices.First();
            var message      = device.DeviceMessages.Last(x => x.Message.Title == "Test Message");

            var controller = Mock();

            controller.Invoke(x => x.Edit(message.MessageId, new ComposeMessage(message.Message)
            {
                Body      = "Changed Test Message",
                StartTime = DateTime.UtcNow.AddSeconds(5),
            }));
            // wait for message to become active
            Thread.Sleep(5000);

            // make sure the device receives the changed message
            HttpContext.Current.User = new RolePrincipal(new GenericIdentity(device.UniqueIdentifier));
            Thread.CurrentPrincipal  = HttpContext.Current.User;
            var messages = new MessageService().GetCollection();

            Assert.IsTrue(messages.Any(x => x.Body.Contains("Changed Test Message")));
        }
コード例 #2
0
        public void Message_Delivered_Only_Once()
        {
            // send some messages
            Messages_Can_Be_Sent();
            // wait for message to become active
            Thread.Sleep(5000);

            // get authentication for first device
            var organization = new LinqMetaData().Organization.First(x => x.Locations.Any(y => y.Devices.Any()));
            var device       = organization.Locations.First(x => x.Devices.Any()).Devices.First();

            // deliver the messages
            HttpContext.Current.User = new RolePrincipal(new GenericIdentity(device.UniqueIdentifier));
            Thread.CurrentPrincipal  = HttpContext.Current.User;
            var messages = new MessageService().GetCollection();

            Assert.IsTrue(messages.Any());
            messages = new MessageService().GetCollection();
            Assert.IsFalse(messages.Any());
        }