Ejemplo n.º 1
0
        public async Task FlyoutHeaderReactsToChanges()
        {
            var shell         = CreateShell();
            var initialHeader = new Label()
            {
                Text = "Hello"
            };
            var newHeader = new Label()
            {
                Text = "Hello part 2"
            };

            shell.FlyoutHeader = initialHeader;
            await shell.Dispatcher.DispatchAsync(async() =>
            {
#pragma warning disable CS0612 // Type or member is obsolete
                TestActivity testSurface = null;
                try
                {
                    testSurface   = await TestActivity.GetTestSurface(Context, shell);
                    var addedView = shell.GetRenderer().View;
                    Assert.IsNotNull(addedView);
                    Assert.IsNull(newHeader.GetValue(Platform.RendererProperty));
                    Assert.IsNotNull(initialHeader.GetValue(Platform.RendererProperty));
                    await shell.Dispatcher.DispatchAsync(() => shell.FlyoutHeader = newHeader);
                    Assert.IsNotNull(newHeader.GetValue(Platform.RendererProperty), "New Header Not Set Up");
                    Assert.IsNull(initialHeader.GetValue(Platform.RendererProperty), "Old Header Still Set Up");
                }
                finally
                {
                    testSurface?.Finish();
                }
#pragma warning restore CS0612 // Type or member is obsolete
            });
        }
Ejemplo n.º 2
0
        public async Task FlyoutHeaderReactsToChanges()
        {
            var shell         = CreateShell();
            var initialHeader = new Label()
            {
                Text = "Hello"
            };
            var newHeader = new Label()
            {
                Text = "Hello part 2"
            };

            shell.FlyoutHeader = initialHeader;
            await Device.InvokeOnMainThreadAsync(async() =>
            {
                TestActivity testSurface = null;
                try
                {
                    testSurface   = await TestActivity.GetTestSurface(Context, shell);
                    var addedView = shell.GetRenderer().View;
                    Assert.IsNotNull(addedView);
                    Assert.IsNull(newHeader.GetValue(AppCompat.Platform.RendererProperty));
                    Assert.IsNotNull(initialHeader.GetValue(AppCompat.Platform.RendererProperty));
                    await Device.InvokeOnMainThreadAsync(() => shell.FlyoutHeader = newHeader);
                    Assert.IsNotNull(newHeader.GetValue(AppCompat.Platform.RendererProperty), "New Header Not Set Up");
                    Assert.IsNull(initialHeader.GetValue(AppCompat.Platform.RendererProperty), "Old Header Still Set Up");
                }
                finally
                {
                    testSurface?.Finish();
                }
            });
        }