Files
Rozpisky/Rozpisky.Tests/ObliqueTesty.cs
T
marekandClaude Opus 5 a6377ab583 Baseline: současný stav projektu Rozpisky
První commit — WPF aplikace pro generování výkresových rohových razítek
(.NET 10, SkiaSharp, ACadSharp, ClosedXML) včetně xUnit testů, DXF šablony,
log a dokumentace. Build výstupy (bin/, obj/, .vs/) jsou ignorovány.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 09:45:49 +02:00

61 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.IO;
using ACadSharp.Entities;
using ACadSharp.IO;
using Rozpisky.Dxf;
using Rozpisky.Rendering;
using Xunit;
namespace Rozpisky.Tests;
/// <summary>
/// Oblique úhel textu (kurzíva náklonem, DXF group 51/50) dřív se ignoroval a text
/// se kreslil vzpřímeně. „SUDOP BRNO" má v DXF group 51 = 15° a group 41 (width) = 0,7.
/// </summary>
public class ObliqueTesty
{
[Fact]
public void SudopBrno_TextNeseObliqueAWidthFactor()
{
var rec = new RecordingRenderer();
new DxfTemplate(TestData.Logo("sudopBrno.dxf")).Replay(rec);
var t = Assert.Single(rec.Texts);
Assert.Equal("SUDOP BRNO", t.Text);
Assert.Equal(15.0, t.Style.ObliqueDeg, 2); // DXF group 51 = 15.0
Assert.Equal(0.7, t.WidthFactor, 3);
}
[Fact]
public void OstatniLoga_MajiObliqueNula()
{
// Regrese: žádné jiné logo oblique nemá nesmí se objevit nenulový sklon.
foreach (var name in TestData.VsechnaLoga.Where(n => n != "sudopBrno.dxf"))
{
var rec = new RecordingRenderer();
new DxfTemplate(TestData.Logo(name)).Replay(rec);
Assert.All(rec.Texts, t => Assert.Equal(0, t.Style.ObliqueDeg));
}
}
[Fact]
public void DxfExport_ZachovaObliqueNaTextu()
{
var dxf = new DxfProfileRenderer();
dxf.Layer("0", 0x000000, 0.25);
dxf.Text(10, 20, "Zkouška", 2.5, style: new TextStyle("Arial", ObliqueDeg: 3));
string path = Path.Combine(Path.GetTempPath(), $"rozpisky-oblique-{Guid.NewGuid():N}.dxf");
try
{
DxfWriter.Write(path, dxf.Document, binary: false);
var doc = DxfReader.Read(path);
var t = Assert.Single(doc.Entities.OfType<TextEntity>());
Assert.Equal(3.0 * Math.PI / 180.0, t.ObliqueAngle, 6);
}
finally
{
File.Delete(path);
}
}
}