Exemplo n.º 1
0
        public void CanInjectAnArrayOfMockServices4()
        {
            AutoMocker <ClassWithArray> mocker = createAutoMocker <ClassWithArray>();

            mocker.PartialMockTheClassUnderTest();
            ClassWithArray theClass = mocker.ClassUnderTest;

            theClass.Services.Length.ShouldEqual(0);
        }
Exemplo n.º 2
0
        public void UseTheAutoMockerToStartUpTheConcreteClassAsAPartialMockAndSetTheNameMethodUp()
        {
            AutoMocker <ConcreteClass> autoMocker = createAutoMocker <ConcreteClass>();

            autoMocker.PartialMockTheClassUnderTest();
            ConcreteClass concreteClass = autoMocker.ClassUnderTest;

            setExpectation(concreteClass, x => x.Name, "Max");
            concreteClass.Name.ShouldEqual("Max");
        }
Exemplo n.º 3
0
        public void CanInjectAnArrayOfMockServices3()
        {
            AutoMocker <ClassWithArray> mocker = createAutoMocker <ClassWithArray>();

            IMockedService[] services = mocker.CreateMockArrayFor <IMockedService>(3);

            mocker.PartialMockTheClassUnderTest();
            ClassWithArray theClass = mocker.ClassUnderTest;

            theClass.Services.Length.ShouldEqual(3);
        }
Exemplo n.º 4
0
        public void ThatWhenGameIDIsNotZeroPopulatedModelIsSentToView()
        {
            //--Arrange
            AutoMocker.PartialMockTheClassUnderTest();
            AutoMocker.ClassUnderTest.Expect(mock => mock.Edit(Arg <int> .Is.Anything, Arg <ApplicationUser> .Is.Anything)).Return(new ViewResult {
                ViewData = new ViewDataDictionary(base.ExpectedPopulatedCompletedGameViewModel)
            });

            //--Act
            var result = AutoMocker.ClassUnderTest.Edit(1, base.CurrentUser) as ViewResult;

            //--Assert
            Assert.AreEqual(base.ExpectedPopulatedCompletedGameViewModel, result.ViewData.Model);
        }
Exemplo n.º 5
0
        public void ThatEditGetActionReturnsAView()
        {
            //--Arrange
            AutoMocker.PartialMockTheClassUnderTest();
            AutoMocker.ClassUnderTest.Expect(mock => mock.Edit()).Return(new ViewResult {
                ViewName = MVC.PlayedGame.Views.Edit
            });

            //--Act
            var result = AutoMocker.ClassUnderTest.Edit() as ViewResult;

            //--Assert
            Assert.AreEqual(MVC.PlayedGame.Views.Edit, result.ViewName);
        }
Exemplo n.º 6
0
        public void TheAutoMockerPushesInMocksForAllOfTheConstructorArgumentsForAPartialMock()
        {
            AutoMocker <ConcreteClass> autoMocker = createAutoMocker <ConcreteClass>();

            var service  = autoMocker.Get <IMockedService>();
            var service2 = autoMocker.Get <IMockedService2>();
            var service3 = autoMocker.Get <IMockedService3>();

            autoMocker.PartialMockTheClassUnderTest();
            ConcreteClass concreteClass = autoMocker.ClassUnderTest;

            Assert.AreSame(service, concreteClass.Service);
            Assert.AreSame(service2, concreteClass.Service2);
            Assert.AreSame(service3, concreteClass.Service3);
        }