Rystem.RepositoryFramework.Infrastructure.InMemory 6.0.4

dotnet add package Rystem.RepositoryFramework.Infrastructure.InMemory --version 6.0.4
NuGet\Install-Package Rystem.RepositoryFramework.Infrastructure.InMemory -Version 6.0.4
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="Rystem.RepositoryFramework.Infrastructure.InMemory" Version="6.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Rystem.RepositoryFramework.Infrastructure.InMemory --version 6.0.4
#r "nuget: Rystem.RepositoryFramework.Infrastructure.InMemory, 6.0.4"
#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.
// Install Rystem.RepositoryFramework.Infrastructure.InMemory as a Cake Addin
#addin nuget:?package=Rystem.RepositoryFramework.Infrastructure.InMemory&version=6.0.4

// Install Rystem.RepositoryFramework.Infrastructure.InMemory as a Cake Tool
#tool nuget:?package=Rystem.RepositoryFramework.Infrastructure.InMemory&version=6.0.4

What is Rystem?

In memory integration by default

With this library you can add in memory integration with the chance to create random data with random values, random based on regular expressions and delegated methods

How to populate with random data?

Simple random (example)

Populate your in memory storage with 120 users

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRepository<IperUser, string>(repositoryBuilder =>
{
    repositoryBuilder
        .WithInMemory(inMemoryBuilder =>
        {
            inMemoryBuilder
                .PopulateWithRandomData(120, 5)
                .WithPattern(x => x.Value.Email, @"[a-z]{5,10}@gmail\.com");
        });
    repositoryBuilder
        .AddBusiness()
            .AddBusinessBeforeInsert<IperRepositoryBeforeInsertBusiness>();
    repositoryBuilder
        .Translate<IperUser>();
});

and in app after build during startup of your application

var app = builder.Build();
await app.Services.WarmUpAsync();
Simple random with regex (example)

Populate your in memory storage with 100 users and property Email with a random regex @"[a-z]{4,10}@gmail.com"

.AddRepository<User, string>(builder => {
    builder
        .WithInMemory(inMemoryBuilder => {
            inMemoryBuilder
                .PopulateWithRandomData(100)
                .WithPattern(x => x.Email, @"[a-z]{4,10}@gmail\.com")
        });
});

and in app after build during startup of your application

var app = builder.Build();
await app.Services.WarmUpAsync();
Where can I use the regex pattern?

You can use regex pattern on all primitives type and most used structs.

Complete list:
int, uint, byte, sbyte, short, ushort, long, ulong, nint, nuint, float, double, decimal, bool, char, Guid, DateTime, TimeSpan, Range, string, int?, uint?, byte?, sbyte?, short?, ushort?, long?, ulong?, nint?, nuint?, float?, double?, decimal?, bool?, char?, Guid?, DateTime?, TimeSpan?, Range?, string?

You can use the pattern in Class, IEnumerable, IDictionary, or Array, and in everything that extends IEnumerable or IDictionary

Important!! You can override regex service in your DI

public static IServiceCollection AddRegexService<T>(
        this IServiceCollection services)
        where T : class, IRegexService
IEnumerable or Array one-dimension (example)

You have your model x (User) that has a property Groups as IEnumerable or something that extends IEnumerable, Groups is a class with a property Id as string. In the code below you are creating a list of class Groups with 8 elements in each 100 User instances, in each element of Groups you randomize based on this regex "[a-z]{4,5}". You may take care of use First() linq method to set correctly the Id property.

.AddRepository<User, string>(builder => {
    builder
        .WithInMemory(inMemoryBuilder => {
            inMemoryBuilder
                .PopulateWithRandomData(100, 8)
                .WithPattern(x => x.Groups!.First().Id, "[a-z]{4,5}");
        });
});

and in app after build during startup of your application

var app = builder.Build();
await app.Services.WarmUpAsync();
IDictionary (example)

Similar to IEnumerable population you may populate your Claims property (a dictionary) with random key but with values based on regular expression "[a-z]{4,5}". As well as IEnumerable implementation you will have 6 elements (because I choose to create 6 elements in Populate method)

.AddRepository<User, string>(builder => {
    builder
        .WithInMemory(inMemoryBuilder => {
            inMemoryBuilder
                .PopulateWithRandomData(100, 6)
                .WithPattern(x => x.Claims!.First().Value, "[a-z]{4,5}");
        });
});

and in app after build during startup of your application

var app = builder.Build();
await app.Services.WarmUpAsync();

