November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Could you provide an example of how the lack of an interface poses a big problem? It should be fairly easy to instantiate and pass to any other service that needs it, in case you can't mock that entire service out of your tests?
As this is a while back, I don't remember the exact problem I had, but quickly looking at things now, I suspect that I wanted to inject it via a constructor, and test the service consuming it just by mocking simple methods on the ReferenceConverter.
When testing now, I see that I can in fact just mock the ICatalogSystem it requires - so in practice it's just a matter of reducing the need to inject stuff into the ReferenceConverter to mock it (it's not really super obvious since most people just get stuff intheir constructors). So the following works:
var mock = new Mock<ReferenceConverter>(new Mock<ICatalogSystem>().Object); mock.Setup(x => x.GetContentLink(It.IsAny<string>())).Returns(new ContentReference(2)); var contentReference = mock.Object.GetContentLink("hey");
However, if I could just say new Mock<ReferenceConverter>() that would make testing it a tiny bit more straigtforward.
I think that would work if you did new Mock<ReferenceConverter>(null) which is pretty close.
That seems very much to make sense. And so my train of thought might just have been something else in may than it is now - so I suppose this can be regarded as "Ok, won't bother" now :p
It would be great if the ReferenceConverter could simply get an interface like IReferenceConverter attached to it like most other stuff now has to eliminate the necessity of creating my own facade class for it just to test simple stuff needing it.