Esempio n. 1
0
 public void Login_InvalidCredentials_Throws(string email, string password, ApiResultCode expectedErrorCode)
 {
     Assert.That(
         () => this.Client.Login(email, password),
         Throws.TypeOf<ApiException>()
         .With.Property<ApiException>(x => x.ApiResultCode).EqualTo(expectedErrorCode));
 }
Esempio n. 2
0
 private HttpResponseMessage createResponse(HttpStatusCode statusCode, ApiResultCode resultCode)
 {
     var error = new Error();
     error.code = (int)resultCode;
     error.message = _toolUtil.getEnumDescription(resultCode);
     return new HttpResponseMessage(statusCode) {
         Content = new StringContent(JsonConvert.SerializeObject(error, Formatting.Indented))
     };
 }
        private HttpStatusCode ConvertResultCode(ApiResultCode resultCode)
        {
            switch (resultCode)
            {
                case ApiResultCode.Success: return HttpStatusCode.OK;
                case ApiResultCode.InternalError: return HttpStatusCode.InternalServerError;
                case ApiResultCode.UnknownUri: return HttpStatusCode.NotFound;
                case ApiResultCode.InvalidBody: return HttpStatusCode.BadRequest;
            }

            throw new NotSupportedException();
        }
Esempio n. 4
0
 internal ApiException(ApiResultCode apiResultCode)
 {
     this.ApiResultCode = apiResultCode;
 }