Ejemplo n.º 1
0
        public void CreateCaseNotExist()
        {
            Guid  guid       = Guid.NewGuid();
            Guid  secondGuid = Guid.NewGuid();
            Topic topic      = new Topic()
            {
                Id     = guid,
                Name   = "Just Testing",
                AreaId = secondGuid
            };
            Area area = new Area();

            area.Id = secondGuid;

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

            mock.Setup(m => m.GetParent(secondGuid)).Returns(area);
            mock.Setup(m => m.Add(It.IsAny <Topic>()));
            mock.Setup(m => m.Save());

            var   controller = new TopicLogic(mock.Object);
            Topic result     = controller.Create(topic);

            mock.VerifyAll();
            Assert.AreEqual(result, topic);
        }
Ejemplo n.º 2
0
        private Topic CreateTopicContext(Area area)
        {
            var topicRepo  = new TopicRepository(Context);
            var topicLogic = new TopicLogic(topicRepo);

            Topic topic = new Topic()
            {
                Name   = "Test topic",
                Area   = area,
                AreaId = area.Id
            };

            topicLogic.Create(topic);

            return(topic);
        }
Ejemplo n.º 3
0
        public void CreateInvalidId()
        {
            Guid  guid  = Guid.NewGuid();
            Topic topic = new Topic();

            topic.Name   = "test";
            topic.AreaId = guid;
            Area area = new Area();

            area.Id = guid;

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

            mock.Setup(m => m.GetParent(guid)).Returns(area);
            mock.Setup(m => m.Add(topic)).Throws(new ExceptionController());

            var controller = new TopicLogic(mock.Object);

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