public void UntypedMockExportProvider() { string msg = null; var mocker = new MockExportProvider(); mocker.Arrange<ILogger>(log => log.Log(Arg.AnyString)).DoInstead((string log) => msg = log); mocker.Arrange<IMessage>(message => message.Message).Returns("foo"); mocker.ExportMock<ICounter>(); var greeter = mocker.Compose<Greeter>(); greeter.Greet(); Assert.AreEqual("0: foo", msg); }
public void UntypedMockExportProvider() { string msg = null; var mocker = new MockExportProvider(); mocker.Arrange <ILogger>(log => log.Log(Arg.AnyString)).DoInstead((string log) => msg = log); mocker.Arrange <IMessage>(message => message.Message).Returns("foo"); mocker.ExportMock <ICounter>(); var greeter = mocker.Compose <Greeter>(); greeter.Greet(); Assert.AreEqual("0: foo", msg); }
public void ShouldRespectContractNames() { var mocker = new MockExportProvider(); mocker.Arrange<IMessage>("msg", msg => msg.Message).Returns("yep"); var reader = mocker.Compose<MessageReader>("reader"); Assert.AreEqual("yep", reader.Message); }
public void ShouldRespectContractNames() { var mocker = new MockExportProvider(); mocker.Arrange <IMessage>("msg", msg => msg.Message).Returns("yep"); var reader = mocker.Compose <MessageReader>("reader"); Assert.AreEqual("yep", reader.Message); }
public void ShouldAssertExpectationsOnAllMocks() { var mocker = new MockExportProvider(); mocker.ExportMock<IMessage>(); mocker.Arrange<ICounter>(counter => counter.Next).Returns(5); mocker.Arrange<ILogger>(log => log.Log(Arg.AnyString)).MustBeCalled(); AssertEx.Throws<AssertFailedException>(() => mocker.Assert()); AssertEx.Throws<AssertFailedException>(() => mocker.AssertAll()); AssertEx.Throws<AssertFailedException>(() => mocker.Assert<ILogger>()); mocker.ExportMock<ICounter>().Assert(); AssertEx.Throws<AssertFailedException>(() => mocker.ExportMock<ICounter>().AssertAll()); var greeter = mocker.Compose<Greeter>(); greeter.Greet(); mocker.Assert(); mocker.AssertAll(); mocker.Assert<ILogger>(); mocker.ExportMock<ICounter>().Assert(); mocker.ExportMock<ICounter>().AssertAll(); }
public void ShouldAssertExpectationsOnAllMocks() { var mocker = new MockExportProvider(); mocker.ExportMock <IMessage>(); mocker.Arrange <ICounter>(counter => counter.Next).Returns(5); mocker.Arrange <ILogger>(log => log.Log(Arg.AnyString)).MustBeCalled(); AssertEx.Throws <AssertFailedException>(() => mocker.Assert()); AssertEx.Throws <AssertFailedException>(() => mocker.AssertAll()); AssertEx.Throws <AssertFailedException>(() => mocker.Assert <ILogger>()); mocker.ExportMock <ICounter>().Assert(); AssertEx.Throws <AssertFailedException>(() => mocker.ExportMock <ICounter>().AssertAll()); var greeter = mocker.Compose <Greeter>(); greeter.Greet(); mocker.Assert(); mocker.AssertAll(); mocker.Assert <ILogger>(); mocker.ExportMock <ICounter>().Assert(); mocker.ExportMock <ICounter>().AssertAll(); }