Exemple #1
0
        public void ToMessageInfo_GoodMessageEntity_MessageInfo()
        {
            Guid userId1 = Guid.NewGuid();
            Guid userId2 = Guid.NewGuid();
            var  entity  = new MessageEntity
            {
                Text       = "text",
                CreateDate = DateTime.Now,
                SenderId   = userId1,
                Sender     = new UserEntity
                {
                    Id   = userId1,
                    Name = "user1"
                },
                RecipientId = userId2,
                Recipient   = new UserEntity
                {
                    Id   = userId2,
                    Name = "user2"
                }
            };

            MessageInfo result = DalConverter.ToMessageInfo(entity);

            Assert.Equal(entity.Text, result.Text);
            Assert.Equal(entity.CreateDate, result.CreateDate);
            Assert.Equal(entity.SenderId, result.SenderId);
            Assert.Equal(entity.Sender.Id, result.Sender.Id);
            Assert.Equal(entity.Sender.Name, result.Sender.Name);
            Assert.Equal(entity.RecipientId, result.RecipientId);
            Assert.Equal(entity.Recipient.Id, result.Recipient.Id);
            Assert.Equal(entity.Recipient.Name, result.Recipient.Name);
        }
Exemple #2
0
        public void ToMessageInfo_NullMessageEntity_Throws()
        {
            MessageEntity entity = null;

            Exception result = Assert.Throws <ArgumentException>(() => DalConverter.ToMessageInfo(entity));

            Assert.IsType(typeof(ArgumentException), result);
        }
Exemple #3
0
        public void ToMessageInfo_GoodMessage_MessageInfo()
        {
            var message = new Message
            {
                Text        = "text",
                CreateDate  = DateTime.Now,
                SenderId    = Guid.NewGuid(),
                RecipientId = Guid.NewGuid()
            };

            MessageInfo result = DalConverter.ToMessageInfo(message);

            Assert.Equal(message.Text, result.Text);
            Assert.Equal(message.SenderId, result.SenderId);
            Assert.Equal(message.RecipientId, result.RecipientId);
            Assert.Null(result.CreateDate);
            Assert.False(result.IsDelivered);
        }
Exemple #4
0
        public void ToMessageInfo_NullRecipient_Throws()
        {
            var entity = new MessageEntity
            {
                Text       = "text",
                CreateDate = DateTime.Now,
                SenderId   = Guid.NewGuid(),
                Sender     = new UserEntity {
                    Id = Guid.NewGuid(), Name = "user"
                },
                RecipientId = Guid.NewGuid(),
                Recipient   = null
            };

            Exception result = Assert.Throws <ArgumentException>(() => DalConverter.ToMessageInfo(entity));

            Assert.IsType(typeof(ArgumentException), result);
        }
Exemple #5
0
        public void ToMessageInfo_NullMessage_Throws()
        {
            Exception result = Assert.Throws <ArgumentException>(() => DalConverter.ToMessageInfo(null));

            Assert.IsType(typeof(ArgumentException), result);
        }
Exemple #6
0
        public int SendMessageToUser(Message message)
        {
            MessageInfo messageInfo = DalConverter.ToMessageInfo(message);

            return(ServiceClient.SendMessageToUser(messageInfo));
        }