Ejemplo n.º 1
0
        public void ControllerMemberEmailMatchesFake()
        {
            // Arrange
            FakeMemberRepository memRepo = new FakeMemberRepository();
            string repoEmail;

            FakeMessageRepository repository = new FakeMessageRepository();
            MessageController     controller = new MessageController(repository);
            string controllerEmail           = "";

            // Act
            List <Message> controllerMembers = controller.Forum().ViewData.Model as List <Message>;

            foreach (var m in controllerMembers)
            {
                if (m.From.Name == "John Doe")
                {
                    controllerEmail = m.From.Email;
                }
            }

            repoEmail = memRepo.GetMemberEmail("John Doe");

            // Assert

            Assert.Equal(repoEmail, controllerEmail);
        }
Ejemplo n.º 2
0
        public void ControllerTopicMatchesFake()
        {
            // Arrange
            FakeMessageRepository repository = new FakeMessageRepository();
            MessageController     controller = new MessageController(repository);

            // Act
            List <Message> controlMess = controller.Forum().ViewData.Model as List <Message>;

            List <Message> repoTopic = repository.GetMessagesByTopic("Bigfoot");

            // Assert

            Assert.Equal(repoTopic[0].Topic, controlMess[0].Topic);
        }
Ejemplo n.º 3
0
        public void ControllerRepositoryMatchesFake()
        {
            // Arrange
            FakeMessageRepository repository = new FakeMessageRepository();
            MessageController     controller = new MessageController(repository);

            // Act


            List <Message> messages = controller.Forum().ViewData.Model as List <Message>;

            // Assert

            Assert.Equal(repository.GetAllMessagesNewestFirst()[0].Body, messages[0].Body);
            Assert.Equal(repository.GetAllMessagesNewestFirst()[0].From.Name, messages[0].From.Name);
            Assert.Equal(repository.GetAllMessagesNewestFirst()[1].Date, messages[1].Date);
            Assert.Equal(repository.GetAllMessagesNewestFirst()[1].Topic, messages[1].Topic);
        }
Ejemplo n.º 4
0
        public void ControllerMemberMessagesMatchFake()
        {
            // Arrange
            FakeMessageRepository repository = new FakeMessageRepository();
            var fakeMemberMessages           = new List <Message>();

            MessageController controller = new MessageController(repository);
            var controllerMemberMessages = new List <Message>();

            // Act
            List <Message> messages = controller.Forum().ViewData.Model as List <Message>;

            fakeMemberMessages = repository.GetAllMessagesFromMember("John Doe");
            foreach (var m in messages)
            {
                if (m.From.Name == "John Doe")
                {
                    controllerMemberMessages.Add(m);
                }
            }
            // Assert

            Assert.Equal(controllerMemberMessages.Count, fakeMemberMessages.Count);
        }