Beispiel #1
0
        public void ShouldGetMessageAttachs()
        {
            //arrange
            var user = new User
            {
                Name    = "testCharUser",
                Picture = new byte[] {}
            };
            var login    = "******";
            var password = "******";
            var title    = "chatTitle";
            var pic      = new byte[] {};
            var atch     = new List <string>()
            {
                "pic.jpg", "text.txt"
            };
            string msg = "TestText of msg";

            //act
            var userRepository = new UsersRepository(ConnectionString);
            var resultUser1    = userRepository.Create(user, login, password);
            var resultUser2    = userRepository.Create(user, login + "1", password);
            var userIds        = new List <Guid> {
                resultUser1.Id, resultUser2.Id
            };

            _tempUsers.AddRange(userIds);
            var chatRepository = new ChatsRepository(ConnectionString);
            var resultChat     = chatRepository.Create(title, userIds, pic);

            _tempChats.Add(resultChat.Id);
            var messageRepository = new MessagesRepository(ConnectionString);
            var resultMsg         = messageRepository.Send(msg, resultUser1.Id, resultChat.Id, atch);
            var resultAttachs     = messageRepository.GetMessageAttachs(resultMsg.Id);

            _tempMessages.Add(resultMsg.Id);

            //asserts
            Assert.AreEqual(2, resultAttachs.Count());

            /*Assert.AreEqual(true, resultAttachs.Any(a => a.Path == atch[0] && a.Sender.Id == resultUser1.Id));
            *  Assert.AreEqual(true, resultAttachs.Any(a => a.Path == atch[1] && a.Sender.Id == resultUser1.Id));*/
        }