public void DesiredSizeShouldBeEmptyByDefault() { var availableSize = new Size2(800, 480); var context = Substitute.For <IGuiContext>(); var button = new GuiButton(); var desiredSize = button.GetDesiredSize(context, availableSize); Assert.That(desiredSize, Is.EqualTo(Size2.Empty)); }
public void DesiredSizeShouldBeTheSizeOfTheBackgroundRegion() { var availableSize = new Size2(800, 480); var context = Substitute.For <IGuiContext>(); var backgroundRegion = MockTextureRegion(); var button = new GuiButton { BackgroundRegion = backgroundRegion }; var desiredSize = button.GetDesiredSize(context, availableSize); Assert.That(desiredSize, Is.EqualTo(backgroundRegion.Size)); }
public void DesiredSizeShouldBeTheSizeOfTheMarginsInANinePatchRegion() { var availableSize = new Size2(800, 480); var context = Substitute.For <IGuiContext>(); var texture = new Texture2D(new TestGraphicsDevice(), 512, 512); var backgroundRegion = new NinePatchRegion2D(new TextureRegion2D(texture), new Thickness(10, 20)); var button = new GuiButton() { BackgroundRegion = backgroundRegion }; var desiredSize = button.GetDesiredSize(context, availableSize); Assert.That(desiredSize, Is.EqualTo(new Size2(20, 40))); }
public void DesiredSizeShouldAtLeastBeTheSizeOfTheIcon() { var texture = new Texture2D(new TestGraphicsDevice(), 35, 38); var icon = new TextureRegion2D(texture); var availableSize = new Size2(800, 480); var context = Substitute.For <IGuiContext>(); var button = new GuiButton { IconRegion = icon }; var desiredSize = button.GetDesiredSize(context, availableSize); Assert.That(desiredSize, Is.EqualTo(icon.Size)); }
public void DesiredSizeShouldAtLeastBeTheSizeOfTheText() { const string text = "abc"; var availableSize = new Size2(800, 480); var context = Substitute.For <IGuiContext>(); var font = CreateMockFont(text, lineHeight: 32); var expectedSize = font.MeasureString(text); var button = new GuiButton { Text = text, Font = font }; var desiredSize = button.GetDesiredSize(context, availableSize); Assert.That(desiredSize, Is.EqualTo(expectedSize)); }
public void DesiredSizeShouldBeTheSizeOfTheBiggestTextOrIcon() { const string text = "abcdefg"; var texture = new Texture2D(new TestGraphicsDevice(), 35, 38); var icon = new TextureRegion2D(texture); var iconExpectedSize = icon.Size; var availableSize = new Size2(800, 480); var context = Substitute.For <IGuiContext>(); var font = CreateMockFont(text, 32); var fontExpectedSize = font.MeasureString(text); var button = new GuiButton { Text = text, Font = font, IconRegion = icon }; var desiredSize = button.GetDesiredSize(context, availableSize); Assert.That(desiredSize.Width, Is.EqualTo(fontExpectedSize.Width)); Assert.That(desiredSize.Height, Is.EqualTo(iconExpectedSize.Height)); }