public void Post_Url_Invalid_3()
 {
     ShortenPostModel dataPostModel = new ShortenPostModel()
     {
         Url = "http://."
     };
     testInvalid(dataPostModel, Constants.ErrorMessages.InValidUrl);
 }
        public void Post_Url_Empty()
        {
            ShortenPostModel dataPostModel = new ShortenPostModel();

            testInvalid(dataPostModel, Constants.ErrorMessages.InValidUrl);
        }
        private void testValidUrl(ShortenPostModel dataPostModel)
        {
            string longUrl = "http://test.com";

            _mockLongShortUrlBll.Setup(p => p.ShortenLongUrl(It.IsAny<string>(), It.IsAny<string>())).Returns(longUrl);

            _controller.Validate(dataPostModel);

            OkNegotiatedContentResult<ResponseWrapper<object>> result = _controller.Post(dataPostModel) as OkNegotiatedContentResult<ResponseWrapper<object>>;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Content.Content, longUrl);
            Assert.AreEqual(result.Content.Status, Constants.Api.ResponseStatus.Ok);
        }
        private void testInvalid(ShortenPostModel dataPostModel, string errorMessage)
        {
            _controller.Validate(dataPostModel);

            OkNegotiatedContentResult<ResponseWrapper<object>> result = _controller.Post(dataPostModel) as OkNegotiatedContentResult<ResponseWrapper<object>>;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Content.ErrorMessage, errorMessage);
            Assert.AreEqual(result.Content.Status, Constants.Api.ResponseStatus.Fail);
        }
 public void Post_Url_Invalid_23()
 {
     ShortenPostModel dataPostModel = new ShortenPostModel()
     {
         Url = "http://foo.bar/foo(bar)baz quux"
     };
     testInvalid(dataPostModel, Constants.ErrorMessages.InValidUrl);
 }
 public void Post_Url_Invalid_22()
 {
     ShortenPostModel dataPostModel = new ShortenPostModel()
     {
         Url = ":// should fail"
     };
     testInvalid(dataPostModel, Constants.ErrorMessages.InValidUrl);
 }
 public void Post_Url_Invalid_19()
 {
     ShortenPostModel dataPostModel = new ShortenPostModel()
     {
         Url = "rdar://1234"
     };
     testInvalid(dataPostModel, Constants.ErrorMessages.InValidUrl);
 }
 public void Post_Url_Invalid_12()
 {
     ShortenPostModel dataPostModel = new ShortenPostModel()
     {
         Url = "http://foo.bar?q=Spaces should be encoded"
     };
     testInvalid(dataPostModel, Constants.ErrorMessages.InValidUrl);
 }