Skip to content

Commit

Permalink
Added failing test for #993.
Browse files Browse the repository at this point in the history
  • Loading branch information
grokys committed May 25, 2017
1 parent 760caf8 commit 15c3ef4
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/Avalonia.Layout.UnitTests/MeasureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,58 @@ public void Negative_Margin_Larger_Than_Constraint_Should_Request_Height_0()

Assert.Equal(0, target.DesiredSize.Height);
}

[Fact]
public void Margin_Should_Affect_AvailableSize()
{
MeasureTest target;

var outer = new Decorator
{
Width = 100,
Height = 100,
Child = target = new MeasureTest
{
Margin = new Thickness(10),
}
};

outer.Measure(Size.Infinity);

Assert.Equal(new Size(80, 80), target.AvailableSize);
}

[Fact]
public void Margin_Should_Be_Applied_Before_Width_Height()
{
MeasureTest target;

var outer = new Decorator
{
Width = 100,
Height = 100,
Child = target = new MeasureTest
{
Width = 80,
Height = 80,
Margin = new Thickness(10),
}
};

outer.Measure(Size.Infinity);

Assert.Equal(new Size(80, 80), target.AvailableSize);
}

class MeasureTest : Control
{
public Size? AvailableSize { get; private set; }

protected override Size MeasureOverride(Size availableSize)
{
AvailableSize = availableSize;
return availableSize;
}
}
}
}

0 comments on commit 15c3ef4

Please sign in to comment.