public void FontListener_Get_ReturnsParsedAbsoluteFont() { // Given. var input = "{7, 0, 0, 100, 0, 0, 0, 400, 1, 0, 1, 0,0,0,0,0, \"Arial\", 1, 120}"; var expected = new AbsoluteFont { FaceName = "Arial", Size = 10, Bold = false, Italic = true, Underline = false, Strikeout = true, Scale = 120, }; var paser = CreateParser(input); var tree = paser.font(); WalkParseTree(tree); // When. var font = TestSubject.Get(tree); // Then. font.Should().BeOfType <AbsoluteFont>() .And.BeEquivalentTo(expected); }
public void FontListener_Get_ReturnsParsedAutoFont() { // Given. var input = "{7, 3, 12, 700, 1, 1, 100}"; var expected = new AutoFont { Bold = true, Italic = true, Scale = 100, }; var parser = CreateParser(input); var tree = parser.font(); WalkParseTree(tree); // When. var font = TestSubject.Get(tree); // Then. font.Should().BeOfType <AutoFont>() .And.BeEquivalentTo(expected); TestSubject.Received(1) .FillRelativeFont((RelativeFont)font, tree.relativeFont()); }
public void Should_Find_Own_Getter_Only_Property_All_Getters() { var m = new TestSubject("abc"); Assert.That(m["GetOnly"], Is.EqualTo("abc")); Assert.That(m.Get("GetOnly").Result, Is.EqualTo("abc")); Assert.That(m.TryGet("GetOnly"), Is.EqualTo("abc")); }
public void ShortcutListener_Get_ReturnsParsedShortcut(string input, Shortcut expected) { var parser = CreateParser(input); var tree = parser.shortcut(); WalkParseTree(tree); var result = TestSubject.Get(tree); result.Should().BeEquivalentTo(expected); }
public void Should_Find_Own_Nullable_Property_All_Getters() { var m = new TestSubject() { Text = "abc" }; Assert.That(m["Text"], Is.EqualTo("abc")); Assert.That(m.Get("Text").Result, Is.EqualTo("abc")); Assert.That(m.TryGet("Text"), Is.EqualTo("abc")); }
public void Should_Find_Own_Property_All_Getters() { var m = new TestSubject() { Number = 42 }; Assert.That(m["Number"], Is.EqualTo(42)); Assert.That(m.Get("Number").Result, Is.EqualTo(42)); Assert.That(m.TryGet("Number"), Is.EqualTo(42)); }
public void ShortcutListener_Get_ThrowsWhenTreeDoesntHaveShortcut() { var parser = CreateParser("{}"); var tree = parser.emptyBlock(); WalkParseTree(tree); Action action = () => TestSubject.Get(tree); action.Should().Throw <InvalidOperationException>() .WithMessage($"Для узла дерева не найден элемент с типом {nameof(Shortcut)}."); }
public void LocalizedStringListener_Get_ShouldContainParsedValue(string input, LocalizedString expected) { // Given. var parser = CreateParser(input); var tree = parser.localizedString(); WalkParseTree(tree); // When. var result = TestSubject.Get(tree); // Then. result.Should().BeEquivalentTo(expected); }
public void FontListener_Get_ThrowsWhenTreeDoesntHaveFont() { // Given. var parser = CreateParser("{}"); var tree = parser.emptyBlock(); WalkParseTree(tree); // When. Action action = () => TestSubject.Get(tree); // Then. action.Should().Throw <InvalidOperationException>(); }
public void FontListener_Get_ReturnsParsedStandardFont(string input, StandardFont expected) { // Given. var parser = CreateParser(input); var tree = parser.font(); WalkParseTree(tree); // When. var font = TestSubject.Get(tree); // Then. font.Should().BeOfType <StandardFont>() .And.BeEquivalentTo(expected); TestSubject.Received(1) .FillRelativeFont((RelativeFont)font, tree.relativeFont()); }
public void FontListener_Get_ReturnsParsedConfigurationFont() { var input = "{7, 2, 0, { 0, 65faf064-3c36-43da-a2e4-e853831118ae }, 1, 100 }"; var expected = new FontFromConfiguration { Style = new Guid("65faf064-3c36-43da-a2e4-e853831118ae"), Scale = 100, }; var parser = CreateParser(input); var tree = parser.font(); WalkParseTree(tree); var font = TestSubject.Get(tree); font.Should().BeOfType <FontFromConfiguration>() .And.BeEquivalentTo(expected); TestSubject.Received(1) .FillRelativeFont((RelativeFont)font, tree.relativeFont()); }