Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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();
        }
Beispiel #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;
 }
        // GET: /<controller>/Detail
        public IActionResult Detail(string name)
        {
            var logic = new TopicLogic();

            ViewBag.Topic = logic.GetByName(name);

            return(View());
        }
Beispiel #8
0
        public IActionResult Interests()
        {
            var logic = new TopicLogic();

            ViewBag.Interests = logic.GetTopicInterests();

            return(View());
        }
        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());
        }
Beispiel #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();
        }
        // 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());
        }
Beispiel #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();
        }
Beispiel #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();
        }
Beispiel #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);
        }
Beispiel #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();
        }
Beispiel #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();
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #19
0
        public override BaseLogic <Topic, Area> CreateBaseLogic(IRepository <Topic, Area> obj)
        {
            var controller = new TopicLogic(obj);

            return(controller);
        }
Beispiel #20
0
 public FormMain(TopicLogic topiclogic, MessageLogic messagelogic)
 {
     InitializeComponent();
     this.topiclogic   = topiclogic;
     this.messagelogic = messagelogic;
 }
 public FormEditTopic(TopicLogic logic)
 {
     InitializeComponent();
     this.logic = logic;
 }