public void Work_FetchNewMessagesForAllRoomsTest()
        {
            CampfireState   campInfo = CampfireState.Instance;
            MockCampfireAPI api      = new MockCampfireAPI();

            List <Message> msgs;

            // Create a new room (at the API level)
            int roomId1 = 123;
            int roomId2 = 1001;
            int userId1 = 100;
            int userId2 = 200;

            api.FakeUsers.Add(new User("Peter", "*****@*****.**", userId1));
            api.FakeUsers.Add(new User("Casey", "*****@*****.**", userId2));

            Room rm1 = new Room(roomId1, "room #1");

            // The room must exist in the API and in cmapfireState
            api.FakeRooms.Add(rm1);
            campInfo.AddRoom(rm1.Id, rm1.Name, 0);

            // add a couple fake messages to room1
            msgs = new List <Message>();
            msgs.Add(new Message(1, Message.MType.EnterMessage, roomId1, userId1, ""));
            msgs.Add(new Message(2, Message.MType.TextMessage, roomId1, userId1, "Hello everyone"));
            api.MessagesInRoom.Add(roomId1, msgs);

            // add room 2
            Room rm2 = new Room(roomId2, "room #2");

            api.FakeRooms.Add(rm2);
            campInfo.AddRoom(rm2.Id, rm2.Name, 0);

            // add a couple fake messages to room1
            msgs = new List <Message>();
            msgs.Add(new Message(3, Message.MType.EnterMessage, roomId2, userId2, ""));
            msgs.Add(new Message(4, Message.MType.TextMessage, roomId2, userId2, "message from user 2"));
            msgs.Add(new Message(5, Message.MType.TextMessage, roomId2, userId1, "message from user 1"));
            api.MessagesInRoom.Add(roomId2, msgs);

            // The process step should now pick up the change and incorporate into campfileState
            MessageProcessor_Accessor.Work_ProcessNewMessagesForAllRooms(campInfo, api);

            // In the "Entered" queue there should be 2 entries
            MessageProcessor_Accessor.ProcessMessages_ProcessQueuedMessages(campInfo, api);
            Assert.AreEqual(2, campInfo.Users.Count);
            Assert.IsTrue(campInfo.Users.Any(u => u.Id == userId1));
            Assert.IsTrue(campInfo.Users.Any(u => u.Id == userId2));

            // In the Text Message queue there should be 3 entries
            MessageProcessor_Accessor.ProcessMessages_ProcessQueuedMessages(campInfo, api);
        }
        public void Work_ConsumeQueuedEnterMessagesTest()
        {
            CampfireState   campInfo = CampfireState.Instance;
            MockCampfireAPI api      = new MockCampfireAPI();

            Assert.AreEqual(0, campInfo.Users.Count);

            int fakeUserId = 12;

            api.FakeUsers.Add(new User("Peter", "*****@*****.**", fakeUserId));

            // Create a Entered Message for the fakeUser
            campInfo.QueueMessage(new CampfireAPI.Message(1, CampfireAPI.Message.MType.EnterMessage, 23, fakeUserId, string.Empty));

            // The process step should now process that queued Enter Message
            MessageProcessor_Accessor.ProcessMessages_ProcessQueuedMessages(campInfo, api);
            Assert.AreEqual(1, campInfo.Users.Count);
            Assert.IsTrue(campInfo.Users.Any(u => u.Id == fakeUserId && u.Name == "Peter"));
        }