Beispiel #1
0
        public Chat AddChat(string message, int draftId, int memberId)
        {
            IChatRepository cr = new ChatRepository();
            IDraftRepository dr = new DraftRepository();
            IMemberRepository mr = new MemberRepository();

            var draft = dr.GetById(draftId);
            var member = mr.GetById(memberId);

            var chat = new Chat() {Draft = draft, Member = member, Text = message};

            cr.Add(chat);

            return chat;
        }
        public void CanAddChat()
        {
            IChatRepository chatRepository = new ChatRepository();
            var chat = new Chat {Draft = _drafts[0], Member = _members[1], Text = "testchattext"};
            chatRepository.Add(chat);

            // use session to try to load the chat
            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Chat>(chat.Id);

                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(fromDb, chat);
                Assert.AreEqual(chat.Text, fromDb.Text);
            }
        }
        public void CanGetUpdatedList()
        {
            IChatRepository chatRepository = new ChatRepository();
            ICollection<Chat> chats = chatRepository.ListByDraft(_drafts[0]);
            List<Chat> chatlist = chats.ToList();

            var chat = new Chat { Draft = _drafts[0], Member = _members[1], Text = "testchattext" };
            chatRepository.Add(chat);

            List<Chat> newChats = chatRepository.ListNewChatsFromDraft(_drafts[0], chatlist[0].Id).ToList();

            Assert.AreEqual(1, newChats.Count);
            Assert.AreEqual(newChats[0].Text, chat.Text);
        }