I am having a lot of trouble understanding how to unit test my web client.
I have just finished a project using TDD for the first time - this project hd no external dependencies such as API calls or databases, it was pure C# code. I definitely saw the benefits of using TDD and I would like to continue practising it.
My next project involves writing a SOAP client. I'm struggling to get past the first test which is using a simple IClient that logs in to the API successfully.
Here is the IClient interface:
public interface IClient
{
bool IsLoggedIn { get; }
bool Login(out string error);
}
I have no idea how I would go about testing this. I'm thinking the unit test method would be something like Login_WithValidCredentials_ReturnsTrue
, but I'm not sure how I could do this without actually simulating every possible response from the API. Is this code actually unit testable, or should this be left to an integration test.
If anyone could give me an example of a simple unit test then I would be very grateful (I am using Moq).