コード例 #1
0
        public void TestAtExecuteViderestillerViewModelTilOveride()
        {
            var fixture = new Fixture();

            fixture.Customize <IViewModel>(e => e.FromFactory(() => MockRepository.GenerateMock <IViewModel>()));

            var exceptionHandlerViewModelMock = MockRepository.GenerateMock <IExceptionHandlerViewModel>();

            var command = new MyViewModelCommand(exceptionHandlerViewModelMock);

            Assert.That(command, Is.Not.Null);

            var viewModelMock = fixture.Create <IViewModel>();
            var actionCalled  = false;

            command.OnExecute += vm =>
            {
                Assert.That(vm, Is.Not.Null);
                Assert.That(vm, Is.EqualTo(viewModelMock));
                actionCalled = true;
            };

            Assert.That(actionCalled, Is.False);
            command.Execute(viewModelMock);
            Assert.That(actionCalled, Is.True);

            exceptionHandlerViewModelMock.AssertWasNotCalled(m => m.HandleException(Arg <Exception> .Is.Anything));
        }
コード例 #2
0
        public void TestAtExecuteKalderExceptionHandlerViewModelMedIntranetGuiSystemExceptionHvisParameterIkkeErAfTypenIViewModel()
        {
            var fixture = new Fixture();

            var exceptionHandlerViewModelMock = MockRepository.GenerateMock <IExceptionHandlerViewModel>();

            var command = new MyViewModelCommand(exceptionHandlerViewModelMock);

            Assert.That(command, Is.Not.Null);

            command.Execute(fixture.Create <object>());

            exceptionHandlerViewModelMock.AssertWasCalled(m => m.HandleException(Arg <IntranetGuiSystemException> .Is.TypeOf));
        }
コード例 #3
0
        public void TestAtExecuteKalderExceptionHandlerViewModelMedIntranetGuiSystemExceptionVedException()
        {
            var fixture = new Fixture();

            fixture.Customize <IViewModel>(e => e.FromFactory(() => MockRepository.GenerateMock <IViewModel>()));

            var exceptionHandlerViewModelMock = MockRepository.GenerateMock <IExceptionHandlerViewModel>();

            var command = new MyViewModelCommand(exceptionHandlerViewModelMock);

            Assert.That(command, Is.Not.Null);

            var executeException = fixture.Create <Exception>();

            command.OnExecute += vm =>
            {
                throw executeException;
            };

            command.Execute(fixture.Create <IViewModel>());

            exceptionHandlerViewModelMock.AssertWasCalled(m => m.HandleException(Arg <IntranetGuiSystemException> .Is.NotNull));
        }