Esempio n. 1
0
        public void UpdateCorrect()
        {
            Guid  guid  = Guid.NewGuid();
            Topic topic = new Topic()
            {
                Id   = guid,
                Name = "Transporte"
            };

            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);
            mock.Setup(m => m.NameExists(topic)).Returns(false);
            mock.Setup(m => m.Update(topic));
            mock.Setup(m => m.Save());
            var controller = new TopicLogic(mock.Object);

            controller.Update(topic);
            mock.VerifyAll();
        }
Esempio n. 2
0
        public void UpdateInvalid()
        {
            Guid  guid  = Guid.NewGuid();
            Topic topic = new Topic();

            topic.Id = guid;

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

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

            Assert.ThrowsException <ExceptionController>(() => controller.Update(topic));
            mock.VerifyAll();
        }