Exemple #1
0
        public virtual ActionResult AddTweets(string btnSubmit, InputModel inputModel)
        {
            try
            {
                model.DownloadTweets(inputModel.InputValues);
            }
            catch (TimeoutException)
            {
                if (Logger != null)
                    Logger.WarnFormat("Twitter service timeout !");
                return View("Timeout");
            }
            catch (Exception ex)
            {
                if (Logger != null)
                    Logger.ErrorFormat("Tweet app experienced unexpected error. Message: {0}, StackTrace: {1}", ex.Message, ex.StackTrace);
                return View("Error");
            }

            if (ModelState.IsValid)
            {
                switch (btnSubmit)
                {
                    case "Get Tweets":
                        return (RedirectToAction("Index"));
                    case "Get Tweets In JSON":
                        return (RedirectToAction("IndexJson"));
                    default:
                        return (View("AddTweets"));
                }
            }
            return View("AddTweets");
        }
Exemple #2
0
 public void TestSetup()
 {
     this.tweetBase = MockRepository.GenerateStub<ITweetBase>();
     tweetBase.Stub(c => c.Tweets).Return(context);
     this.homeController = new HomeController(tweetBase);
     this.homeControllerNull = new HomeController();
     this.inputModel = new InputModel();
 }