コード例 #1
0
		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);
		}
コード例 #2
0
        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);
        }
コード例 #3
0
		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);
		}
コード例 #4
0
        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);
        }
コード例 #5
0
		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();
		}
コード例 #6
0
        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();
        }