예제 #1
0
        public void GetAllIsOk()
        {
            Topic firstTopicExpected = new Topic()
            {
                Id     = Guid.NewGuid(),
                Name   = "Just Testing",
                AreaId = Guid.NewGuid()
            };

            Topic secondTopicExpected = new Topic()
            {
                Id     = Guid.NewGuid(),
                Name   = "Second Just Testing",
                AreaId = Guid.NewGuid()
            };

            IEnumerable <Topic> topics = new List <Topic>()
            {
                firstTopicExpected,
                secondTopicExpected
            };

            var mock = new Mock <IRepository <Topic, Area> >(MockBehavior.Strict);

            mock.Setup(m => m.GetAll()).Returns(topics);
            var controller = new TopicLogic(mock.Object);

            IEnumerable <Topic> resultList = controller.GetAll();

            Assert.AreEqual(topics, resultList);
        }
예제 #2
0
        public void GetAllNoElements()
        {
            var mock = new Mock <IRepository <Topic, Area> >(MockBehavior.Strict);

            mock.Setup(m => m.GetAll()).Throws(new ArgumentException());
            var controller = new TopicLogic(mock.Object);

            Assert.ThrowsException <ArgumentException>(() => controller.GetAll());
            mock.VerifyAll();
        }
예제 #3
0
        public void GetAllTopicsTest()
        {
            var topics = new List <TopicEntity>()
            {
                testTopicEntity
            };

            topicRepository.Setup(x => x.GetAll()).Returns(topics);

            var result = (IList <TopicEntity>)topicLogic.GetAll();

            topicRepository.VerifyAll();
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(result.First(), testTopicEntity);
        }