예제 #1
0
 public RetryingAsyncCommand(IAsyncCommand <T> inner, byte maxAttempts = 3, TimeSpan delay = default, Func <T, Exception, Task>?handleFailedAttemptAsync = default)
 {
     _inner       = inner;
     _maxAttempts = maxAttempts;
     _delay       = delay;
     _handleFailedAttemptAsync = handleFailedAttemptAsync;
 }
 public LoginAndSignUpViewModel(INavigationService navigationService) : base(navigationService)
 {
     Title         = "Login";
     User          = new UserModel();
     LogInCommand  = new AsyncCommand(LogInCommandExecute);
     SignUpCommand = new AsyncCommand(SignUpCommandExecute);
 }
예제 #3
0
 public StaffAccountCreator()
 {
     ClearCommand  = new RelayCommand(Clear);
     CreateCommand = new RelayAsyncCommand(Create);
     PrintCommand  = new RelayAsyncCommand(Print);
     Clear();
 }
예제 #4
0
 public FieldAreaListVM(CaseType caseType)
 {
     _caseType    = caseType;
     Cases        = new ObservableCollection <ICase>();
     SelectedCase = default(ICase);
     BuildCases   = new AsyncCommand <string>(BuildCasesAsync, CanBuildCases, new RelayCommandErrorHandler());
 }
예제 #5
0
        public IAsyncCommand Find(Guid group, int id)
        {
            IAsyncCommand cmd = null;

            _commandMap.TryGetValue(new Key(group, id), out cmd);
            return(cmd);
        }
예제 #6
0
 public MainWindowViewModel(ISearchService searchService)
 {
     Keyword        = "conveyancing software";
     Url            = "www.smokeball.com.au";
     _searchService = searchService;
     Submit         = new AsyncCommand(ExecuteSubmitAsync, CanExecuteSubmit);
 }
예제 #7
0
        public void Create_Asynchronous_Reference_StronglyTypedCommandParameter_DefaultState()
        {
            IAsyncCommand <int> command = Command.Create <int>(_ => Task.CompletedTask);

            Assert.IsType <AsyncRelayCommand <int> >(command);
            Assert.True(command.CanExecute(240));
        }
예제 #8
0
        public void Create_Asynchronous_Reference_StronglyTypedCommandParameter_MutableState()
        {
            IAsyncCommand <int> command = Command.Create <int>(_ => Task.CompletedTask, _ => false);

            Assert.IsType <AsyncRelayCommand <int> >(command);
            Assert.False(command.CanExecute(240));
        }
예제 #9
0
        public void Create_Asynchronous_Reference_NoCommandParameter_DefaultState()
        {
            IAsyncCommand command = Command.Create(() => Task.CompletedTask);

            Assert.IsType <AsyncRelayCommand>(command);
            Assert.True(command.CanExecute());
        }
