Exemplo 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);
        }
Exemplo n.º 2
0
 public FormMessages(MessageLogic messagelogic, LikeLogic likelogic, TopicLogic topiclogic)
 {
     InitializeComponent();
     this.messagelogic = messagelogic;
     this.likelogic    = likelogic;
     this.topiclogic   = topiclogic;
 }
        public TopicLogic CreateLogic()
        {
            var Repository = new TopicRepository(Context);
            var Logic      = new TopicLogic(Repository);

            return(Logic);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
 public FormMessage(MessageLogic logic, VisitorLogic vlogic, ModeratorLogic mlogic, TopicLogic topiclogic)
 {
     InitializeComponent();
     this.logic      = logic;
     this.vlogic     = vlogic;
     this.mlogic     = mlogic;
     this.topiclogic = topiclogic;
 }
Exemplo n.º 7
0
        // GET: /<controller>/Detail
        public IActionResult Detail(string name)
        {
            var logic = new TopicLogic();

            ViewBag.Topic = logic.GetByName(name);

            return(View());
        }
Exemplo n.º 8
0
        public IActionResult Interests()
        {
            var logic = new TopicLogic();

            ViewBag.Interests = logic.GetTopicInterests();

            return(View());
        }
Exemplo n.º 9
0
        public IActionResult CreatePost(Topic topic)
        {
            // validate topic (there is an asp.net way of doing this with
            // model.state or something
            var logic = new TopicLogic();

            logic.ValidateTopic(topic);

            return(View());
        }
Exemplo n.º 10
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();
        }
Exemplo n.º 11
0
        // GET: /<controller>/
        public IActionResult Index(string s)
        {
            var logic  = new TopicLogic();
            var filter = new TopicFilter()
            {
                SearchTerms = s
            };

            ViewBag.SearchTerms = s;
            ViewBag.Topics      = logic.GetTopics(filter);

            return(View());
        }
Exemplo n.º 12
0
        public void RemoveInvalid()
        {
            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(false);
            var controller = new TopicLogic(mock.Object);

            Assert.ThrowsException <ExceptionController>(() => controller.Remove(topic.Id));
            mock.VerifyAll();
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        public void RemoveValid()
        {
            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)).Returns(topic);
            mock.Setup(m => m.Remove(topic));
            mock.Setup(m => m.Save());
            var controller = new TopicLogic(mock.Object);

            controller.Remove(topic.Id);
            mock.VerifyAll();
        }
Exemplo n.º 16
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();
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
        public void TestInitialize()
        {
            testAreaEntity = new AreaEntity
            {
                Id     = 1,
                Name   = "Limpieza",
                Topics = new List <TopicEntity>()
            };

            testTopicEntity = new TopicEntity
            {
                Id           = 1,
                Name         = "Contenedores de basura",
                AreaEntityId = 1,
                RequestTypes = new List <TypeReqEntity>()
            };

            areaRepository  = new Mock <IRepository <AreaEntity> >(MockBehavior.Strict);
            topicRepository = new Mock <IRepository <TopicEntity> >(MockBehavior.Strict);
            unitOfWork      = new Mock <IUnitOfWork>();
            unitOfWork.Setup(r => r.AreaRepository).Returns(areaRepository.Object);
            unitOfWork.Setup(r => r.TopicRepository).Returns(topicRepository.Object);
            topicLogic = new TopicLogic(unitOfWork.Object);
        }
Exemplo n.º 19
0
        public override BaseLogic <Topic, Area> CreateBaseLogic(IRepository <Topic, Area> obj)
        {
            var controller = new TopicLogic(obj);

            return(controller);
        }
Exemplo n.º 20
0
 public FormMain(TopicLogic topiclogic, MessageLogic messagelogic)
 {
     InitializeComponent();
     this.topiclogic   = topiclogic;
     this.messagelogic = messagelogic;
 }
Exemplo n.º 21
0
 public FormEditTopic(TopicLogic logic)
 {
     InitializeComponent();
     this.logic = logic;
 }