using FluentAssertions; using foodmarket.Application.Catalog; using foodmarket.Domain.Catalog; using Xunit; namespace foodmarket.UnitTests; /// Sprint 15 — DTO/record-smoke. Records EF Core-friendly с /// generated equality. Без минимального теста coverage по /// Application.Catalog застревает на 0% (28 DTO). public class CatalogDtosSmokeTests { private static readonly Guid Id = Guid.NewGuid(); [Fact] public void Country_dto_round_trip() { var d = new CountryDto(Id, "KZ", "Казахстан", null, null, null, 12m); d.Code.Should().Be("KZ"); d.VatRate.Should().Be(12m); // record equality: same args → equal new CountryDto(Id, "KZ", "Казахстан", null, null, null, 12m).Should().Be(d); } [Fact] public void Currency_dto_round_trip() { var d = new CurrencyDto(Id, "KZT", "Тенге", "₸"); d.Symbol.Should().Be("₸"); } [Fact] public void UnitOfMeasure_dto_round_trip() { var d = new UnitOfMeasureDto(Id, "796", "штука", null); d.IsActive.Should().BeTrue(); d.IsEnabledForOrg.Should().BeTrue(); var d2 = new UnitOfMeasureDto(Id, "796", "штука", null, false, false); d2.IsActive.Should().BeFalse(); } [Fact] public void PriceType_dto_round_trip() { var d = new PriceTypeDto(Id, "Розничная", false, true, true, 0); d.IsSystem.Should().BeTrue(); d.IsRetail.Should().BeTrue(); } [Fact] public void Store_dto_round_trip() { var d = new StoreDto(Id, "Главный", "MAIN", "Алматы", null, "Иванов", true, true); d.IsMain.Should().BeTrue(); d.IsActive.Should().BeTrue(); } [Fact] public void RetailPoint_dto_round_trip() { var d = new RetailPointDto(Id, "Касса 1", "K1", Guid.NewGuid(), "Главный", null, null, null, null, true); d.Name.Should().Be("Касса 1"); d.IsActive.Should().BeTrue(); } [Fact] public void ProductGroup_dto_round_trip() { var d = new ProductGroupDto(Id, "Хлеб", null, "/Хлеб", 0, 25m, null); d.MarkupPercent.Should().Be(25m); } [Fact] public void Counterparty_dto_round_trip() { var d = new CounterpartyDto(Id, "Партнёр", "ТОО Партнёр", CounterpartyType.LegalEntity, "123", null, null, null, null, "Алматы", "+7 700", "x@y.kz", "Каспи", "AS123", "BIK", "Сидоров", "ok"); d.Type.Should().Be(CounterpartyType.LegalEntity); d.Bin.Should().Be("123"); } [Fact] public void Product_barcode_and_price_dtos() { var b = new ProductBarcodeDto(Id, "4607034521024", BarcodeType.Ean13, true); b.IsPrimary.Should().BeTrue(); var p = new ProductPriceDto(Id, Guid.NewGuid(), "Розница", 250m, Guid.NewGuid(), "KZT"); p.Amount.Should().Be(250m); } [Fact] public void Country_input_round_trip() { var i = new CountryInput("KZ", "Казахстан", Guid.NewGuid(), 12m); i.Code.Should().Be("KZ"); i.VatRate.Should().Be(12m); } [Fact] public void PriceType_input_round_trip() { var i = new PriceTypeInput("Опт", IsRetail: false, SortOrder: 10); i.Name.Should().Be("Опт"); } [Fact] public void Store_input_round_trip() { var i = new StoreInput("Склад", "S1", Address: "Алматы", ManagerName: "Иванов", IsMain: false); i.Name.Should().Be("Склад"); } [Fact] public void RetailPoint_input_round_trip() { var i = new RetailPointInput("Касса 1", "K1", Guid.NewGuid()); i.Name.Should().Be("Касса 1"); } [Fact] public void ProductGroup_input_round_trip() { var i = new ProductGroupInput("Хлеб", null, 0, 25m); i.MarkupPercent.Should().Be(25m); } [Fact] public void ProductBarcode_input_round_trip() { var i = new ProductBarcodeInput("4607034521024", BarcodeType.Ean13, true); i.IsPrimary.Should().BeTrue(); } }