Пример #1
0
        IServiceLocator CreateServiceLocator(IWindowsFactory windowFactory)
        {
            var builder = new ServiceLocatorStubBuilder();

            builder.WindowsFactory = windowFactory;
            return(builder.Build());
        }
Пример #2
0
        public void ShowOkCancelDialogBox_WhenValidationExceptionIsThrownOnTheExecuteCancel_DontLogException()
        {
            var serviceLocatorBuilder = new ServiceLocatorStubBuilder();

            serviceLocatorBuilder.WindowsFactory = CreateWindowsFactory(CreateModalWindowStub(cmds => cmds.CancelCommand.Execute(null)));

            var logger        = Substitute.For <ILogger>();
            var loggerFactory = Substitute.For <ILoggerFactory>();

            serviceLocatorBuilder.LoggerFactory = loggerFactory;

            var dialogViewModel = Substitute.For <IOkCancelDialogBoxViewModel>();

            dialogViewModel.When(vm => vm.ExecuteCancel())
            .Do(vm => { throw new ValidationException("Validatation failed!"); });

            var dialogServices = CreateDialogServices(serviceLocatorBuilder.Build());

            try
            {
                dialogServices.ShowOkCancelDialogBox(dialogViewModel);
            }
            catch (ValidationException)
            {
            }


            logger.DidNotReceiveWithAnyArgs().Exception("", null);
        }
Пример #3
0
        public void ShowOkCancelDialogBox_When()
        {
            var serviceLocatorBuilder = new ServiceLocatorStubBuilder();

            var appServices = Substitute.For <IApplicationServices>();

            serviceLocatorBuilder.ApplicationServices = appServices;

            var dialogViewModel = Substitute.For <IOkCancelDialogBoxViewModel>();


            var dialogServices = CreateDialogServices(serviceLocatorBuilder.Build());

            dialogServices.ShowOkCancelDialogBox(dialogViewModel);

            appServices.ReceivedWithAnyArgs().ExecuteOnUIThread(null);
        }