예제 #10
0
        public void Create_Asynchronous_Reference_NoCommandParameter_MutableState()
        {
            IAsyncCommand command = Command.Create(() => Task.CompletedTask, () => false);

            Assert.IsType <AsyncRelayCommand>(command);
            Assert.False(command.CanExecute());
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="command">Async command.</param>
        /// <param name="fireAndForgetOnExecution">Flag indicates whether or not the async command shall be fire and forget on execution.</param>
        public AsyncCommandToCommand(IAsyncCommand command, bool fireAndForgetOnExecution = true)
        {
            this.command = command ?? throw new ArgumentNullException(nameof(command));
            this.fireAndForgetOnExecution = fireAndForgetOnExecution;

            command.CanExecuteChanged += (sender, args) => CanExecuteChanged(sender, args);
        }
예제 #12
0
 static void VerifyService(IAsyncCommand service)
 {
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
 }
        public EventPopupViewModel(Event ev, TimetableInfoList timetable)
        {
            Event = ev;

            ClosePopupCommand    = CommandFactory.Create(ClosePopup);
            AddToCalendarCommand = CommandFactory.Create(AddEventToCalendar);

            LessonInfo lessonInfo = timetable.LessonsInfo.FirstOrDefault(li => li.Lesson.Equals(ev.Lesson));

            Notes = lessonInfo?.Notes;

            EventNumber = timetable.Events
                          .Where(e => e.Lesson == ev.Lesson && e.Type == ev.Type && e.Start < ev.Start)
                          .DistinctBy(e => e.Start)
                          .Count() + 1;
            EventsCount = timetable.Events
                          .Where(e => e.Lesson == ev.Lesson && e.Type == ev.Type)
                          .DistinctBy(e => e.Start)
                          .Count();

            Details = $"{string.Format(LN.EventType, ev.Type.FullName)} ({EventNumber}/{EventsCount})\n" +
                      $"{string.Format(LN.EventClassroom, ev.RoomName)}\n" +
                      $"{string.Format(LN.EventTeachers, string.Join(", ", ev.Teachers.Select(t => t.Name)))}\n" +
                      $"{string.Format(LN.EventGroups, string.Join(", ", ev.Groups.Select(t => t.Name)))}\n" +
                      $"{string.Format(LN.EventDay, ev.Start.ToString("ddd, dd.MM.yy"))}\n" +
                      $"{string.Format(LN.EventTime, ev.Start.ToString("HH:mm"), ev.End.ToString("HH:mm"))}";
        }
예제 #14
0
        private void RunWithThreadContext(Action action)
        {
            bool          flag         = false;
            IAsyncCommand asyncCommand = this.command;

            if (asyncCommand != null)
            {
                asyncCommand.SetContextDataInTls();
                if (asyncCommand.PerUserTracingEnabled)
                {
                    AirSyncDiagnostics.SetThreadTracing();
                }
                flag = true;
            }
            try
            {
                action();
            }
            finally
            {
                if (flag)
                {
                    Command.ClearContextDataInTls();
                    if (asyncCommand.PerUserTracingEnabled)
                    {
                        AirSyncDiagnostics.ClearThreadTracing();
                    }
                }
            }
        }
예제 #15
0
 public static bool TestConnection <T1, T2, T3>(
     this IAsyncCommand <T1, T2, T3> command,
     TenantInfo tenantInfo,
     string connectionString)
 {
     return(TestConection(tenantInfo, connectionString));
 }
 public ListarProdutosViewModel()
 {
     SelectionChangedCommand = new AsyncCommand <Produto>((Produto obj) => ExecuteSelectionChangedCommandAsync(obj), allowsMultipleExecutions: false);
     VoltarCommand           = new AsyncCommand(ExecuteVoltarCommandAsync, allowsMultipleExecutions: false);
     RefreshCommand          = new AsyncCommand(ExecuteRefreshCommandAsync, allowsMultipleExecutions: false);
     InitializeAsync         = InitializationAsync();
 }
예제 #17
0
        /// <summary>
        /// Save execute command asynchronously.
        /// </summary>
        /// <param name="asyncCommand">Async command to execute safely.</param>
        /// <param name="parameter">Command parameter.</param>
        /// <param name="callCanExecuteBeforeExecution">Call CanExecute before command execution.</param>
        /// <param name="ignoreExceptions">Ignore exceptions from command.</param>
        public static async Task SafeExecuteAsync(
            this IAsyncCommand asyncCommand,
            object parameter = null,
            bool callCanExecuteBeforeExecution = true,
            bool ignoreExceptions = true)
        {
            if (asyncCommand == null)
            {
                return;
            }

            try
            {
                if (callCanExecuteBeforeExecution)
                {
                    if (asyncCommand.CanExecute(parameter))
                    {
                        return;
                    }
                }

                await asyncCommand.ExecuteAsync(parameter);
            }
            catch
            {
                if (!ignoreExceptions)
                {
                    throw;
                }
            }
        }
예제 #18
0
        public async Task RefreshAll(MediaType mediaType)
        {
            if (MessageBoxService.ShowMessage(Properties.Resources.RefreshAllConfirm, Properties.Resources.RefreshAll,
                                              MessageButton.YesNo, MessageIcon.Question, MessageResult.No) != MessageResult.Yes)
            {
                return;
            }

            try
            {
                BeginProgress();
                IAsyncCommand     command           = this.GetAsyncCommand(x => x.RefreshAll(mediaType));
                CancellationToken cancellationToken = command.CancellationTokenSource.Token;
                BackgroundOperation.Register(Properties.Resources.RefreshAll, command.CancelCommand);

                switch (mediaType)
                {
                case MediaType.Movie:
                    foreach (MovieContainer container in App.Repository.Movies)
                    {
                        if (cancellationToken.IsCancellationRequested)
                        {
                            break;
                        }

                        await App.Repository.UpdateMovieAsync(container, cancellationToken);
                    }
                    break;

                case MediaType.Tv:
                    foreach (TvShowContainer container in App.Repository.TvShows)
                    {
                        if (cancellationToken.IsCancellationRequested)
                        {
                            break;
                        }

                        await App.Repository.UpdateTvShowAsync(container, cancellationToken);
                    }
                    break;

                case MediaType.Person:
                    foreach (PersonContainer container in App.Repository.People)
                    {
                        if (cancellationToken.IsCancellationRequested)
                        {
                            break;
                        }

                        await App.Repository.UpdatePersonAsync(container, cancellationToken);
                    }
                    break;
                }
            }
            finally
            {
                EndProgress();
                BackgroundOperation.UnRegister(Properties.Resources.RefreshAll);
            }
        }
예제 #19
0
        public async Task Send(IAsyncCommand command)
        {
            var commandType = command.GetType();

            var validator = _validatorsFactory(commandType);

            if (validator != null)
            {
                var validatorType = validator.GetType();

                var actionPossible = (ActionPossible)validatorType.InvokeMember("Execute", BindingFlags.InvokeMethod, null, validator, new object[] { command });

                if (actionPossible.IsImpossible)
                {
                    _eventsBus.Publish(new ActionImposibleEvent(actionPossible.Errors));
                    return;
                }
            }

            var handler = _asyncHandlersFactory(commandType);

            var handlerType = handler.GetType();

            await(Task) handlerType.InvokeMember("Handle", BindingFlags.InvokeMethod, null, handler, new object[] { command });

            _eventsBus.Publish(new CommandCompletedEvent(commandType.Name));
        }
예제 #20
0
        public EventPopupViewModel(Event ev, TimetableInfoList timetables, ITimetablePageCommands timetablePage)
        {
            Event         = ev;
            TimetablePage = timetablePage;
            if (timetables.Timetables.Count == 1)
            {
                Timetable  = timetables.Timetables.Single();
                LessonInfo = Timetable.GetAndAddLessonsInfo(ev.Lesson);
            }
            else
            {
                LessonInfo = new(ev.Lesson);
            }

            EventNumber = timetables.Events
                          .Where(e => e.Lesson == ev.Lesson && e.Type == ev.Type && e.Start < ev.Start)
                          .DistinctBy(e => e.Start)
                          .Count() + 1;
            EventsCount = timetables.Events
                          .Where(e => e.Lesson == ev.Lesson && e.Type == ev.Type)
                          .DistinctBy(e => e.Start)
                          .Count();
            Details = $"{string.Format(LN.EventType, ev.Type.FullName)} ({EventNumber}/{EventsCount})\n" +
                      $"{string.Format(LN.EventClassroom, ev.RoomName)}\n" +
                      $"{string.Format(LN.EventTeachers, string.Join(", ", ev.Teachers.Select(t => t.Name)))}\n" +
                      $"{string.Format(LN.EventGroups, string.Join(", ", Event.Groups.Select(t => t.Name).GroupBasedOnLastPart()))}\n" +
                      $"{string.Format(LN.EventDay, ev.Start.ToString("ddd, dd.MM.yy"))}\n" +
                      $"{string.Format(LN.EventTime, ev.Start.ToString("HH:mm"), ev.End.ToString("HH:mm"))}";
            Notes = LessonInfo.Notes?.Trim();

            OptionsCommand = CommandFactory.Create(ShowOptions, allowsMultipleExecutions: false);
        }
예제 #21
0
        public AuthenticateViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IUserService userService)
        {
            if (eventAggregator == null)
            {
                throw new ArgumentNullException("eventAggregator");
            }
            if (regionManager == null)
            {
                throw new ArgumentNullException("regionManager");
            }
            if (userService == null)
            {
                throw new ArgumentNullException("userService");
            }

            this.regionManager   = regionManager;
            this.eventAggregator = eventAggregator;
            this.eventAggregator.GetEvent <LoginStatusChangedEvent>().Subscribe(this.LoginStatusChanged, ThreadOption.UIThread);
            this.userService      = userService;
            this.PropertyChanged += this.OnLoginPropertyChanged;
            this.PropertyChanged += this.OnCanLoginChanged;

            this.loginCommand            = new AsyncCommand <UserQueryResult>(() => this.LoginAsync(), this.CanLogin);
            this.loginAsGuestCommand     = new DelegateCommand(this.LoginAsGuest);
            this.selectGameRegionCommand = new DelegateCommand <object>(this.SelectGameRegion);

            this.gameRegions    = this.userService.GameRegions.ToList();
            this.SelectedRegion = this.userService.HomeRegion;

            this.Notification = Resources.Disclaimer;
        }
