Пример #1
0
        public void Removing_First_MainDisplayInfoChanged_Invokes_Correct_Members()
        {
            var onChangedInvokeCount = 0;
            var display = new MyDisplay();

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

            DeviceDisplay.MainDisplayInfoChanged -= OnChanged;

            Assert.Equal(0, display.StartedCount);
            Assert.Equal(1, display.StoppedCount);
            Assert.Equal(0, display.AddedCount);
            Assert.Equal(0, 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);

            void OnChanged(object sender, DisplayInfoChangedEventArgs e)
            {
                onChangedInvokeCount++;
            }
        }
Пример #2
0
 public virtual void TearDown()
 {
     Device.PlatformServices = null;
     DeviceDisplay.SetCurrent(null);
     System.Threading.Thread.CurrentThread.CurrentCulture   = _defaultCulture;
     System.Threading.Thread.CurrentThread.CurrentUICulture = _defaultUICulture;
     DispatcherProvider.SetCurrent(null);
 }
Пример #3
0
 public virtual void Setup()
 {
     _defaultCulture         = System.Threading.Thread.CurrentThread.CurrentCulture;
     _defaultUICulture       = System.Threading.Thread.CurrentThread.CurrentUICulture;
     Device.PlatformServices = new MockPlatformServices();
     DispatcherProvider.SetCurrent(new DispatcherProviderStub());
     DeviceDisplay.SetCurrent(null);
 }
Пример #4
0
        public void Setting_Null_Is_Default()
        {
            DeviceDisplay.SetCurrent(new MyDisplay());
            DeviceDisplay.SetCurrent(null);

            Assert.NotNull(DeviceDisplay.Current);
            Assert.Equal("DeviceDisplayImplementation", DeviceDisplay.Current.GetType().Name);
        }
Пример #5
0
 public virtual void TearDown()
 {
     MockPlatformSizeService.Current?.Reset();
     AppInfo.SetCurrent(null);
     DeviceDisplay.SetCurrent(null);
     DeviceInfo.SetCurrent(null);
     System.Threading.Thread.CurrentThread.CurrentCulture   = _defaultCulture;
     System.Threading.Thread.CurrentThread.CurrentUICulture = _defaultUICulture;
     DispatcherProvider.SetCurrent(null);
 }
Пример #6
0
 public virtual void Setup()
 {
     Microsoft.Maui.Controls.Hosting.CompatibilityCheck.UseCompatibility();
     _defaultCulture   = System.Threading.Thread.CurrentThread.CurrentCulture;
     _defaultUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
     MockPlatformSizeService.Current?.Reset();
     DispatcherProvider.SetCurrent(new DispatcherProviderStub());
     DeviceDisplay.SetCurrent(null);
     DeviceInfo.SetCurrent(null);
     AppInfo.SetCurrent(null);
 }
Пример #7
0
        public void Setting_Custom_Invokes_Correct_Members()
        {
            var display = new MyDisplay();

            DeviceDisplay.SetCurrent(display);

            Assert.Equal(0, display.StartedCount);
            Assert.Equal(0, display.StoppedCount);
            Assert.Equal(1, 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);
        }
Пример #8
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);
        }
Пример #9
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++;
            }
        }
Пример #10
0
 public override void Setup()
 {
     base.Setup();
     Device.PlatformServices = new MockPlatformServices();
     DeviceDisplay.SetCurrent(new MockDeviceDisplay());
 }
Пример #11
0
 public override void Setup()
 {
     base.Setup();
     DeviceDisplay.SetCurrent(new MockDeviceDisplay());
 }
Пример #12
0
 public override void Setup()
 {
     base.Setup();
     DeviceDisplay.SetCurrent(mockDeviceDisplay = new MockDeviceDisplay());
     DeviceInfo.SetCurrent(mockDeviceInfo       = new MockDeviceInfo());
 }
Пример #13
0
 public void Dispose()
 {
     DeviceDisplay.SetCurrent(null);
 }
Пример #14
0
 public override void Setup()
 {
     base.Setup();
     mockDeviceDisplay = new TestDeviceDisplay();
     DeviceDisplay.SetCurrent(mockDeviceDisplay);
 }