コード例 #1
0
        public async Task TraceToggling()
        {
            MockFolderPickerService         folderPicker = new MockFolderPickerService(ApplicationData.Current.TemporaryFolder);
            MockEventLogger                 logger       = new MockEventLogger();
            IDiagnosticTraceButtonViewModel vm           = CreateViewModel(folderPicker, logger);

            Assert.AreEqual(StartTraceLabel, vm.Label, "Initial ViewModel label should indicate tracing will start");
            Assert.IsFalse(vm.IsTracing, "ViewModel should not be tracing initially");
            Assert.IsFalse(logger.IsTracing, "Logger should not be tracing initially");
            Assert.IsTrue(vm.Command.CanExecute(null), "ViewModel trace button should be enabled initially");

            int eventsTraced = 0;

            logger.EventTraced += (s, e) =>
            {
                eventsTraced++;
            };

            bool folderLaunched = false;

            folderPicker.FolderLaunched += (s, e) =>
            {
                folderLaunched = true;
            };

            await vm.Command.ExecuteAsync(null);

            Assert.AreEqual(StopTraceLabel, vm.Label, "ViewModel label after starting a trace should indicate tracing will stop");
            Assert.IsTrue(vm.IsTracing, "ViewModel should be tracing after using the trace button");
            Assert.IsTrue(logger.IsTracing, "Logger should be tracing after using the trace button");
            Assert.AreEqual(1, eventsTraced, "Starting a trace should fire an event");
            Assert.IsFalse(folderLaunched, "Folder should not be launched until tracing stops");

            await vm.Command.ExecuteAsync(null);

            Assert.AreEqual(StartTraceLabel, vm.Label, "ViewModel label after ending a trace should indicate tracing will start again");
            Assert.IsFalse(vm.IsTracing, "ViewModel should not be tracing after using the trace button a second time");
            Assert.IsFalse(logger.IsTracing, "Logger should not be tracing after using the trace button a second time");
            Assert.AreEqual(2, eventsTraced, "Stopping a trace should fire a second event");
            Assert.IsTrue(folderLaunched, "Folder should be launched once tracing stops");
        }
コード例 #2
0
ファイル: HelpViewModel.cs プロジェクト: sfuqua/PassKeep
 /// <summary>
 /// Initializes the ViewModel with the given dependencies.
 /// </summary>
 /// <param name="traceViewModel"></param>
 public HelpViewModel(IDiagnosticTraceButtonViewModel traceViewModel)
 {
     this.traceViewModel = traceViewModel;
 }