Ejemplo n.º 1
0
        public void GetIsNotOk()
        {
            Guid  guid       = Guid.NewGuid();
            Topic dummyTopic = new Topic();

            dummyTopic.Id = guid;

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

            mock.Setup(m => m.Exist(dummyTopic)).Returns(true);
            mock.Setup(m => m.Get(guid)).Throws(new ExceptionController());
            var controller = new TopicLogic(mock.Object);

            Assert.ThrowsException <ExceptionController>(() => controller.Get(guid));
            mock.VerifyAll();
        }
Ejemplo n.º 2
0
        public void GetIsOk()
        {
            Guid  guid  = Guid.NewGuid();
            Topic topic = new Topic()
            {
                Id     = guid,
                Name   = "Just Testing",
                AreaId = Guid.NewGuid()
            };
            Topic dummyTopic = new Topic();

            dummyTopic.Id = guid;

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

            mock.Setup(m => m.Exist(dummyTopic)).Returns(true);
            mock.Setup(m => m.Get(guid)).Returns(topic);
            var controller = new TopicLogic(mock.Object);

            Topic result = controller.Get(guid);

            Assert.AreEqual(topic, result);
        }