예제 #22
0
 public LanguagePickerViewModel(IAnalyticsService analyticsService, INavigationHelper navigationHelper, LanguageService languageService)
     : base(analyticsService)
 {
     this.languageService = languageService;
     LanguageService.PreferredLanguageChanged += LanguageService_PreferredLanguageChanged;
     SetAppLanguageCommand = new AsyncCommand <LanguageViewModel>((x) => SetAppLanguage(x));
 }
예제 #23
0
        private async Task ExecCommandAsync(RHostClientHelpTestApp clientApp, IAsyncCommand command)
        {
            clientApp.Reset();
            await UIThreadTools.InUI(command.InvokeAsync);

            await clientApp.WaitForReadyAndRenderedAsync(DoIdle, nameof(HelpTest));
        }
 public CommandAsyncToOleMenuCommandShim(Guid group, int id, IAsyncCommand command)
     : base(group, id) {
     if (command == null) {
         throw new ArgumentNullException(nameof(command));
     }
     _command = command;
 }
예제 #25
0
        public LinkedAccounts()
        {
            state = State.App.Instance.Linked;
            state.AddObserver(this);

            SyncCommand = new RelayAsyncCommand(Sync);
        }
예제 #26
0
 public MainViewModel()
 {
     Title           = "MainPage";
     NavigateCommand = new AsyncCommand(async() => { await NavigationService.PushPageModel <TestViewModel>(); });
     LoadMore        = new AsyncCommand(async() => { await FetchData(); });
     ClickedCommand  = new AsyncCommand(async() => { await FetchData(); });
 }
