I have C# API Library (.Net Framework 4.5.2) and I want to create regression tests to compare between 2 versions of the API. All the information that I found is about how to create regression tests for Restful API, which is not my case.
Today, I have a project that loads 2 versions of that API with a different alias name. For example:
- The production version is loaded from nuget.
- The development is loaded from the solution.
Advantages of this approach:
- It's very easy to debug when there is a difference (Unlike comparing a file with many data from different classes or properties)
- I have compile-time errors (Unlike using reflection)
There is 2 big disadvantage for this approach which makes it hard to maintain:
- There is a lot of code duplication. (I need to write the same code for each API version)
- I need to write the full namespace of each class in order to use it.
Is there a better way to do it? Or there is any tool or framework that do it?
Example of what I have today:
extern alias devVer;
using devVerApi = devVer::ApiLibrary;
using prodVerApi = ApiLibrary;
[TestMethod]
public void ClassWithSomeLogicTests_CheckRegression()
{
var prodClass = new prodVerApi.ClassWithSomeLogic("Text");
var devClass = new devVerApi.ClassWithSomeLogic("Text");
Assert.AreEqual(prodClass.GetLength(), devClass.GetLength());
}