public void LogoutTest_ShouldFalse() { // Setup the handler var mockHandler = GetHttpMessageHandlerMock("See you soon !"); // Use HttpClient with mocked HttpMessageHandler var httpClient = new HttpClient(mockHandler.Object); var objectToTest = new LoginApi(new Uri("https://test.com/"), ref httpClient); // Perform test objectToTest.LogoutAsync().Result.Should().Be(false); objectToTest.IsLoggedIn.Should().Be(true); // Check the http call was as expected var expectedUri = new Uri("https://test.com/cgi/session.pl"); var formVariables = new List <KeyValuePair <string, string> >(3); formVariables.Add(new KeyValuePair <string, string>(".submit", "Sign-out")); var expectedContent = new FormUrlEncodedContent(formVariables); VerifyMockCalls(mockHandler, HttpMethod.Post, expectedUri, expectedContent); }