public void Test() { #region inner document var inner = new InnerDocument { FromGln = "12344321", ToGln = "43211234", IsTest = true, OrdersNumber = "OR 431", OrdersDate = new DateTime(2013, 02, 03), DeliveryType = null, TransportBy = "bus", SumTotal = 12.34m, RecadvType = TypeOfDocument.Canceled, IntervalLength = 12, Buyer = new PartyInfo { Gln = "buyer gln", UsesSimplifiedTaxSystem = true, PartyInfoType = PartyInfoType.Foreign, ForeignPartyInfo = new ForeignPartyInfo { Name = "foreignParty" }, RussianPartyInfo = new RussianPartyInfo { ULInfo = new UlInfo { Inn = "buyer inn", Name = "buyer name", }, IPInfo = new IpInfo { Inn = "IP inn", FirstName = "Zzz", LastName = "Qxx", }, }, PartyAddress = new PartyAddress { RussianAddressInfo = new RussianAddressInfo { PostalCode = "617470", City = "Moscow", }, ForeignAddressInfo = new ForeignAddressInfo { Address = "Some address", CountryCode = "922", }, }, Chief = new ContactInformation { Name = "Ceo name", Phone = "22747", }, OrderContact = new ContactInformation { Phone = "25016", }, }, Supplier = new PartyInfo { Gln = "supplier gln", UsesSimplifiedTaxSystem = false, PartyInfoType = PartyInfoType.Russian, RussianPartyInfo = new RussianPartyInfo { ULInfo = new UlInfo { Inn = "supplier inn", Name = "supplier name", }, }, Chief = new ContactInformation { Name = "Name", Phone = "34050", }, OrderContact = new ContactInformation { Name = "Contact name", }, }, GoodItems = new[] { new CommonGoodItem { GTIN = "131", Quantity = new Quantity { Value = 23.456m, MeasurementUnitCode = "kg", }, IsReturnable = true, TypeOfUnit = "package", Marks = new[] { "123", "345", "321" }, QuantityVariances = new[] { new QuantityVariance { Reason = "some reason", QuantityValue = 11m, }, } }, new CommonGoodItem { GTIN = "222", Quantity = new Quantity { Value = 0.56m, MeasurementUnitCode = "g", }, IsReturnable = false, TypeOfUnit = "package", }, }, }; #endregion #region expected document var expectedDocument = new FirstContractDocument { Header = new FirstContractDocumentHeader { Sender = "12344321", Recipient = "43211234", IsTest = "1", }, Document = new[] { new FirstContractDocumentBody { OriginOrder = new DocumentIdentificator { Number = "OR 431", Date = new DateTime(2013, 02, 03), }, DeliveryType = null, DeliveryInfo = new DeliveryInfo { TransportBy = "bus" }, IntervalLength = "12", Status = "canceled", Buyer = new FirstContractPartyInfo { Gln = "buyer gln", TaxSystem = "Simplified", ForeignAddress = new ForeignAddress { Address = "Some address", CountryIsoCode = "922", }, Organization = new Organization { Inn = "buyer inn", Name = "buyer name", }, SelfEmployed = new SelfEmployed { Inn = "IP inn", FullName = new FullName { FirstName = "Zzz", LastName = "Qxx", }, }, ForeignOrganization = new ForeignOrganization { Name = "foreignParty", }, RussianAddress = new RussianAddress { City = "Moscow", PostalCode = "617470", }, ContactInfo = new ContactInfo { Ceo = new ContactPersonInfo { Name = "Ceo name", Phone = "22747", } }, AdditionalInfo = new AdditionalInfo { Phone = "25016", NameOfCeo = "Ceo name", } }, Seller = new FirstContractPartyInfo { Gln = "supplier gln", TaxSystem = null, Organization = new Organization { Inn = "supplier inn", Name = "supplier name", }, ForeignAddress = new ForeignAddress(), SelfEmployed = new SelfEmployed { FullName = new FullName() }, RussianAddress = new RussianAddress(), ContactInfo = new ContactInfo { Ceo = new ContactPersonInfo { Name = "Name", Phone = "34050", } }, AdditionalInfo = new AdditionalInfo { Phone = "34050", NameOfCeo = "Contact name", } }, LineItems = new LineItems { TotalSumExcludingTaxes = "12.34", LineItem = new[] { new LineItem { Gtin = "131", OrderedQuantity = new MeasureUnitQuantity { Quantity = "23.46", UnitOfMeasure = "kg", }, TypeOfUnit = "RET", ControlMarks = new[] { "123", "345", "321" }, ToBeReturnedQuantity = new[] { new ReasonQuantity { Quantity = "11.00", ReasonOfReturn = "some reason", } }, Declarations = new string[0], }, new LineItem { Gtin = "222", OrderedQuantity = new MeasureUnitQuantity { Quantity = "0.56", UnitOfMeasure = "g", }, TypeOfUnit = "package", ControlMarks = new string[0], ToBeReturnedQuantity = new ReasonQuantity[0], Declarations = new string[0], }, }, }, } } }; #endregion var converter = converterCollection.GetConverter(new TestConverterContext()); var convertedDocument = converter(inner); convertedDocument.Should().BeEquivalentTo(expectedDocument, config => config .Excluding(x => x.Document[0].Comment) .Excluding(x => x.Header.CreationDateTime) .Excluding(x => x.CreationDateTime) .Excluding(x => x.Document[0].MessageCodes)); }
public void TestReconfigureForContextA() { #region first contract document var firstContractDocument = new FirstContractDocument { Id = "id_dqd", Header = new FirstContractDocumentHeader { Sender = "sender", Recipient = "recipient", IsTest = "1", CreationDateTime = null, }, CreationDateTime = new DateTime(2012, 02, 02), Document = new[] { new FirstContractDocumentBody { OriginOrder = new DocumentIdentificator { Number = "OR123", Date = new DateTime(2012, 01, 01), }, DeliveryType = "Paper", DeliveryInfo = new DeliveryInfo { TransportBy = "transportBy", }, Status = "canceled", IntervalLength = "21", Buyer = new FirstContractPartyInfo { Gln = "12345678", SelfEmployed = new SelfEmployed { Inn = "inn", FullName = new FullName { FirstName = "First Name", LastName = "Last name", } }, Organization = null, ForeignOrganization = null, ForeignAddress = new ForeignAddress { Address = null, CountryIsoCode = null }, TaxSystem = "Simplified", RussianAddress = new RussianAddress { PostalCode = "620142", City = "Ekat", }, ContactInfo = new ContactInfo { Ceo = new ContactPersonInfo { Name = "Jeff", Phone = "8909" } } }, Seller = new FirstContractPartyInfo { Gln = "87654321", SelfEmployed = null, Organization = new Organization { Inn = "org inn", Name = "org name", }, ForeignOrganization = new ForeignOrganization { Name = "foreign org name", }, ForeignAddress = new ForeignAddress { Address = "221B, Baker st., London", CountryIsoCode = "111", }, TaxSystem = "complex", RussianAddress = null, ContactInfo = new ContactInfo { Ceo = null, }, AdditionalInfo = new AdditionalInfo { NameOfCeo = "Bezos", Phone = "8808", } }, LineItems = new LineItems { TotalSumExcludingTaxes = "123.45", LineItem = new[] { new LineItem { Gtin = "134143", OrderedQuantity = new MeasureUnitQuantity { Quantity = "0.43", UnitOfMeasure = "kg", }, TypeOfUnit = "RET", ControlMarks = new[] { "abc", "def", "zzz" }, Declarations = new[] { "123", "345", "567" }, ToBeReturnedQuantity = new[] { new ReasonQuantity { ReasonOfReturn = "bad goods", Quantity = "92", }, new ReasonQuantity { Quantity = "23", ReasonOfReturn = "no need" } }, FlowType = "very flow", }, } }, MessageCodes = new[] { "nullify", "azb", "czf" } }, } }; #endregion #region inner document var innerDocument = new InnerDocument { FromGln = "recipient", ToGln = "sender", IsTest = true, CreationDateTimeBySender = new DateTime(2012, 02, 02), OrdersNumber = "OR123", OrdersDate = new DateTime(2012, 01, 01), DeliveryType = DocumentsDeliveryType.Paper, TransportBy = "transportBy", RecadvType = TypeOfDocument.Canceled, SumTotal = 123.45m, FlowType = "very flow", IntervalLength = 21, Buyer = new PartyInfo { Gln = "12345678", PartyInfoType = PartyInfoType.Russian, PartyAddress = new PartyAddress { AddressType = AddressType.Russian, RussianAddressInfo = new RussianAddressInfo { PostalCode = "620142", City = "Ekat", } }, UsesSimplifiedTaxSystem = true, RussianPartyInfo = new RussianPartyInfo { RussianPartyType = RussianPartyType.IP, IPInfo = new IpInfo { Inn = "inn", FirstName = "First Name", LastName = "Last name", } }, Chief = new ContactInformation { Name = "Jeff", Phone = "8909", } }, Supplier = new PartyInfo { Gln = "87654321", PartyInfoType = PartyInfoType.Foreign, PartyAddress = new PartyAddress { AddressType = AddressType.Foreign, ForeignAddressInfo = new ForeignAddressInfo { CountryCode = "111", Address = "221B, Baker st., London", } }, UsesSimplifiedTaxSystem = false, RussianPartyInfo = new RussianPartyInfo { RussianPartyType = RussianPartyType.UL, ULInfo = new UlInfo { Inn = "org inn", Name = "org name", } }, Chief = new ContactInformation { Name = "Bezos", Phone = "8808", } }, GoodItems = new[] { new CommonGoodItem { GTIN = "134143", Quantity = new Quantity { Value = 0.43m, MeasurementUnitCode = "kg", }, GoodNumber = new GoodNumber { Number = 1, MessageType = MessageType.ReceivingAdvice, }, IsReturnable = true, Marks = new[] { "123", "345", "567" }, Declarations = new[] { new CustomDeclaration { Number = "abc" }, new CustomDeclaration { Number = "def" }, new CustomDeclaration { Number = "zzz" }, }, QuantityVariances = new[] { new QuantityVariance { Reason = "bad goods", QuantityValue = 92m, }, new QuantityVariance { Reason = "no need", QuantityValue = 23m, }, }, } }, Nullify = true, MessageCodes = new[] { "nullify", null, "czf" }, }; #endregion var converter = converterCollection.GetConverter(new TestConverterContext(MutatorsContextType.A)); converter(firstContractDocument).Should().BeEquivalentTo(innerDocument); }