예제 #1
0
        public void Rewind_3_BeyondAllIntervals()
        {
            // Configure
            int config_IntervalCount = 2;
            int config_IntervalSpan  = 60;
            int config_RewindAmount  = (int)(config_IntervalSpan * (config_IntervalCount + 0.5));

            TestLog.WriteLine("---Test config:");
            TestLog.WriteLine($"Intervals: {config_IntervalCount}");
            TestLog.WriteLine($"Interval spans: {config_IntervalSpan}");
            TestLog.WriteLine($"Amount rewound: {config_RewindAmount}");

            // Impacted State
            TestState <string>           activeTaskName = new TestState <string>(nameof(activeTaskName));
            TestState <DateTimeOffset>   appTime        = new TestState <DateTimeOffset>(nameof(appTime));
            TestStateList <IntervalData> intervals      = new TestStateList <IntervalData>(nameof(intervals));

            // Setup
            this.app.ActiveSession.Navigate();
            this.common.MakeIntervals(config_IntervalCount, config_IntervalSpan);

            TestLog.WriteLine("---Define expected post-test state");
            {
                {
                    var initialTime = this.app.ActiveSession.DevTimeBar.DateTime;
                    TestLog.WriteLine($"Initial time: {initialTime}");
                    appTime.Expected = initialTime - TimeSpan.FromMinutes(config_IntervalCount * config_IntervalSpan);
                }
                {
                    var initialIntervals = this.app.ActiveSession.Session.Intervals;
                    TestLog.OutputCollection <UiInterval>("Initial intervals", initialIntervals);
                    intervals.Expected = IntervalData.Copy(initialIntervals, 0);
                }
                {
                    activeTaskName.Expected = null;
                }
            }

            // Test
            this.app.ActiveSession.DevTimeBar.Rewind(config_RewindAmount);

            // Define Restore
            this.Restore = () => this.common.RemoveIntervals();

            // Confirm
            this.app.ActiveSession.Refresh();

            TestLog.WriteLine($"---Post-test state");
            {
                appTime.Actual        = this.app.ActiveSession.DevTimeBar.DateTime;
                intervals.Actual      = IntervalData.Copy(this.app.ActiveSession.Session.Intervals);
                activeTaskName.Actual = this.app.ActiveSession.TaskSelector.ItemSelected;
            }

            Assert.Equal(appTime.Expected, appTime.Actual);
            Assert.Equal(activeTaskName.Expected, activeTaskName.Actual);
            Assert.Equal(intervals.Expected, intervals.Actual);
        }
예제 #2
0
        public void StatePreservedOnReturnNavigation()
        {
            // Configure
            int config_IntervalCount = 2;
            int config_IntervalSpan  = 60;

            TestLog.WriteLine("---Test config:");
            TestLog.WriteLine($"Intervals: {config_IntervalCount}");
            TestLog.WriteLine($"Interval spans: {config_IntervalSpan}");

            // Impacted State
            TestState <string>           activeTaskName = new TestState <string>(nameof(activeTaskName));
            TestStateList <IntervalData> intervals      = new TestStateList <IntervalData>(nameof(intervals));

            // Setup
            this.app.ActiveSession.Navigate();
            this.common.MakeIntervals(config_IntervalCount, config_IntervalSpan);

            TestLog.WriteLine("---Define expected post-test state");
            {
                {
                    var initialIntervals = this.app.ActiveSession.Session.Intervals;
                    TestLog.OutputCollection <UiInterval>("Initial intervals", initialIntervals);
                    intervals.Expected = IntervalData.Copy(initialIntervals);
                }
                {
                    activeTaskName.Expected = this.app.ActiveSession.TaskSelector.ItemSelected;
                }
            }

            // Test
            this.app.Settings.Navigate();
            this.app.ActiveSession.Navigate();

            // Define Restore
            this.Restore = () => this.common.RemoveIntervals();

            // Confirm
            this.app.ActiveSession.Refresh();

            TestLog.WriteLine($"---Post-test state");
            {
                intervals.Actual      = IntervalData.Copy(this.app.ActiveSession.Session.Intervals);
                activeTaskName.Actual = this.app.ActiveSession.TaskSelector.ItemSelected;
            }

            Assert.Equal(activeTaskName.Expected, activeTaskName.Actual);
            Assert.Equal(intervals.Expected, intervals.Actual);
        }
