Пример #1
0
        public async Task TestFailedLogin()
        {
            var mockReponseHandler = new MockResponseHandler();

            var uri = new Uri($"{BaseAddress}{YoutrackDirectory.Authentication}");

            mockReponseHandler.AddFakeResponse(uri, new HttpResponseMessage(HttpStatusCode.Unauthorized));

            var clientFactory = new HttpClientFactory(mockReponseHandler);

            var client = clientFactory.Create(BaseAddress);


            var user = new User
            {
                Login    = "******",
                Password = "******".ToSecureString()
            };

            var loginClient = new YouTrackClient(client, user);

            var success = await loginClient.AuthenticateAsync(user);

            Assert.IsFalse(success);
        }
Пример #2
0
        public static void AddAuthenticationResponseHandler(this MockResponseHandler messageHandler, string baseAddress)
        {
            var stringContent = new StringContent("<login>ok</login>");

            var uri = new Uri($"{baseAddress}{YoutrackDirectory.Authentication}");

            messageHandler.AddFakeResponse(uri, new HttpResponseMessage(HttpStatusCode.Accepted)
            {
                Content = stringContent
            });
        }