Exemplo n.º 1
0
        public void ReceiveMessagesTest()
        {
            IChatManager target = ContainerService.Instance.Resolve<ChatManager>();
            const string userId = "100";
            const string chatRoomId = "100";

            IRepository<User> userRepository = ContainerService.Instance.Resolve<IRepository<User>>();

            var user = new User
                           {
                               Id = Convert.ToInt16(userId),
                               Name = "Kiril",
                               Password = "******",
                               TimeLogIn = DateTime.Now
                           };

            userRepository.Add(user);
            userRepository.SaveAll();

            IRepository<Room> roomRepository = ContainerService.Instance.Resolve<IRepository<Room>>();

            var room = new Room
                           {
                               Id = Convert.ToInt16(chatRoomId),
                               Name = "test"
                           };

            roomRepository.Add(room);
            roomRepository.SaveAll();

            IRepository<Message> messageRepository = ContainerService.Instance.Resolve<IRepository<Message>>();

            Message message = new Message
                              {
                                  Date = DateTime.Now,
                                  Id = messageRepository.FindAll().Count() + 1,
                                  RoomId = 100,
                                  UserId = 100,
                                  Text = "testMessage"
                              };

            messageRepository.Add(message);
            messageRepository.SaveAll();

            string str = target.ReceiveMessages(userId, chatRoomId);

            var s = str.Split(new[]{"Date"},StringSplitOptions.None);

            messageRepository.Delete(message);
            messageRepository.SaveAll();

            userRepository.Delete(user);
            userRepository.SaveAll();

            roomRepository.Delete(room);
            roomRepository.SaveAll();

            Assert.AreEqual(1, s.Length);
        }
Exemplo n.º 2
0
        public void SendMessage(string text, string userId, string chatRoomId)
        {
            IRepository<Message> messageRepository = ContainerService.Instance.Resolve<IRepository<Message>>();

            var messageId = messageRepository.FindAll().Count() + 1;

            Message message = new Message
                                  {
                                      Date = DateTime.Now,
                                      Id = messageId,
                                      RoomId = Convert.ToInt16(chatRoomId),
                                      UserId = Convert.ToInt16(userId),
                                      Text = text
                                  };

            messageRepository.Add(message);
            messageRepository.SaveAll();
        }
Exemplo n.º 3
0
		private void detach_Messages(Message entity)
		{
			this.SendPropertyChanging();
			entity.Room = null;
		}
Exemplo n.º 4
0
		private void attach_Messages(Message entity)
		{
			this.SendPropertyChanging();
			entity.Room = this;
		}
Exemplo n.º 5
0
	partial void DeleteMessage(Message instance);
Exemplo n.º 6
0
	partial void UpdateMessage(Message instance);
Exemplo n.º 7
0
	partial void InsertMessage(Message instance);