public async Task PostAuthenticate_WhenValidCredentials_ReturnsToken()
        {
            RestClient client = new RestClient(mockTokenProvider.Object);

            IHttpClientResponse response = await client.Post("http://online.cuprum.com/webapixamarin/Api/Authenticate/Authenticate", new { ClaveAcceso = "arodriguez", Contrasena = "admin123$" });

            Assert.AreEqual("\"Authorized\"", response.GetContent());
            Assert.IsNotNull(response.GetHeader("token"));
        }
        public async Task GetListMateriaApps_WhenValidToken_ReturnsData()
        {
            RestClient client = new RestClient(mockTokenProvider.Object);

            IHttpClientResponse response = await client.Get("http://online.cuprum.com/webapixamarin/api/Materia/GetListMateriaApps");

            Assert.IsTrue(response.IsSuccessfulResponse());
            Assert.IsNotNull(response.GetContent());
        }
Example #3
0
        private void validateResponse(string endpoint, IHttpClientResponse response)
        {
            if (!response.IsSuccessfulResponse())
            {
                if (response.GetContent() == "Not User Found")
                {
                    throw new InvalidCredentialsException();
                }

                throw new RequestFailedException(endpoint);
            }
        }