예제 #27
0
        public async Task ProcessCommand_WhenSubscribingDuringExecution_ShouldNotifyCommandStarted(
            [Frozen] Mock <IAsyncCommandBus> innerCommandBus,
            NotifyCommandStateBus sut,
            IAsyncCommand command,
            [Frozen] TestScheduler scheduler)
        {
            //arrange
            var observer = scheduler.CreateObserver <IAsyncCommand>();

            innerCommandBus.Setup(bus => bus.ProcessCommand(It.IsAny <IAsyncCommand>()))
            .Returns(() =>
            {
                sut.ObserveCommandStarted().Subscribe(observer);
                return(Task.FromResult(true));
            });

            //act
            scheduler.AdvanceTo(200);
            await sut.ProcessCommand(command);

            scheduler.Start();

            //assert
            var expected = OnNext(201, command);

            observer.Messages.First().ShouldBeEquivalentTo(expected);
        }
예제 #28
0
        private NotificationManager.AsyncEvent GetNextEvent()
        {
            IAsyncCommand asyncCommand = this.command;

            NotificationManager.AsyncEvent result;
            lock (this.eventQueue)
            {
                if (this.eventQueue.Count > 0)
                {
                    NotificationManager.AsyncEvent asyncEvent = this.eventQueue.Peek();
                    if ((asyncCommand != null && !asyncCommand.ProcessingEventsEnabled) || (asyncEvent.Command != null && !asyncEvent.Command.ProcessingEventsEnabled))
                    {
                        result = null;
                    }
                    else
                    {
                        result = this.eventQueue.Dequeue();
                    }
                }
                else
                {
                    result = null;
                }
            }
            return(result);
        }