예제 #3
0
 internal string IntervalsTaskName(IntervalData interval)
 {
     return(this.IntervalsTaskName(interval.Name));
 }
예제 #4
0
 // Class Methods
 internal static List <IntervalData> Copy(IReadOnlyCollection <UiInterval> uiIntervals)
 {
     return(IntervalData.Copy(uiIntervals, uiIntervals.Count));
 }
예제 #5
0
        // Methods

        public bool Equals(IntervalData other)
        {
            return((this.Start == other.Start) && (this.Span == other.Span));
        }
예제 #6
0
        public void RemoveLastInterval_1(int remove)
        {
            // Configure
            int config_IntervalCount    = 2;
            int config_IntervalSpan     = 60;
            int config_IntervalsRemoved = remove;

            TestLog.WriteLine("---Test config:");
            TestLog.WriteLine($"Intervals: {config_IntervalCount}");
            TestLog.WriteLine($"Interval spans: {config_IntervalSpan}");
            TestLog.WriteLine($"Num of intervals removed: {config_IntervalsRemoved}");

            // Impacted State
            TestState <string>           activeTaskName = new TestState <string>(nameof(activeTaskName));
            TestState <DateTimeOffset>   appTime        = new TestState <DateTimeOffset>(nameof(appTime));
            TestStateList <IntervalData> intervals      = new TestStateList <IntervalData>(nameof(intervals));

            // Setup
            this.app.ActiveSession.Navigate();
            this.common.MakeIntervals(config_IntervalCount, config_IntervalSpan);

            TestLog.WriteLine("---Define expected post-test state");
            {
                {
                    var initialTime = this.app.ActiveSession.DevTimeBar.DateTime;
                    TestLog.WriteLine($"Initial time: {initialTime}");
                    var multiplier = (config_IntervalsRemoved >= config_IntervalCount) ? config_IntervalCount : config_IntervalsRemoved;
                    appTime.Expected = initialTime - TimeSpan.FromMinutes(config_IntervalSpan * multiplier);
                }
                {
                    var initialIntervals = this.app.ActiveSession.Session.Intervals;
                    TestLog.OutputCollection <UiInterval>("Initial intervals", initialIntervals);
                    var copyCount = config_IntervalCount - config_IntervalsRemoved;
                    intervals.Expected = IntervalData.Copy(initialIntervals, copyCount);
                }
                {
                    activeTaskName.Expected = this.common.IntervalsTaskName(intervals.Expected.LastOrDefault());
                }
            }

            // Test
            for (int i = 0; i < config_IntervalsRemoved; i++)
            {
                this.app.ActiveSession.DevTimeBar.RemoveLastInterval();
            }

            // Define Restore
            this.Restore = () => this.common.RemoveIntervals();

            // Confirm
            this.app.ActiveSession.Refresh();

            TestLog.WriteLine($"---Post-test state");
            {
                appTime.Actual        = this.app.ActiveSession.DevTimeBar.DateTime;
                intervals.Actual      = IntervalData.Copy(this.app.ActiveSession.Session.Intervals);
                activeTaskName.Actual = this.app.ActiveSession.TaskSelector.ItemSelected;
            }

            Assert.Equal(appTime.Expected, appTime.Actual);
            Assert.Equal(activeTaskName.Expected, activeTaskName.Actual);
            Assert.Equal(intervals.Expected, intervals.Actual);
        }
