AutoMock version 1.0.3

Rating: No reviews yet
Downloads: 0
Change Set: 30386
Released: Nov 5, 2013
Updated: May 18, 2016 by define
Dev status: Stable Help Icon

Available Downloads

There are no downloads associated with this release.

Release Notes

New version of AutoMock, version 1.0.3

Support for ordered tests

        [TestMethod]
        public void ShouldSupportOrderedTest()
        {
            //Arrange
            var autoMocker = new RhinoAutoMocker<CustomerUpdater>();

            var mockRepository = autoMocker.Repository;

            using (mockRepository.Ordered())
            {
                autoMocker.Get<ICustomerDataProvider>().Expect(x => x.GetCustomer(Arg<int>.Is.Anything)).Return(new CustomerItem());
                autoMocker.Get<ICustomerDataProvider>().Expect(x => x.UpdateCustomer(Arg<CustomerItem>.Is.Anything));
                autoMocker.Get<ILogWriter>().Expect(x => x.Write(Arg<string>.Is.Anything));
                autoMocker.Get<ILogWriter>().Expect(x => x.Write(Arg<string>.Is.Anything));
                autoMocker.Get<IMailSender>().Expect(x => x.SendMail(Arg<string>.Is.Anything, Arg<string>.Is.Anything));
            }
            
            //Act
            autoMocker.ClassUnderTest.UpdateCustomerName(1, "Frank", "frank@somecompany.com");

            //Assert
           ExceptionAssert.Throws<ExpectationViolationException>(mockRepository.VerifyAll,"IMailSender.SendMail(anything, anything); Expected #1, Actual #0.\r\nILogWriter.Write(anything); Expected #1, Actual #0.\r\n");  

        }

Support for manually injecting dependencies

        [TestMethod]
        public void WhenConstructorInjectedDependencyIsDefinedNoMockShouldBeCreated()
        {
            var autoMocker = new RhinoAutoMocker<CustomerUpdater>(new DummyLogWriter());
            autoMocker.Get<ICustomerDataProvider>().Expect(x => x.GetCustomer(0)).IgnoreArguments().Return(new CustomerItem());

            autoMocker.ClassUnderTest.UpdateCustomerName(1, "Frank", "frank@somecompany.com");

            var dummyLogWriter = autoMocker.Get<ILogWriter>() as DummyLogWriter;

            Assert.AreEqual("Customer Frank has been updated", dummyLogWriter.LogEntrys.First());

        }

Improved error messages when AutoMocking unsupported classes.

new RhinoAutoMocker<ILogWriter>(); //Interface cannot be used as ClassUnderTest. Only concrete class implementations are supported.

Reviews for this release

No reviews yet for this release.