mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
Cannot create instance of FluentMockServer without running .Start() #255
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @TheLordDrake on GitHub (Feb 25, 2020).
When attempting to new up an instance of

FluentMockServerand passing aFluentMockServerSettingsinstance it encounter the following error:(Argument type 'WireMock.Settings.FluentMockServerSettings' is not assignable to parameter type 'WireMock.Settings.IFluentMockServerSettings')
On inspection
FluentMockServerhas a constructor that takesIFluentMockServerSettingsand calls itsbasewith a cast toIWireMockServerSettings.IFluentMockServerSettingsis an empty wrapper aroundIWireMockServerSettings.As a work around I tried newing up an instance of

WireMockServerdirectly, and found I was unable to do so as it has aprotectedcontructor.(Cannot access protected constructor 'WireMockServer' here)
To me this appears to be a bug, with possible fixes including removing the
protectedscope of theWireMockServerconstructor, or resolving the issue withFluentMockServerSettingsbeing an invalid type. I was going to create a PR to resolve this, but when I forked and cloned the repo I discovered that it has numerous build errors, several of which I'm uncertain how to resolve at the moment.@StefH commented on GitHub (Feb 25, 2020):
Just use
WireMockServer.StartThe FluentMockServer is obsolete (however it should more or less still work...)
@TheLordDrake commented on GitHub (Feb 25, 2020):
I was trying to avoid that, but I've since moved on from that approach, so
.Start()does bypass this issue.Would a more appropriate resolution be to remove
FluentMockServerandIFluentMockServeror at least mark them as deprecated?@StefH commented on GitHub (Mar 5, 2020):
I'll mark FluentMockServer + FluentMockServerSettings obsolete in one of the next releases.