or if you have in Value an object

AddRepository<User, string>(builder => {
    builder
        .WithInMemory(inMemoryBuilder => {
            inMemoryBuilder
                .PopulateWithRandomData(100, 6)
                .WithPattern(x => x.Claims!.First().Value.SomeProperty, "[a-z]{4,5}");
        });
});

and in app after build during startup of your application

var app = builder.Build();
await app.Services.WarmUpAsync();

Populate with delegation

Similar to regex pattern, you can use a delegation to populate something.

Dictionary (example)

Here you can see that all 6 elements in each 100 users are populated in Value with string "A"

.AddRepository<User, string>(builder => {
    builder
        .WithInMemory(inMemoryBuilder => {
            inMemoryBuilder
                .PopulateWithRandomData(100, 6)
                .WithPattern(x => x.Claims!.First().Value, () => "A");
        });
});

and in app after build during startup of your application

var app = builder.Build();
await app.Services.WarmUpAsync();

Populate with Implementation

If you have an interface or abstraction in your model, you can specify an implementation type for population. You have two different methods, with typeof

.AddRepository<PopulationTest, string>(builder => {
    builder
        .WithInMemory(inMemoryBuilder => {
            inMemoryBuilder
                .PopulateWithRandomData(100, 2)
                .WithImplementation(x => x.I, typeof(MyInnerInterfaceImplementation));
        });
});

or generics

.AddRepository<PopulationTest, string>(builder => {
    builder
        .WithInMemory(inMemoryBuilder => {
            inMemoryBuilder
                .PopulateWithRandomData(100)
                .WithImplementation<IInnerInterface, MyInnerInterfaceImplementation>(x => x.I!);
        });
});

In Memory, simulate real implementation

If you want to test with possible exceptions (for your reliability tests) and waiting time (for your load tests) you may do it with this library and in memory behavior settings.

Add random exceptions

You can set different custom exceptions and different percentage for each operation: Delete, Get, Insert, Update, Query. In the code below I'm adding three exceptions with a percentage of throwing them, they are the same for each operation. I have a 0.45% for normal Exception, 0.1% for "Big Exception" and 0.548% for "Great Exception"

.AddRepository<Car, string>(settings =>
{
    settings.WithInMemory(builder =>
    {
        var customExceptions = new List<ExceptionOdds>
        {
            new ExceptionOdds()
            {
                Exception = new Exception("Normal Exception"),
                Percentage = 10.352
            },
            new ExceptionOdds()
            {
                Exception = new Exception("Big Exception"),
                Percentage = 49.1
            },
            new ExceptionOdds()
            {
                Exception = new Exception("Great Exception"),
                Percentage = 40.548
            }
        };
        builder.Settings.AddForRepositoryPattern(new MethodBehaviorSetting
        {
            ExceptionOdds = customExceptions
        });
    });
});

Add random waiting time

You can set different range in milliseconds for each operation to simulate the await of an external integration. In the code below I'm adding a same custom range for all Repository interfaces between 1000ms and 2000ms.

