コード例 #1
0
 public void Post_Url_Invalid_3()
 {
     ShortenPostModel dataPostModel = new ShortenPostModel()
     {
         Url = "http://."
     };
     testInvalid(dataPostModel, Constants.ErrorMessages.InValidUrl);
 }
コード例 #2
0
        public void Post_Url_Empty()
        {
            ShortenPostModel dataPostModel = new ShortenPostModel();

            testInvalid(dataPostModel, Constants.ErrorMessages.InValidUrl);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public void Post_Url_Invalid_23()
 {
     ShortenPostModel dataPostModel = new ShortenPostModel()
     {
         Url = "http://foo.bar/foo(bar)baz quux"
     };
     testInvalid(dataPostModel, Constants.ErrorMessages.InValidUrl);
 }
コード例 #6
0
 public void Post_Url_Invalid_22()
 {
     ShortenPostModel dataPostModel = new ShortenPostModel()
     {
         Url = ":// should fail"
     };
     testInvalid(dataPostModel, Constants.ErrorMessages.InValidUrl);
 }
コード例 #7
0
 public void Post_Url_Invalid_19()
 {
     ShortenPostModel dataPostModel = new ShortenPostModel()
     {
         Url = "rdar://1234"
     };
     testInvalid(dataPostModel, Constants.ErrorMessages.InValidUrl);
 }
コード例 #8
0
 public void Post_Url_Invalid_12()
 {
     ShortenPostModel dataPostModel = new ShortenPostModel()
     {
         Url = "http://foo.bar?q=Spaces should be encoded"
     };
     testInvalid(dataPostModel, Constants.ErrorMessages.InValidUrl);
 }