Exemple #1
0
        public Task MeasureOverrideWithNan() =>
        RunOnUIThread.Execute(() =>
        {
            var SUT = new MyControl01();

            SUT.BaseAvailableSize = new Size(double.NaN, double.NaN);
            SUT.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            Assert.AreEqual(new Size(double.PositiveInfinity, double.PositiveInfinity), SUT.MeasureOverrides.Last());
            Assert.AreEqual(new Size(0, 0), SUT.DesiredSize);
        });
Exemple #2
0
        public Task When_Measure_Once() =>
        RunOnUIThread.Execute(() =>
        {
            var SUT = new MyControl01();

            SUT.Measure(new Size(10, 10));
            Assert.AreEqual(1, SUT.MeasureOverrides.Count);
            Assert.AreEqual(new Size(10, 10), SUT.MeasureOverrides[0]);

            SUT.Measure(new Size(10, 10));
            Assert.AreEqual(1, SUT.MeasureOverrides.Count);
        });
Exemple #3
0
        public async Task MeasureOverrideWithNan()
        {
            await Dispatch(() =>
            {
                var SUT = new MyControl01();

                SUT.BaseAvailableSize = new Size(double.NaN, double.NaN);
                SUT.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                Assert.AreEqual(new Size(double.PositiveInfinity, double.PositiveInfinity), SUT.MeasureOverrides.Last());
                Assert.AreEqual(new Size(0, 0), SUT.DesiredSize);
            });
        }
Exemple #4
0
        public Task MeasureWithNan() =>
        RunOnUIThread.Execute(() =>
        {
            var SUT = new MyControl01();

            SUT.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            Assert.AreEqual(new Size(double.PositiveInfinity, double.PositiveInfinity), SUT.MeasureOverrides.Last());
            Assert.AreEqual(new Size(0, 0), SUT.DesiredSize);

            Assert.ThrowsException <InvalidOperationException>(() => SUT.Measure(new Size(double.NaN, double.NaN)));
            Assert.ThrowsException <InvalidOperationException>(() => SUT.Measure(new Size(42.0, double.NaN)));
            Assert.ThrowsException <InvalidOperationException>(() => SUT.Measure(new Size(double.NaN, 42.0)));
        });
Exemple #5
0
        public async Task When_Measure_Once()
        {
            await Dispatch(() =>
            {
                var SUT = new MyControl01();

                SUT.Measure(new Size(10, 10));
                Assert.AreEqual(1, SUT.MeasureOverrides.Count);
                Assert.AreEqual(new Size(10, 10), SUT.MeasureOverrides[0]);

                SUT.Measure(new Size(10, 10));
                Assert.AreEqual(1, SUT.MeasureOverrides.Count);
            });
        }
Exemple #6
0
        public Task When_Measure_And_Invalidate() =>
        RunOnUIThread.ExecuteAsync(() =>
        {
            var SUT = new MyControl01();

            SUT.Measure(new Size(10, 10));
            Assert.AreEqual(1, SUT.MeasureOverrides.Count);
            Assert.AreEqual(new Size(10, 10), SUT.MeasureOverrides[0]);

            SUT.InvalidateMeasure();

            SUT.Measure(new Size(10, 10));
            Assert.AreEqual(2, SUT.MeasureOverrides.Count);
            Assert.AreEqual(new Size(10, 10), SUT.MeasureOverrides[1]);
        });
Exemple #7
0
        public Task When_Grid_Measure_And_Invalidate() =>
        RunOnUIThread.Execute(() =>
        {
            var grid = new Grid();
            var SUT  = new MyControl01();

            grid.Children.Add(SUT);

            grid.Measure(new Size(10, 10));
            Assert.AreEqual(1, SUT.MeasureOverrides.Count);
            Assert.AreEqual(new Size(10, 10), SUT.MeasureOverrides[0]);

            grid.InvalidateMeasure();

            grid.Measure(new Size(10, 10));
            Assert.AreEqual(1, SUT.MeasureOverrides.Count);
        });
Exemple #8
0
        public async Task When_Grid_Measure_And_Invalidate()
        {
            await Dispatch(() =>
            {
                var grid = new Grid();
                var SUT  = new MyControl01();

                grid.Children.Add(SUT);

                grid.Measure(new Size(10, 10));
                Assert.AreEqual(1, SUT.MeasureOverrides.Count);
                Assert.AreEqual(new Size(10, 10), SUT.MeasureOverrides[0]);

                grid.InvalidateMeasure();

                grid.Measure(new Size(10, 10));
                Assert.AreEqual(1, SUT.MeasureOverrides.Count);
            });
        }