예제 #7
0
        public void RemoveLastInterval_2_Continue()
        {
            // Configure
            int config_IntervalCount = 2;
            int config_IntervalSpan  = 60;
            int config_ActiveIntervalContinuedProgression = 30;

            TestLog.WriteLine("---Test config:");
            TestLog.WriteLine($"Intervals: {config_IntervalCount}");
            TestLog.WriteLine($"Interval spans: {config_IntervalSpan}");
            TestLog.WriteLine($"Active interval progression post successor's removal: {config_ActiveIntervalContinuedProgression}");

            // Impacted State
            TestState <string>           activeTaskName = new TestState <string>(nameof(activeTaskName));
            TestState <DateTimeOffset>   appTime        = new TestState <DateTimeOffset>(nameof(appTime));
            TestStateList <IntervalData> intervals      = new TestStateList <IntervalData>(nameof(intervals));

            // Setup
            this.app.ActiveSession.Navigate();
            this.common.MakeIntervals(config_IntervalCount, config_IntervalSpan);

            TestLog.WriteLine("---Define expected post-test state");
            {
                {
                    var initialTime = this.app.ActiveSession.DevTimeBar.DateTime;
                    TestLog.WriteLine($"Initial time: {initialTime}");
                    var mins = config_ActiveIntervalContinuedProgression - config_IntervalSpan;
                    appTime.Expected = initialTime + TimeSpan.FromMinutes(mins);
                }
                {
                    var initialIntervals = this.app.ActiveSession.Session.Intervals;
                    TestLog.OutputCollection <UiInterval>("Initial intervals", initialIntervals);
                    var intervalData = IntervalData.Copy(initialIntervals, initialIntervals.Count - 1);

                    var index = config_IntervalCount - 2;
                    intervalData[index] = new IntervalData(
                        intervalData[index].Start,
                        intervalData[index].Span + TimeSpan.FromMinutes(config_ActiveIntervalContinuedProgression),
                        intervalData[index].Name);
                    intervals.Expected = intervalData;
                }
                {
                    activeTaskName.Expected = this.common.IntervalsTaskName(intervals.Expected.Last().Name);
                }
            }

            // Test
            this.app.ActiveSession.DevTimeBar.RemoveLastInterval();
            this.app.ActiveSession.DevTimeBar.FastForward(config_ActiveIntervalContinuedProgression);

            // Define Restore
            this.Restore = () => this.common.RemoveIntervals();

            // Confirm
            this.app.ActiveSession.Refresh();

            TestLog.WriteLine($"---Post-test state");
            {
                appTime.Actual        = this.app.ActiveSession.DevTimeBar.DateTime;
                intervals.Actual      = IntervalData.Copy(this.app.ActiveSession.Session.Intervals);
                activeTaskName.Actual = this.app.ActiveSession.TaskSelector.ItemSelected;
            }

            Assert.Equal(appTime.Expected, appTime.Actual);
            Assert.Equal(activeTaskName.Expected, activeTaskName.Actual);
            Assert.Equal(intervals.Expected, intervals.Actual);
        }
예제 #8
0
        public void IntervalAdd()
        {
            // Configure
            int config_IntervalCount = 1;
            int config_IntervalSpan  = 60;
            int config_TaskIndex     = 1;

            TestLog.WriteLine("---Test config:");
            TestLog.WriteLine($"Intervals: {config_IntervalCount}");
            TestLog.WriteLine($"Interval spans: {config_IntervalSpan}");
            TestLog.WriteLine($"Task index to create interval: {config_TaskIndex}");

            // Impacted State
            TestStateList <IntervalData> intervals    = new TestStateList <IntervalData>(nameof(intervals));
            TestState <string>           intervalTask = new TestState <string>(nameof(intervalTask));

            // Setup
            this.app.ActiveSession.Navigate();

            TestLog.WriteLine("---Define expected post-test state");
            {
                {
                    var initialIntervals = this.app.ActiveSession.Session.Intervals;
                    TestLog.OutputCollection <UiInterval>("Initial intervals", initialIntervals);
                }
                {
                    var taskNames = this.app.ActiveSession.TaskSelector.ItemNames;
                    TestLog.OutputCollection("Tasks", taskNames);
                    Assert.NotEmpty(taskNames);
                    intervalTask.Expected = taskNames.ElementAt(config_TaskIndex);
                }
                {
                    var intervalData = new List <IntervalData>();
                    intervalData.Add(new IntervalData(
                                         this.app.ActiveSession.DevTimeBar.DateTime.TimeOfDay,
                                         TimeSpan.FromMinutes(config_IntervalSpan)));
                    intervals.Expected = intervalData;
                }
            }

            // Test
            var success = this.app.ActiveSession.TaskSelector.Select(intervalTask.Expected);

            Assert.True(success);
            this.app.ActiveSession.DevTimeBar.FastForward(config_IntervalSpan);

            // Define Restore
            this.Restore = () => this.common.RemoveIntervals();

            // Confirm
            this.app.ActiveSession.Refresh();

            TestLog.WriteLine($"---Post-test state");
            {
                intervals.Actual    = IntervalData.Copy(this.app.ActiveSession.Session.Intervals);
                intervalTask.Actual = this.common.IntervalsTaskName(intervals.Actual.LastOrDefault());
            }

            Assert.Equal(intervalTask.Expected, intervalTask.Actual);
            Assert.Equal(intervals.Expected, intervals.Actual);
        }
