private void Bootstrap(CommandLineArguments commandLineArguments) { var server = BootstrapServer(commandLineArguments.BaseUrl); var authenticationService = new AuthenticationService(server); statusPublisher = new StatusPublisher(server, authenticationService); var standUpModel = new StandUpModel(new DispatcherTimerWrapper(), commandLineArguments.DeskStateTimes.SittingTime, commandLineArguments.DeskStateTimes.StandingTime); standUpModel.DeskStateChanged += async(s, f) => await statusPublisher.PublishChangedDeskState(f.NewDeskState); var standUpViewModel = new StandUpViewModel(standUpModel, authenticationService, this); standUpViewModel.PropertyChanged += (sender, eventArgs) => { if (eventArgs.PropertyName.Equals("AuthenticationStatus")) { Task.Run(async() => await statusPublisher.PublishChangedDeskState(standUpModel.DeskState)); } }; MainWindow = new MainWindow(standUpViewModel); MainWindow.Show(); if (commandLineArguments.Update) { updateTask = Task.Run(async() => { using (var mgr = new UpdateManager(Settings.Default.UpdateUrl, "StandUpTimer")) { await mgr.UpdateApp(); } }); } }
public void You_cannot_end_a_desk_state_without_starting_it_first() { var target = new StandUpViewModel(Model, A.Fake <IAuthenticationService>(), A.Fake <IBringToForeground>()); target.DeskStateEnded(); Assert.Throws <InvalidOperationException>(target.DeskStateEnded); }
public void When_a_new_desk_state_started_Hide_the_OK_button() { var target = new StandUpViewModel(Model, A.Fake <IAuthenticationService>(), A.Fake <IBringToForeground>()); target.DeskStateEnded(); target.DeskStateStarted(); Assert.That(target.OkButtonVisibility, Is.EqualTo(Visibility.Collapsed)); }
public void When_the_desk_state_ended_Bring_the_app_into_the_foreground() { var bringToForeground = A.Fake <IBringToForeground>(); var target = new StandUpViewModel(Model, A.Fake <IAuthenticationService>(), bringToForeground); target.DeskStateEnded(); A.CallTo(() => bringToForeground.Now()).MustHaveHappened(); }
public void Skipping_a_desk_state_ends_it_and_starts_the_new_leg() { var target = new StandUpViewModel(Model, A.Fake <IAuthenticationService>(), A.Fake <IBringToForeground>()); Assert.That(target.CurrentImage, Does.Contain("sitting")); target.SkipCommand.Execute(null); Assert.That(target.CurrentImage, Does.Contain("standing")); Assert.That(target.OkButtonVisibility, Is.EqualTo(Visibility.Collapsed)); }
public void When_the_desk_state_of_the_model_changes_Set_the_according_image() { var model = Model; var target = new StandUpViewModel(model, A.Fake <IAuthenticationService>(), A.Fake <IBringToForeground>()); Assert.That(target.CurrentImage, Does.Contain("sitting")); model.Skip(); Assert.That(target.CurrentImage, Does.Contain("standing")); }
public MainWindow(StandUpViewModel standUpViewModel) { DataContext = this.standUpViewModel = standUpViewModel; Left = Settings.Default.Left; Top = Settings.Default.Top; InitializeComponent(); TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal; }
public void When_the_authentication_state_changes_Propagate_that_event() { var authenticationService = A.Fake <IAuthenticationService>(); var raised = false; var target = new StandUpViewModel(Model, authenticationService, A.Fake <IBringToForeground>()); target.PropertyChanged += (sender, args) => { raised = args.PropertyName.Equals("AuthenticationStatus"); }; authenticationService.AuthenticationStateChanged += Raise.WithEmpty(); Assert.That(raised, Is.True); }
public void You_cannot_start_a_desk_state_when_it_already_runs() { var target = new StandUpViewModel(Model, A.Fake <IAuthenticationService>(), A.Fake <IBringToForeground>()); Assert.Throws <InvalidOperationException>(target.DeskStateStarted); }