How to test Wep API client without running application

Viewed 234

I have some api controllers and generated a swagger client with tests for them and filled it out. Here an example of filled test class:

[TestFixture]
public class CategoriesApiTests
{
    private CategoriesApi _instance;

    [SetUp]
    public void Init()
    {
        _instance = new CategoriesApi("http://localhost:5000/");
    }

    [Test]
    public void InstanceTest()
    {
        Assert.IsInstanceOf<CategoriesApi>(_instance, "instance is a CategoriesApi");
    }
}

But my tests only pass if I run my application.
How can I emulate running an application for testing?

1 Answers

What you may want to do is to separate all business logic into a separate DLL and then use unit testing.

Related