예제 #29
0
 public PIDViewModel()
 {
     PIDs = PIDs;
     RefreshAsyncCommand   = new AsyncCommand(ExecuteRefreshAsyncCommand);
     ChooseDllAsyncCommand = new AsyncCommand(ExecuteChooseDllAsyncCommand);
     InjectAsyncCommand    = new AsyncCommand(ExecuteInjectAsyncCommand, CanExecuteInjectAsyncCommand);
 }
예제 #30
0
 public static IDisposable ExecuteAsync <T>(this IObservable <T> observable, IAsyncCommand <T> command)
 {
     return(observable.SelectMany(async t => { if (command.CanExecute(t))
                                               {
                                                   await command.ExecuteAsync(t);
                                               }
                                               return Unit.Default; }).Subscribe());
 }
예제 #31
0
        public async Task <TResult> Process <TResult>(IAsyncCommand <TResult> command)
        {
            var handlerType = typeof(IAsyncCommandHandler <,>).MakeGenericType(command.GetType(), typeof(TResult));

            dynamic handler = _container.Resolve(handlerType);

            return(await handler.HandleAsync((dynamic)command));
        }
		public void Sut_ProcessCommand_VerifyGuardClauses(
			GuardClauseAssertion assertion,
			IAsyncCommand command)
		{
			var method = new Methods<ConcurrencyExecutionAsyncCommandBus>()
				.Select(sut => sut.ProcessCommand(command));				
            assertion.Verify(method);
		}
예제 #33
0
 protected TopicsGridVm()
 {
     TopicsToList = new ObservableCollection<TopicSummary>();
     Products = new ObservableCollection<DisplayableProduct>();
     RefreshTopics = RelayAsyncSimpleCommand.Create(LoadAllTopics, CanLoadAllTopics);
     ExportProductToMkDocs = RelayAsyncSimpleCommand.Create(ExportProduct, () => true);
     DefaultDirectoryPath = Directory.GetCurrentDirectory();
     EventBus.AsObservable<OnTopicRemoved>().Subscribe(Handle);
 }
		public async Task Process_ShouldCallInnerProcessCommand(
			[Frozen]Mock<IAsyncCommandBus> mockCommandBus,
			ConcurrencyExecutionAsyncCommandBus sut,
			IAsyncCommand command)
		{
			//act
			await sut.ProcessCommand(command);

			//assert
			mockCommandBus.Verify(m => m.ProcessCommand(command));
		}
예제 #35
0
        public MainViewModel()
        {
            LoadServersCommand = new AsyncCommand(LoadServersAsync);
            UpdateServersCommand = new AsyncCommand(UpdateServersAsync);
            UpdateCurrentServerInfoCommand = new AsyncCommand(UpdateCurrentServerInfoAsync);
            ExecuteCommandCommand = new AsyncCommand(ExecuteCommandAsync);
            AddServerCommand = new AsyncCommand(AddNewServerAsync);
            RemoveServerCommand = new AsyncCommand(RemoveServerAsync);

            updateTimer.Tick += updateTimer_Tick;
            updateTimer.Interval = new TimeSpan(0, 0, 2);
            updateTimer.Start();
        }
		public async Task Process_WhenRegisteringCommandType_ShouldCallInnerProcessCommand(
			[Frozen]Mock<IAsyncCommandBus> mockCommandBus,
			ConcurrencyExecutionAsyncCommandBus sut,
			IAsyncCommand command)
		{
			//arrange
			sut.ForCommand<TestCommand>(1);

			//act
			await sut.ProcessCommand(command);

			//assert
			mockCommandBus.Verify(m => m.ProcessCommand(command));
		}
예제 #37
0
		public async Task ProcessCommand_ShouldCallInnerProcessCommnad(
			[Frozen]Mock<IAsyncCommandBus> innerCommandBus,
		  NotifyCommandStateBus sut,
			IAsyncCommand command)
		{
			//arrange
			var verifiable = innerCommandBus.Setup(bus => bus.ProcessCommand(command)).ReturnsDefaultTaskVerifiable();

			//act
			await sut.ProcessCommand(command);

			//assert
			verifiable.Verify();
		}
        public void Add(IAsyncCommand funcToRun, string id, Type commandType)
        {
            lock (_syncRoot)
            {
                if (Exists(id, commandType))
                {
                    throw new Exception(string.Format("{0} already exists.", id));
                }

                var item = GetAsyncItemToAdd(funcToRun, id, commandType);

                _processStatus.Add(GetKey(id, commandType), item);
            }
        }
예제 #39
0
		public async Task ProcessCommand_ShouldReturnCorrectValue(
			[Frozen]Mock<IAsyncCommandHandlerFactory> asyncCommandHandlerFactory,
			Mock<IAsyncCommandHandler<IAsyncCommand>> commandHandler,
			IAsyncCommand command,
			string expected,
			AsyncCommandQueryBus sut)
		{
			//arrange
			asyncCommandHandlerFactory.Setup(a => a.Create<IAsyncCommand>()).Returns(commandHandler.Object);
			var verifiable = commandHandler.Setup(q => q.Execute(command)).ReturnsDefaultTaskVerifiable();

			//act
			await sut.ProcessCommand(command);

			//assert
			verifiable.Verify();
		}
예제 #40
0
        public PythonWebLauncher(IServiceProvider serviceProvider, PythonToolsService pyService, IPythonProject project) {
            _pyService = pyService;
            _project = project;
            _serviceProvider = serviceProvider;

            var project2 = project as IPythonProject2;
            if (project2 != null) {
                // The provider may return its own object, but the web launcher only
                // supports instances of CustomCommand.
                _runServerCommand = project2.FindCommand(RunWebServerCommand);
                _debugServerCommand = project2.FindCommand(DebugWebServerCommand);
            }

            var portNumber = _project.GetProperty(PythonConstants.WebBrowserPortSetting);
            int portNum;
            if (Int32.TryParse(portNumber, out portNum)) {
                _testServerPort = portNum;
            }
        }
예제 #41
0
		public async Task ProcessCommand_WhenSubscribingDuringExecution_ShouldNotifyCommandStarted(
			[Frozen]Mock<IAsyncCommandBus> innerCommandBus,
			NotifyCommandStateBus sut,
			IAsyncCommand command,
			[Frozen]TestScheduler scheduler)
		{
			//arrange
			var observer = scheduler.CreateObserver<IAsyncCommand>();
			innerCommandBus.Setup(bus => bus.ProcessCommand(It.IsAny<IAsyncCommand>()))
			.Returns(() =>
			{
				sut.ObserveCommandStarted().Subscribe(observer);
				return Task.FromResult(true);
			});

			//act
			scheduler.AdvanceTo(200);
			await sut.ProcessCommand(command);
			scheduler.Start();

			//assert
			var expected = OnNext(201, command);
			observer.Messages.First().ShouldBeEquivalentTo(expected);
		}
