Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public class SUT
  2. {
  3. private readonly IFoo _foo;
  4. private readonly IBar _bar;
  5.  
  6. public SUT(IClientFactory clientFactory)
  7. {
  8. _foo = clientFactory.CreateClientInstance<Foo>(string.Empty);
  9. _bar = clientFactory.CreateClientInstance<Bar>(string.Empty);
  10. }
  11.  
  12. }
  13.  
  14. public class SUTTests
  15. {
  16.  
  17. [Fact]
  18. public DoTest()
  19. {
  20. var fooMock = new Mock<IFoo>(MockBehavior.Strict);
  21. var clientFactoryMock = new Mock<IClientFactory>(MockBehavior.Strict);
  22. var underTest = new SUT(clientFactoryMock.Object);
  23.  
  24. //the below setup produces a compile error saying that it cannot convert from IFoo to Foo even though the actua method returns IFoo
  25. clientFactoryMock.Setup(x => x.CreateClientInstance<Foo>(String.Empty,cts)).Returns(fooMock.Object);
  26.  
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement