Inheritance: MonoBehaviour
Exemple #1
0
        public void GetSpan_Always_InvokesGetValueWithSpanProperty(double value)
        {
            var uut = new FrameworkElement();

            uut.SetValue(StretchPanel.SpanProperty, value);

            StretchPanel.GetSpan(uut).ShouldBe(value);
        }
Exemple #2
0
            public StretchPanel ConstructUUT()
            {
                var uut = new StretchPanel();

                uut.Orientation = orientation;

                children?.ForEach(x => uut.Children.Add(x));

                return(uut);
            }
Exemple #3
0
        public void SetSpan_ValueIsNegative_ThrowsException(double value)
        {
            var uut = new FrameworkElement();

            var result = Should.Throw <ArgumentException>(() =>
            {
                StretchPanel.SetSpan(uut, value);
            });

            result.ShouldSatisfyAllConditions(
                () => result.Message.ShouldContain(StretchPanel.SpanProperty.Name),
                () => result.Message.ShouldContain(value.ToString()));
        }
Exemple #4
0
        /**********************************************************************/
        #region Test Procedures

        private static FakeFrameworkElement[] MakeFakeChildren(IEnumerable <double> eachSpan)
        => eachSpan.Select(x => new { Element = new FakeFrameworkElement(), Span = x })
        .Do(x => StretchPanel.SetSpan(x.Element, x.Span))
        .Select(x => x.Element)
        .ToArray();
Exemple #5
0
        public void ArrangeOverride_OrientationIsHorizontal_InvokesChildrenEachArrangeWithFinalRectSizeExpected(double finalSizeWidth, double finalSizeHeight, params double[] childrenEachSpan)
        {
            var context = new TestContext()
            {
                orientation = Orientation.Horizontal,
                children    = MakeFakeChildren(childrenEachSpan)
            };
            var uut = context.ConstructUUT();

            var totalSpan = childrenEachSpan.Sum();

            var finalSize = new Size(finalSizeWidth, finalSizeHeight);

            uut.Arrange(new Rect(finalSize));

            context.children.ShouldSatisfyAllConditions(
                () => context.children.ForEach(x => x.ActualWidth.ShouldBe(finalSizeWidth * StretchPanel.GetSpan(x) / totalSpan)),
                () => context.children.ForEach(x => x.ActualHeight.ShouldBe(finalSizeHeight)));
        }
Exemple #6
0
        public void MeasureOverride_OrientationIsHorizontal_InvokesChildrenEachMeasure(double availableSizeWidth, double availableSizeHeight, params double[] childrenEachSpan)
        {
            var context = new TestContext()
            {
                orientation = Orientation.Horizontal,
                children    = MakeFakeChildren(childrenEachSpan)
            };
            var uut = context.ConstructUUT();

            var totalSpan = childrenEachSpan.Sum();

            var availableSize = new Size(availableSizeWidth, availableSizeHeight);

            uut.Measure(availableSize);

            context.children.ShouldSatisfyAllConditions(
                () => context.children.ForEach(x => x.MeasureOverride_AvailableSize.Width.ShouldBe(availableSizeWidth * StretchPanel.GetSpan(x) / totalSpan)),
                () => context.children.ForEach(x => x.MeasureOverride_AvailableSize.Height.ShouldBe(availableSizeHeight)));
        }