public void Read()
        {
            Message message = new Message();

            Assert.That(message.ReadTime, Is.Null);

            DateTime read_time = new DateTime(2015, 2, 14, 12, 12, 12);
            SystemTime.SetDateTime(read_time);
            message.Read();
            SystemTime.ResetDateTime();

            Assert.That(message.ReadTime, Is.EqualTo(read_time));
        }
        public static void FilledBy(this ToMeItemModel model, Message message)
        {
            model.Id = message.Id;
            model.Content = message.Content;
            model.PublishTime = message.CreateTime;

            model.Task = new ViewModel.Task.LiteItemModel();
            model.Task.FilledBy(message.Task);
            model.Project = new _LiteralLinkedModel();
            model.Project.Filledby(message.Project);

            model.Addresser = new UserModel();
            model.Addresser.FilledBy(message.Addresser);

            model.ReadTime = message.ReadTime;
        }
        public void Send()
        {
            User addresser = new User();
            User addressee = new User();

            Message message = new Message
            {
                Addresser = addresser,
                Addressee = addressee
            };

            Assert.That(addresser.MessagesFromMe.IsNullOrEmpty(), Is.True);
            Assert.That(addressee.MessagesToMe.IsNullOrEmpty(), Is.True);

            message.Send();

            Assert.That(addresser.MessagesFromMe.Count, Is.EqualTo(1));
            Assert.That(addressee.MessagesToMe.Count, Is.EqualTo(1));
        }
        public void Not_Send()
        {
            Message message_empty = new Message
            {
                Addresser = null,
                Addressee = null
            };

            message_empty.Send();             //no exception is threw out

            User addresser = new User();            
            Message message_no_addressee = new Message
            {
                Addresser = addresser,
                Addressee = null
            };

            message_no_addressee.Send();

            //need not record into MessageFromMe since no addressee
            Assert.That(addresser.MessagesFromMe.Count, Is.EqualTo(1));

            
            User addressee = new User();
            Message message_no_addresser = new Message
            {
                Addresser = null,
                Addressee = addressee
            };
            Assert.That(addressee.MessagesToMe.IsNullOrEmpty(), Is.True);

            message_no_addresser.Send();

            //only record in MessagesToMe
            Assert.That(addressee.MessagesToMe.Count, Is.EqualTo(1));              
        }
 private Message create_message(DateTime publishTime, DateTime? readTime)
 {
     Message message = new Message();
     message.SetPropertyInBase("CreateTime", publishTime);
     message.SetPrivateField("_readTime", readTime);
     Save(message);
     return message;
 }
        private Message create_message(Project project)
        {
            Message message = new Message
            {
                Project = project,
            };
            Save(message);

            return message;
        }
        private Message create_message(User addresser, User addressee)
        {
            Message message = new Message
            {
                Addresser = addresser,
                Addressee = addressee
            };
            Save(message);

            return message;
        }
        private Message create_message(bool hideForAddresser, bool hideForAddressee)
        {
            Message message = new Message();
            message.SetPrivateField("_hideForAddresser", hideForAddresser);
            message.SetPrivateField("_hideForAddressee", hideForAddressee);

            Save(message);

            return message;
        }
        public void Read()
        {
            Message message_read_1 = new Message();
            message_read_1.SetPrivateField("_readTime", new DateTime(2014, 1, 1));
            Message message_read_2 = new Message();
            message_read_2.SetPrivateField("_readTime", new DateTime(2015, 11, 12));

            Message message_not_read_1 = new Message();
            Message message_not_read_2 = new Message();

            Save(message_read_1,
                message_read_2,
                message_not_read_1,
                message_not_read_2);

            var result_read = session.Query<Message>().HasRead().ToList();
            Assert.That(result_read.Count, Is.EqualTo(2));
            Contains(result_read, message_read_1);
            Contains(result_read, message_read_2);

            var result_not_read = session.Query<Message>().NotRead().ToList();
            Assert.That(result_not_read.Count, Is.EqualTo(2));
            Contains(result_not_read, message_not_read_1);
            Contains(result_not_read, message_not_read_2);
        }
        public void Hide()
        {
            User addresser = new User();
            User addressee = new User();
            Message message = new Message
            {
                Addresser = addresser,
                Addressee = addressee
            };
            message.Send();

            Assert.That(message.HideForAddresser, Is.False);
            Assert.That(message.HideForAddressee, Is.False);

            message.Hide(MessageFor.Addresser);

            Assert.That(message.HideForAddresser, Is.True);
            Assert.That(message.HideForAddressee, Is.False);

            message.Hide(MessageFor.Addressee);

            Assert.That(message.HideForAddresser, Is.True);
            Assert.That(message.HideForAddressee, Is.True);
        }
Beispiel #11
0
        public virtual void Comment(User author, User addressee, string comment)
        {
            addHistory(author, Constants.DescriptionComment, comment);

            Message message = new Message
            {
                Task = this,
                Project = Project,
                Addresser = author,
                Addressee = addressee,
                Content = comment
            };
            message.Send();
        }