.AddRepository<User, string>(builder =>
{
    builder.WithInMemory(inMemoryBuilder =>
    {
        var customRange = new Range(1000, 2000);
        inMemoryBuilder.Settings.AddForRepositoryPattern(new MethodBehaviorSetting
        {
            MillisecondsOfWait = customRange
        });
    });
});
Product Compatible and additional computed target framework versions.
.NET 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. 
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
6.0.4 86 4/3/2024
6.0.3 85 3/25/2024
6.0.2 77 3/11/2024
6.0.0 249 11/21/2023
6.0.0-rc.6 87 10/25/2023
6.0.0-rc.5 69 10/25/2023
6.0.0-rc.4 55 10/23/2023
6.0.0-rc.3 56 10/19/2023
6.0.0-rc.2 60 10/18/2023
6.0.0-rc.1 56 10/16/2023
5.0.20 163 9/25/2023
5.0.19 197 9/10/2023
5.0.18 153 9/6/2023
5.0.17 119 9/6/2023
5.0.16 117 9/5/2023
5.0.15 121 9/5/2023
5.0.14 132 9/5/2023
5.0.13 125 9/1/2023
5.0.12 116 8/31/2023
5.0.11 107 8/30/2023
5.0.10 123 8/29/2023
5.0.9 140 8/24/2023
5.0.8 129 8/24/2023
5.0.7 133 8/23/2023
5.0.6 132 8/21/2023
5.0.5 126 8/21/2023
5.0.4 154 8/16/2023
5.0.3 150 8/2/2023
5.0.2 144 8/2/2023
5.0.1 137 8/1/2023
5.0.0 152 7/31/2023
4.1.26 155 7/20/2023
4.1.25 173 7/16/2023
4.1.24 192 6/13/2023
4.1.23 156 6/13/2023
4.1.22 146 5/30/2023
4.1.21 177 5/20/2023
4.1.20 315,159 4/19/2023
4.1.19 95,036 3/20/2023
4.1.18 239 3/20/2023
4.1.17 228 3/16/2023
4.1.16 247 3/16/2023
4.1.15 241 3/15/2023
4.1.14 819 3/9/2023
4.1.13 253 3/7/2023
4.1.12 280 2/10/2023
4.1.11 336 1/26/2023
4.1.10 342 1/22/2023
4.1.9 320 1/20/2023
4.1.8 319 1/18/2023
4.1.7 494 1/18/2023
4.1.6 303 1/17/2023
4.1.1 345 1/4/2023
4.1.0 386 1/1/2023
3.1.5 327 12/21/2022
3.1.3 339 12/12/2022
3.1.2 318 12/7/2022
3.1.1 323 12/7/2022
3.1.0 377 12/2/2022
3.0.29 366 12/1/2022
3.0.28 327 12/1/2022
3.0.27 380 11/23/2022
3.0.25 334 11/23/2022
3.0.24 372 11/18/2022
3.0.23 336 11/18/2022
3.0.22 361 11/15/2022
3.0.21 367 11/14/2022
3.0.20 396 11/13/2022
3.0.19 396 11/2/2022
3.0.18 388 11/2/2022
3.0.17 432 10/29/2022
3.0.16 397 10/29/2022
3.0.15 406 10/29/2022
3.0.14 426 10/24/2022
3.0.13 408 10/24/2022
3.0.12 418 10/17/2022
3.0.11 449 10/10/2022
3.0.10 425 10/6/2022
3.0.9 421 10/6/2022
3.0.8 423 10/6/2022
3.0.7 446 10/6/2022
3.0.6 423 10/5/2022
3.0.5 438 10/5/2022
3.0.4 456 10/5/2022
3.0.3 431 10/3/2022
3.0.2 417 9/30/2022
3.0.1 428 9/29/2022
2.0.17 435 9/29/2022
2.0.16 460 9/27/2022
2.0.15 479 9/27/2022
2.0.14 475 9/26/2022
2.0.13 481 9/26/2022
2.0.12 470 9/26/2022
2.0.11 461 9/25/2022
2.0.10 494 9/25/2022
2.0.9 471 9/22/2022
2.0.8 453 9/22/2022
2.0.6 460 9/20/2022
2.0.5 450 9/20/2022
2.0.4 468 9/20/2022
2.0.2 485 9/20/2022
2.0.1 532 9/13/2022
2.0.0 466 8/19/2022
1.1.24 482 7/30/2022
1.1.23 469 7/29/2022
1.1.22 467 7/29/2022
1.1.21 770 7/29/2022
1.1.20 483 7/29/2022
1.1.19 543 7/27/2022
1.1.17 474 7/27/2022
1.1.16 489 7/26/2022
1.1.15 476 7/25/2022
1.1.14 487 7/25/2022
1.1.13 486 7/22/2022
1.1.12 489 7/19/2022
1.1.11 527 7/19/2022
1.1.10 476 7/19/2022
1.1.9 512 7/19/2022
1.1.8 485 7/18/2022
1.1.7 492 7/18/2022
1.1.6 486 7/18/2022
1.1.5 485 7/17/2022
1.1.4 494 7/17/2022
1.1.3 499 7/17/2022
1.1.2 503 7/17/2022
1.1.0 506 7/17/2022
1.0.2 492 7/15/2022
1.0.1 475 7/15/2022
1.0.0 501 7/8/2022
0.10.7 491 7/7/2022
0.10.2 554 7/2/2022
0.10.1 476 7/1/2022
0.10.0 478 7/1/2022
0.9.12 494 6/29/2022
0.9.11 537 6/20/2022
0.9.10 492 6/20/2022
0.9.9 484 6/11/2022
0.9.7 530 6/9/2022
0.9.6 505 6/5/2022
0.9.5 490 6/3/2022
0.9.4 482 6/3/2022
0.9.3 458 6/3/2022
0.9.2 463 5/31/2022
0.9.1 470 5/31/2022
0.9.0 481 5/31/2022