예제 #9
0
        public void IntervalResize_SlideFront()
        {
            // Configure
            int config_IntervalCount        = 3;
            int config_IntervalSpan         = 60;
            int config_IndexSlidingInterval = 1;
            int config_SlideOffset          = 10;

            TestLog.WriteLine("---Test config:");
            TestLog.WriteLine($"Intervals: {config_IntervalCount}");
            TestLog.WriteLine($"Interval spans: {config_IntervalSpan}");
            TestLog.WriteLine($"Interval index to slide: {config_IndexSlidingInterval}");
            TestLog.WriteLine($"Slide delta: {config_SlideOffset}");

            // Impacted State
            TestStateList <IntervalData> intervals = new TestStateList <IntervalData>(nameof(intervals));

            // Setup
            this.app.ActiveSession.Navigate();
            this.common.MakeIntervals(config_IntervalCount, config_IntervalSpan);

            TestLog.WriteLine("---Define expected post-test state");
            {
                List <IntervalData> intervalData;
                {
                    var initialIntervals = this.app.ActiveSession.Session.Intervals;
                    TestLog.OutputCollection <UiInterval>("Initial intervals", initialIntervals);
                    intervalData = IntervalData.Copy(initialIntervals);
                }

                var slideTimeSpan = TimeSpan.FromMinutes(config_SlideOffset);
                {
                    var index = config_IndexSlidingInterval - 1;
                    intervalData[index] = new IntervalData(
                        intervalData[index].Start,
                        intervalData[index].Span + slideTimeSpan,
                        intervalData[index].Name);

                    index++;
                    intervalData[index] = new IntervalData(
                        intervalData[index].Start + slideTimeSpan,
                        intervalData[index].Span - slideTimeSpan,
                        intervalData[index].Name);
                }
                intervals.Expected = intervalData;
            }
            // Test
            var slidingInterval = this.app.ActiveSession.Session.Intervals.ElementAt(config_IndexSlidingInterval);

            slidingInterval.Click();
            slidingInterval.Resize(UiElement.Part.Front, config_SlideOffset);

            // Define Restore
            this.Restore = () => this.common.RemoveIntervals();

            // Confirm
            this.app.ActiveSession.Refresh();

            TestLog.WriteLine($"---Post-test state");
            {
                intervals.Actual = IntervalData.Copy(this.app.ActiveSession.Session.Intervals);
            }

            TestLog.WriteLine($"---Note: Appium cursor moves occasionally result in +/- 1 pixel of requested");
            var oneMinute = TimeSpan.FromMinutes(1);

            for (int i = 0; i < intervals.Actual.Count; i++)
            {
                Assert.InRange(
                    intervals.Actual.ElementAt(i).Start,
                    intervals.Expected.ElementAt(i).Start - oneMinute,
                    intervals.Expected.ElementAt(i).Start + oneMinute);

                Assert.InRange(
                    intervals.Actual.ElementAt(i).Span,
                    intervals.Expected.ElementAt(i).Span - oneMinute,
                    intervals.Expected.ElementAt(i).Span + oneMinute);
            }
        }