public void Can_Call_Process()
        {
            var mockAdProcessorService = new Mock<IAdProcessorService>();
            var mocAdAddressParser = new Mock<IAdComponentParser>();
            var mockMaxMinParser = new Mock<IAdComponentParser>();
            var mocDescriptionParser = new Mock<IAdComponentParser>();
            var mockAd = new Ad();
            var adTobeParsed = "";

            //mocAdAddressParser.Setup(cparser => cparser.Parse(mockAd, adTobeParsed));
               // mockMaxMinParser.Setup(cparser => cparser.Parse(mockAd, adTobeParsed));
               // mocDescriptionParser.Setup(cparser => cparser.Parse(mockAd, adTobeParsed));

            mockAdProcessorService.Setup(processor => processor.Process(It.IsAny<Ad>(), adTobeParsed));
            //mockAdProcessorService.SetupGet(ps => ps.ComponentParsers).Returns(() => (new List<IAdComponentParser>()
            //                                                                              {
            //                                                                                  mocAdAddressParser.Object,
            //                                                                                  mockMaxMinParser.Object,
            //                                                                                  mocDescriptionParser.Object
            //                                                                              }).AsEnumerable());
            var postController = new PostController(mockAdProcessorService.Object);
            postController.Index(new FormCollection()
                                     {
                                         {"searchPost",adTobeParsed}
                                     });

            mockAdProcessorService.VerifyAll();
               // mocAdAddressParser.VerifyAll();
            //mockMaxMinParser.VerifyAll();
               // mocDescriptionParser.VerifyAll();
        }
Exemple #2
0
 public ActionResult Create(Ad ad)
 {
     if (ModelState.IsValid) {
         ad.UserId = 1;
         ad.LastUpdatedBy = 1;
         ad.CreatedBy = 1;
         ad.AdTypeId = 1;
         adRepository.InsertOrUpdate(ad);
         adRepository.Save();
         return RedirectToAction("Index");
     }
     return View();
 }
 public void Process(Ad ad, string adInString)
 {
     this.ComponentParsers.ForEach(parser => parser.Parse(ad, adInString));
 }
 public ActionResult Index(FormCollection form)
 {
     Ad adTobePopulated=new Ad();
     AdProcessor.Process(adTobePopulated, form["searchPost"]);
     return View();
 }
Exemple #5
0
 public ActionResult Edit(Ad ad)
 {
     if (ModelState.IsValid) {
         adRepository.InsertOrUpdate(ad);
         adRepository.Save();
         return RedirectToAction("Index");
     }
     else {
         return View();
     }
 }
 public void Parse(Ad ad, string adInString)
 {
 }