예제 #42
0
		public async Task ProcessCommand_ShouldNotifyCommandError(
			[Frozen]Mock<IAsyncCommandBus> innerCommandBus,
			NotifyCommandStateBus sut,
			IAsyncCommand command,
			[Frozen]TestScheduler scheduler,
			Exception exception)
		{
			//arrange
			var observer = scheduler.CreateObserver<Tuple<IAsyncCommand, Exception>>();
			innerCommandBus.Setup(bus => bus.ProcessCommand(It.IsAny<IAsyncCommand>()))
			.Returns(() =>
			{
				scheduler.AdvanceTo(300);
				throw exception;
			});
			sut.ObserveCommandError().Subscribe(observer);

			//act
			try
			{
				await sut.ProcessCommand(command);
			}
			catch (Exception ex)
			{
				if (ex != exception)
				{
					throw;
				}
			}

			//assert
			var expected = OnNext(300, new Tuple<IAsyncCommand, Exception>(command, exception));
			observer.Messages.First().ShouldBeEquivalentTo(expected);
		}
        public AuthenticateViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IUserService userService)
        {
            if (eventAggregator == null)
            {
                throw new ArgumentNullException("eventAggregator");
            }
            if (regionManager == null)
            {
                throw new ArgumentNullException("regionManager");
            }
            if (userService == null)
            {
                throw new ArgumentNullException("userService");
            }

            this.regionManager = regionManager;
            this.eventAggregator = eventAggregator;
            this.eventAggregator.GetEvent<LoginStatusChangedEvent>().Subscribe(this.LoginStatusChanged, ThreadOption.UIThread);
            this.userService = userService;
            this.PropertyChanged += this.OnLoginPropertyChanged;
            this.PropertyChanged += this.OnCanLoginChanged;

            this.loginCommand = new AsyncCommand<UserQueryResult>(() => this.LoginAsync(), this.CanLogin);
            this.loginAsGuestCommand = new DelegateCommand(this.LoginAsGuest);
            this.selectGameRegionCommand = new DelegateCommand<object>(this.SelectGameRegion);

            this.gameRegions = this.userService.GameRegions.ToList();
            this.SelectedRegion = this.userService.HomeRegion;

            this.Notification = Resources.Disclaimer;
        }
		public async Task ProcessCommand_CallProcessCommand(
			[Frozen]Mock<ICommandEvents> commandEvents,
			[Frozen]Mock<IAsyncCommandBus> commandBus,
			NotifyEventsAsyncCommandBus sut,
			IAsyncCommand command)
		{
			//arrange
			commandBus.Setup(c => c.ProcessCommand(command)).Returns(Task.FromResult(true));

			//act
			await sut.ProcessCommand(command);

			//assert
			commandBus.Verify(c => c.ProcessCommand(command), Times.Once());
		}
        private AsyncContainerItem GetAsyncItemToAdd(IAsyncCommand funcToRun, string id, Type commandType)
        {
            var timer = new Timer(_timeSpan.Time.TotalMilliseconds) { Enabled = false, AutoReset = false };
            timer.Elapsed += (object sender, ElapsedEventArgs e) => RemoveJob(id, commandType);

            var item = new AsyncContainerItem(funcToRun, timer);
            return item;
        }
예제 #46
0
 public VersionRangesVM()
 {
     VersionRanges = new ObservableCollection<EditableVersionRange>();
     DeleteVersionRange = RelayAsyncSimpleCommand.Create(DeleteCurrentVersionRange, () => true);
     CreateVersionRange = RelayAsyncSimpleCommand.Create(CreateNewVersionRange, () => true);
 }
