Well, for example, you can create a static action method inside your composition root to change the current configuration and invoke it during testing. For instance:
public class CompositionRoot { public static Action<IContainer> OverrideContainer = c => { }; internal static IContainer CreateContainer() { ContainerBuilder builder = new ContainerBuilder();
After that, you can create the layout of your server, for example, as follows:
[TestFixture] public class ConfigurationControllerFixture : BaseServer { [Test] public async Task verify_should_get_data() { var response = await GetAsync(Uri); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); } protected override string Uri { get { return "api/configuration"; } } } public abstract class BaseServer { protected TestServer Server; protected abstract string Uri { get; } protected virtual void OverrideConfiguration() { CompositionRoot.OverrideContainer = c => {
Hope this helps :)
source share