public void ShouldReturnEmptyCollectionForEmptyString() { // Arrange var sut = new StringMeasurer(); // Act var actual = sut.Measure(string.Empty, Font); // Assert Assert.Empty(actual.Rectangles); }
public void ShouldReturnMeasurementWithCorrectWord() { // Arrange var sut = new StringMeasurer(); const string expected = "testword"; // Act var actual = sut.Measure(expected, Font); // Assert Assert.Equal(expected, actual.Word); }
public void ShouldProduceRectangleBiggerThanRectSpacing() { // Arrange var sut = new StringMeasurer(); // Act var actual = sut.Measure(".", Font); // Assert Assert.True(actual.Rectangles.First().Width > 2 * StringMeasurer.RectSpacing); Assert.True(actual.Rectangles.First().Height > 2 * StringMeasurer.RectSpacing); }
public void ShouldContainOneRectanglePerChar() { // Arrange var sut = new StringMeasurer(); const string word = "testword"; // Act var actual = sut.Measure(word, Font); // Assert Assert.Equal(word.Length, actual.Rectangles.Count); }
public void ShouldProduceRectanglesWithSameSize() { // Arrange var sut = new StringMeasurer(); // Act var result = sut.Measure("xX", Font); // Assert var distinctSizes = result.Rectangles.Select(r => Tuple.Create(r.Width, r.Height)).Distinct().ToList(); Assert.Single(distinctSizes); }
public void ShouldHaveOffsetThatAlignsRectToZero() { // Arrange var sut = new StringMeasurer(); // Act var actual = sut.Measure("test", Font); // Assert var offset = actual.Offset; var rect = actual.Rectangles.First(); Assert.Equal(0, offset.X + rect.X, 4); Assert.Equal(0, offset.Y + rect.Y, 4); }