예제 #47
0
 public AbortAsyncCommand([NotNull]IAsyncCommand asyncCommand)
 {
     _asyncCommand = asyncCommand;
     _invokeCanExcecuteChangedAction = new Action(() => CanExecuteChanged.CheckedInvoke(this));
 }
		public void ForCommand_WhenRegisteringCommandTypeTwice_ShouldThrow(
			[Frozen]Mock<IAsyncCommandBus> mockCommandBus,
			ConcurrencyExecutionAsyncCommandBus sut,
			IAsyncCommand command)
		{
			//arrange
			sut.ForCommand<TestCommand>(1);

			//act
			Action action = () => sut.ForCommand<TestCommand>(1);

			//assert
			action.ShouldThrow<ArgumentException>();
		}
 public AsyncContainerItem(IAsyncCommand _command, Timer timer)
 {
     AsyncCommand = _command;
     Timer = timer;
 }
예제 #50
0
		public async Task ProcessCommand_ShouldNotifyCommandStarted(
			[Frozen]Mock<IAsyncCommandBus> innerCommandBus,
			NotifyCommandStateBus sut,
			IAsyncCommand command,
			[Frozen]TestScheduler scheduler)
		{
			//arrange
			var observer = scheduler.CreateObserver<IAsyncCommand>();
			sut.ObserveCommandStarted().Subscribe(observer);

			//act
			scheduler.AdvanceTo(200);
			await sut.ProcessCommand(command);

			//assert
			var expected = OnNext(200, command);
			observer.Messages.First().ShouldBeEquivalentTo(expected);
		}
예제 #51
0
		public void ProcessCommand_WhenCommandHandlerIsNotFound_ShouldThrow(
			[Frozen]Mock<IAsyncCommandHandlerFactory> asyncCommandHandlerFactory,
			Mock<IAsyncCommandHandler<IAsyncCommand>> commandHandler,
			IAsyncCommand command,
			string expected,
			AsyncCommandQueryBus sut)
		{
			//arrange
			asyncCommandHandlerFactory.Setup(a => a.Create<IAsyncCommand>())
				.Throws<InvalidOperationException>();

			//act
			Func<Task> action = async () => await sut.ProcessCommand(command);

			//assert
			action.ShouldThrow<InvalidOperationException>();
		}
예제 #52
0
		public async Task ProcessCommand_WhenSubscribingAfterExecution_ShouldNotNotifyCommandStarted(
			[Frozen]Mock<IAsyncCommandBus> innerCommandBus,
			NotifyCommandStateBus sut,
			IAsyncCommand command,
			[Frozen]TestScheduler scheduler)
		{
			//arrange
			var observer = scheduler.CreateObserver<IAsyncCommand>();
			
			//act
			scheduler.AdvanceTo(200);
			await sut.ProcessCommand(command);
			sut.ObserveCommandStarted().Subscribe(observer);

			//assert
			observer.Values().Should().BeEmpty();
		}
 public static CommandAsyncToOleMenuCommandShim CreateRCmdSetCommand(int id, IAsyncCommand command) => new CommandAsyncToOleMenuCommandShim(RGuidList.RCmdSetGuid, id, command);
 public virtual void ResetTimer(string id, Type commandType, IAsyncCommand asyncFunc)
 {
     lock (_syncRoot)
     {
         if (asyncFunc.Progress.Status != Commands.StatusEnum.Running)
         {
             SetInactive(id, commandType);
         }
         else
         {
             SetActive(id, commandType);
         }
     }
 }
예제 #55
0
 public CountUrlBytesViewModel(MainWindowViewModel parent, string url, IAsyncCommand command)
 {
     LoadingMessage = "Loading (" + url + ")...";
     Command = command;
     RemoveCommand = new DelegateCommand(() => parent.Operations.Remove(this));
 }
예제 #56
0
 static void VerifyService(IAsyncCommand service) {
     if(service == null) throw new ArgumentNullException("service");
 }