public void LayoutGroupMeasureChild() { tlog.Debug(tag, $"LayoutGroupMeasureChild START"); flagOnMeasureChild = false; Assert.False(flagOnMeasureChild, "flagOnMeasureChild should be false initially"); var testingTarget = new MyLayoutGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should be an instance of LayoutGroup type."); View view = new View() { Size = new Size(100, 150), }; // MeasureSpecification.ModeType.Exactly using (LayoutItem child = new LayoutItem()) { child.AttachToOwner(view); MeasureSpecification measureWidth = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly); MeasureSpecification measureHeight = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly); testingTarget.MeasureChildTest(child, measureWidth, measureHeight); Assert.True(flagOnMeasureChild, "LayoutGroup overridden method not invoked."); } // MeasureSpecification.ModeType.AtMost using (LayoutItem child = new LayoutItem()) { child.AttachToOwner(view); MeasureSpecification measureWidth = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.AtMost); MeasureSpecification measureHeight = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.AtMost); testingTarget.MeasureChildTest(child, measureWidth, measureHeight); Assert.True(flagOnMeasureChild, "LayoutGroup overridden method not invoked."); } // MeasureSpecification.ModeType.Unspecified using (LayoutItem child = new LayoutItem()) { child.AttachToOwner(view); MeasureSpecification measureWidth = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Unspecified); MeasureSpecification measureHeight = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Unspecified); testingTarget.MeasureChildTest(child, measureWidth, measureHeight); Assert.True(flagOnMeasureChild, "LayoutGroup overridden method not invoked."); } view.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"LayoutGroupMeasureChild END (OK)"); }
public void LayoutGroupMeasureChildWithNullArgument() { tlog.Debug(tag, $"LayoutGroupMeasureChildWithNullArgument START"); flagOnMeasureChild = false; Assert.False(flagOnMeasureChild, "flagOnMeasureChild should be false initially"); var testingTarget = new MyLayoutGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should be an instance of LayoutGroup type."); MeasureSpecification measureWidth = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly); MeasureSpecification measureHeight = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly); try { testingTarget.MeasureChildTest(null, measureWidth, measureHeight); Assert.Fail("Should return null argument exception"); } catch (ArgumentNullException) { testingTarget.Dispose(); tlog.Debug(tag, $"LayoutGroupMeasureChildWithNullArgument END (OK)"); Assert.Pass("ArgumentNullException: passed!"); } }