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); }
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); }
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); }
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(); }
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()); }
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()); }
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()); }
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(); }
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(); }
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); }
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(); }
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(); }
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); }
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); }
public override BaseLogic <Topic, Area> CreateBaseLogic(IRepository <Topic, Area> obj) { var controller = new TopicLogic(obj); return(controller); }
public FormMain(TopicLogic topiclogic, MessageLogic messagelogic) { InitializeComponent(); this.topiclogic = topiclogic; this.messagelogic = messagelogic; }
public FormEditTopic(TopicLogic logic) { InitializeComponent(); this.logic = logic; }