BeneficialStrategies.Iso20022.Messages.Samples 1.1.0

dotnet add package BeneficialStrategies.Iso20022.Messages.Samples --version 1.1.0
                    
NuGet\Install-Package BeneficialStrategies.Iso20022.Messages.Samples -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BeneficialStrategies.Iso20022.Messages.Samples" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BeneficialStrategies.Iso20022.Messages.Samples" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="BeneficialStrategies.Iso20022.Messages.Samples" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BeneficialStrategies.Iso20022.Messages.Samples --version 1.1.0
                    
#r "nuget: BeneficialStrategies.Iso20022.Messages.Samples, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BeneficialStrategies.Iso20022.Messages.Samples@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BeneficialStrategies.Iso20022.Messages.Samples&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=BeneficialStrategies.Iso20022.Messages.Samples&version=1.1.0
                    
Install as a Cake Tool

Beneficial Strategies

BeneficialStrategies.Iso20022.Messages.Samples

Named, valid ISO 20022 objects for tests, and a generated minimal valid object for any interface of the model, built through the Factory against the interfaces, so a test needs no message records.

Named ISO 20022 objects for your tests. When a test needs "a valid account identification", "a valid cash account" or, in time, "a valid payment message", it takes one from here instead of building it by hand: no ten lines of setup, no message records to install, and the same object every time.

The samples are built against the interfaces of the model (BeneficialStrategies.Iso20022.Messages), the contract the rest of the family is written to, with the objects made by the Factory. So a sample works with anything that takes the interface: the validators, a consumer of a message bus, a method of your own.

How to use

Take a sample

A sample is a static property. Its path says what it is: the type, Valid, the scenario, and how much of it is filled.

// a valid account identification, the IBAN variant of the choice
IAccountIdentification4Choice id = Samples.AccountIdentification4Choice.Valid.IBAN.Minimal;

Console.WriteLine(id);                                                    // IIBAN_1 { Value = DE89370400440532013000 }
if (id is IIBAN iban) Console.WriteLine($"IBAN {iban.Value}");            // IBAN DE89370400440532013000

Every access builds a new object, so a test can never change what another test reads: the objects have setters (the Factory's classes need them), and a shared sample would be a shared variable.

var again = Samples.AccountIdentification4Choice.Valid.IBAN.Minimal;
Console.WriteLine($"{ReferenceEquals(id, again)} {id.Equals(again)}");    // False True: two objects, equal by value

Try the project yourself.

Samples are built from samples

A bigger sample is made of the samples of its parts. A valid cash account contains a valid account identification:

ICashAccount40 account = Samples.CashAccount40.Valid.Standard.Minimal;
Console.WriteLine(((IIBAN)account.Identification!).Value);                // DE89370400440532013000: the IBAN sample of example 01

Most scenarios have two shapes: Minimal has few members set, Maximal more. They are both valid, and the second is there for the test that needs the optional parts:

var small = Samples.AccountIdentification4Choice.Valid.Other.Minimal;
var large = Samples.AccountIdentification4Choice.Valid.Other.Maximal;
Console.WriteLine($"{small.Identification} scheme={(small.SchemeName is null ? "none" : "set")}");   // ACCT-001 scheme=none
Console.WriteLine($"{large.Identification} scheme={(large.SchemeName is null ? "none" : "set")}");   // ACCT-001 scheme=set

The scheme name of the Maximal is itself a sample (AccountSchemeName1Choice.Valid.Proprietary.Minimal), so a message's Minimal is made of the Minimal of its header and its parts, all the way down.

Try the project yourself.

Vary a sample

A sample is an ordinary object of the interface, so it goes wherever the interface does: into a validator, a handler, a serializer. When a test needs a variation, copy it and change what the test is about. The sample itself is untouched:

var changed = IsoDataFactory.With(Samples.AccountIdentification4Choice.Valid.Other.Minimal, b => b
    .Set(x => x.Identification).To("OTHER-2"));

Console.WriteLine(changed.Identification);                                                  // OTHER-2
Console.WriteLine(Samples.AccountIdentification4Choice.Valid.Other.Minimal.Identification);  // ACCT-001

Try the project yourself.

A sample for any type

The named samples cover what tests have needed so far. For any other interface of the model, IsoSample makes a valid object from the interface itself: its required members, no others.

IGenericIdentification3 id = Samples.IsoSample.Minimal<IGenericIdentification3>();
Console.WriteLine(id);                                          // IGenericIdentification3_1 { Identification = A, Issuer = null }

var account = Samples.IsoSample.Minimal<IAccountIdentification4Choice>();
Console.WriteLine(account);                                     // IIBAN_2 { Value = DE89370400440532013000 }: a named sample wins, wherever the type appears

A list gets one item, a choice its first variant (by name), a code set its first value, and a primitive the first value of its format that the type accepts. It is the same on every call, and a new object each time. The values are placeholders that fit the format, so write no test that depends on what they are.

Where the rules ask for more than the shape says (one of two optional members must be present, a list of at least two), the object is built to the shape and a validator says no. Those types need a named sample. Writing the sample (Samples/<Type>/Valid/Standard.cs) fixes it for every object that contains the type.

Try the project yourself.

More

What is here, and what is coming

Today: the variants of 24 choices (AccountIdentification4Choice, AmountType4Choice, Party50Choice, ...), the components they need (CashAccount40, PostalAddress27, ...) and one message (MultilateralSettlementRequestV02). The values in them are those of the tests they were moved out of, so Minimal is "few members" and Maximal is "more members", not yet "only the required members" and "every member" in the sense of the model.

Any other interface is available through IsoSample.Minimal<T>(). Coming, as the tests that use them are moved onto the samples: the rest of the messages, components and choices; samples for the primitive values (simple types, code sets, amounts); the Invalid samples, one class for each known issue; and Maximal for the whole model (every optional member the rules allow together).

The standard for samples

Every sample follows one pattern, so a sample is found by its name:

Samples/<Type>/Valid/<Scenario>.cs     a static class per scenario, with Minimal and (where it differs) Maximal
Samples/<Type>/Invalid/<Issue>.cs      one static class per known issue
  • Namespace and name: BeneficialStrategies.Iso20022.Messages.Samples.<Type>.Valid.<Scenario>. <Type> is the name of the message, component or choice as in the model. For a variant of a choice, <Scenario> is the variant (AccountIdentification4Choice.Valid.Other); for any other type it is Standard (CashAccount40.Valid.Standard).
  • Minimal and Maximal: two valid shapes; Maximal has more members set, and exists only where it differs from Minimal.
  • Properties, not fields, so each access builds a new object.
  • Built from other samples, with IsoDataFactory.Make<T> (and IsoDataFactory.With to change a copy of another); a sample makes objects of the interfaces only that way.
  • A name that is also a type of System gets a trailing underscore: Valid.DateTime_, Valid.Type_ (the ones the model has are DateTime, Decimal, Index, Range, Single, Type and ValueType).
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 112 10/25/2026
1.1.0-alpha 95 10/25/2026
1.0.0-alpha 112 10/23/2026

Added: First stable release: the samples of 1.1.0-alpha, which build identifiers with valid check digits, depending on the stable Primitives 1.1.1, Messages 1.0.1 and Factory 1.0.0 (#17).