Beispiel #1
0
        public void Removing_Second_MainDisplayInfoChanged_Invokes_Correct_Members()
        {
            var onChangedInvokeCount = 0;
            var display = new MyDisplay();

            DeviceDisplay.SetCurrent(display);
            DeviceDisplay.MainDisplayInfoChanged += OnChanged;
            DeviceDisplay.MainDisplayInfoChanged += OnChanged;
            display.ResetCounts();

            DeviceDisplay.MainDisplayInfoChanged -= OnChanged;

            Assert.Equal(0, display.StartedCount);
            Assert.Equal(0, display.StoppedCount);
            Assert.Equal(0, display.AddedCount);
            Assert.Equal(1, display.RemovedCount);
            Assert.Equal(0, display.SetKeepScreenOnCount);
            Assert.Equal(0, display.GetKeepScreenOnCount);
            Assert.Equal(0, display.GetMainDisplayInfoCount);
            Assert.Equal(0, onChangedInvokeCount);

            Assert.False(display.KeepScreenOn);

            DeviceDisplay.MainDisplayInfoChanged -= OnChanged;
            DeviceDisplay.MainDisplayInfoChanged -= OnChanged;

            void OnChanged(object sender, DisplayInfoChangedEventArgs e)
            {
                onChangedInvokeCount++;
            }
        }
Beispiel #2
0
        public void Swapping_With_KeepScreenOn_Invokes_Correct_Members()
        {
            var onChangedInvokeCount = 0;
            var display1             = new MyDisplay();
            var display2             = new MyDisplay();

            DeviceDisplay.SetCurrent(display1);
            DeviceDisplay.KeepScreenOn = true;
            display1.ResetCounts();

            DeviceDisplay.SetCurrent(display2);

            // old
            Assert.Equal(0, display1.StartedCount);
            Assert.Equal(0, display1.StoppedCount);
            Assert.Equal(0, display1.AddedCount);
            Assert.Equal(1, display1.RemovedCount);
            Assert.Equal(1, display1.GetKeepScreenOnCount);
            Assert.Equal(0, display1.GetMainDisplayInfoCount);
            Assert.Equal(0, onChangedInvokeCount);
            Assert.False(display1.KeepScreenOn);

            // new
            Assert.Equal(0, display2.StartedCount);
            Assert.Equal(0, display2.StoppedCount);
            Assert.Equal(1, display2.AddedCount);
            Assert.Equal(0, display2.RemovedCount);
            Assert.Equal(1, display2.SetKeepScreenOnCount);
            Assert.Equal(0, display2.GetKeepScreenOnCount);
            Assert.Equal(1, display2.GetMainDisplayInfoCount);
            Assert.Equal(0, onChangedInvokeCount);
            Assert.True(display2.KeepScreenOn);
        }
Beispiel #3
0
        public void Setting_KeepScreenOn_Invokes_Correct_Members()
        {
            var display = new MyDisplay();

            DeviceDisplay.SetCurrent(display);
            display.ResetCounts();

            DeviceDisplay.KeepScreenOn = true;

            Assert.Equal(0, display.StartedCount);
            Assert.Equal(0, display.StoppedCount);
            Assert.Equal(0, display.AddedCount);
            Assert.Equal(0, display.RemovedCount);
            Assert.Equal(1, display.SetKeepScreenOnCount);
            Assert.Equal(0, display.GetKeepScreenOnCount);
            Assert.Equal(0, display.GetMainDisplayInfoCount);

            Assert.True(display.KeepScreenOn);
        }
Beispiel #4
0
        public void MainDisplayInfo_Invokes_Correct_Members()
        {
            var expected = new DisplayInfo(100, 100, 2, DisplayOrientation.Portrait, DisplayRotation.Rotation0);
            var display  = new MyDisplay(expected);

            DeviceDisplay.SetCurrent(display);
            display.ResetCounts();

            var main = DeviceDisplay.MainDisplayInfo;

            Assert.Equal(expected, main);

            Assert.Equal(0, display.StartedCount);
            Assert.Equal(0, display.StoppedCount);
            Assert.Equal(0, display.AddedCount);
            Assert.Equal(0, display.RemovedCount);
            Assert.Equal(0, display.SetKeepScreenOnCount);
            Assert.Equal(0, display.GetKeepScreenOnCount);
            Assert.Equal(1, display.GetMainDisplayInfoCount);

            Assert.False(display.KeepScreenOn);
        }
Beispiel #5
0
        public void Swapping_With_MainDisplayInfoChanged_Invokes_Correct_Members()
        {
            var onChangedInvokeCount = 0;
            var display1             = new MyDisplay();
            var display2             = new MyDisplay();

            DeviceDisplay.SetCurrent(display1);
            DeviceDisplay.MainDisplayInfoChanged += OnChanged;
            display1.ResetCounts();

            DeviceDisplay.SetCurrent(display2);

            // old
            Assert.Equal(0, display1.StartedCount);
            Assert.Equal(1, display1.StoppedCount);
            Assert.Equal(0, display1.AddedCount);
            Assert.Equal(1, display1.RemovedCount);
            Assert.Equal(1, display1.GetKeepScreenOnCount);
            Assert.Equal(0, display1.GetMainDisplayInfoCount);
            Assert.Equal(0, onChangedInvokeCount);
            Assert.False(display1.KeepScreenOn);

            // new
            Assert.Equal(1, display2.StartedCount);
            Assert.Equal(0, display2.StoppedCount);
            Assert.Equal(1, display2.AddedCount);
            Assert.Equal(0, display2.RemovedCount);
            Assert.Equal(0, display2.SetKeepScreenOnCount);
            Assert.Equal(0, display2.GetKeepScreenOnCount);
            Assert.Equal(1, display2.GetMainDisplayInfoCount);
            Assert.Equal(0, onChangedInvokeCount);
            Assert.False(display2.KeepScreenOn);

            void OnChanged(object sender, DisplayInfoChangedEventArgs e)
            {
                onChangedInvokeCount++;
            }
        }