public void TestStepCount() { var tour = new Tour(); tour.Steps = new[] { new Step("1", "Header1", "Content1", "ID1"), new Step("2", "Header2", "Content2", "ID2"), new Step("3", "Header2", "Content2", "ID2"), }; var manager = new VisualElementManagerMock(tour.Steps); var tourRun = new TourRun(tour, manager, new WindowManagerMock(), new PopupNavigatorMock()); FeatureTour.SetTourRun(tourRun); tourRun.Start(); var vm = tourRun.GetPrivateField <TourViewModel>("myTourViewModel"); Assert.AreEqual(false, vm.HasTourFinished); Assert.AreEqual(3, vm.TotalStepsCount); Assert.AreEqual(1, vm.CurrentStepNo); tourRun.NextStep(); Assert.AreEqual(false, vm.HasTourFinished); Assert.AreEqual(3, vm.TotalStepsCount); Assert.AreEqual(2, vm.CurrentStepNo); tourRun.NextStep(); Assert.AreEqual(true, vm.HasTourFinished); Assert.AreEqual(3, vm.TotalStepsCount); Assert.AreEqual(3, vm.CurrentStepNo); tourRun.NextStep(); Assert.AreEqual(true, vm.HasTourFinished); Assert.AreEqual(3, vm.TotalStepsCount); Assert.AreEqual(3, vm.CurrentStepNo); tourRun.PreviousStep(); Assert.AreEqual(false, vm.HasTourFinished); Assert.AreEqual(3, vm.TotalStepsCount); Assert.AreEqual(2, vm.CurrentStepNo); FeatureTour.SetCurrentRunNull(); }
public void TestCompleteRun_2Steps_UsingNavigator() { var navigator = FeatureTour.GetNavigator(); var tour = new Tour(); tour.Steps = new[] { new Step("1", "Header1", "Content1"), new Step("2", "Header2", "Content2"), }; var manager = new VisualElementManagerMock(tour.Steps); var windowManager = new WindowManagerMock(); var popupNavigator = new PopupNavigatorMock(); var tourRun = new TourRun(tour, manager, windowManager, popupNavigator); FeatureTour.SetTourRun(tourRun); tourRun.Start(); Assert.AreEqual(tour.Steps[0], FeatureTour.CurrentStep); Assert.IsTrue(navigator.IfCurrentStepEquals(FeatureTour.CurrentStep.ID).GoNext()); Assert.AreEqual(tour.Steps[1], FeatureTour.CurrentStep); Assert.IsFalse(navigator.IfCurrentStepEquals(FeatureTour.CurrentStep.ID).GoNext()); Assert.AreEqual(tour.Steps[1], FeatureTour.CurrentStep); Assert.IsTrue(navigator.IfCurrentStepEquals(FeatureTour.CurrentStep.ID).GoPrevious()); Assert.AreEqual(tour.Steps[0], FeatureTour.CurrentStep); Assert.IsFalse(navigator.IfCurrentStepEquals(FeatureTour.CurrentStep.ID).GoPrevious()); Assert.AreEqual(tour.Steps[0], FeatureTour.CurrentStep); Assert.IsTrue(navigator.Close()); Assert.AreEqual(null, FeatureTour.CurrentStep); AssertManagerIsClean(popupNavigator, windowManager); FeatureTour.SetCurrentRunNull(); }
/// <summary> /// Starts the tour. /// </summary> public void Start() { Log.Debug("Starting tour: " + (Name ?? "<null>")); var run = new TourRun(this, TourHelper.VisualElementManager, TourHelper.WindowManager, TourHelper.PopupNavigator); try { FeatureTour.SetTourRun(run); run.Start(); } catch (LicenseException licEx) { MessageBox.Show("Your copy of FeatureTour is not licensed: " + licEx.Message, "FeatureTour not licensed", MessageBoxButton.OK, MessageBoxImage.Warning); } catch (Exception ex) { Log.Error("Tour.Start: Unhandled Exception.", ex); } }
public void OnStepEnteredLeavedClosed() { var c = new Counter(); var navigator = FeatureTour.GetNavigator(); navigator.OnStepEntered("ID1").Execute(s => c.entered1++); navigator.OnStepEntered("ID2").Execute(s => c.entered2++); navigator.OnStepLeft("ID1").Execute(s => c.leaved1++); navigator.OnStepLeft("ID2").Execute(s => c.leaved2++); navigator.OnClosed().Execute(s => c.closed++); var tour = new Tour(); tour.Steps = new[] { new Step("1", "Header1", "Content1", "ID1"), new Step("2", "Header2", "Content2", "ID2"), }; var manager = new VisualElementManagerMock(tour.Steps); var tourRun = new TourRun(tour, manager, new WindowManagerMock(), new PopupNavigatorMock()); AssertIsCounter(c, 0, 0, 0, 0, 0); FeatureTour.SetTourRun(tourRun); AssertIsCounter(c, 0, 0, 0, 0, 0); tourRun.Start(); AssertIsCounter(c, 1, 0, 0, 0, 0); tourRun.NextStep(); AssertIsCounter(c, 1, 1, 1, 0, 0); tourRun.PreviousStep(); AssertIsCounter(c, 2, 1, 1, 1, 0); tourRun.Close(); AssertIsCounter(c, 2, 2, 1, 1, 1); FeatureTour.SetCurrentRunNull(); }