Lpd.ObjectFaker 1.0.0

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

// Install Lpd.ObjectFaker as a Cake Tool
#tool nuget:?package=Lpd.ObjectFaker&version=1.0.0                

Lpd.ObjectFaker - Overview

  • You may use this class library for creating own Randomizers of any types
  • Lpd.ObjectFaker was created for Lpd tests via Personal Data Fake objects
  • Reminder: You would use Lpd class library for GDPR and/or PCI DSS requirements implementation in your apps
  • Lpd.ObjectFaker contains two datasets like Pops.NamesList and Pops.SurnamesList

Lpd.ObjectFaker - Overview of classes

  • GeneratorBuilder <T> builds Randomizer of any type
  • RandomBytes needs for generation byte[]
  • RandomItem <T> and RandomManyItems <T>
  • RandomPair <T1, T2> and RandomManyPairs <T1, T2>
  • Exts: StringExtensions: ToEnum
  • Exts: RandomExtensions: NextEnum and NextEnums
  • Exts: IEnumerableExtensions: MakeNullWithProbability
  • Library tested for .net462 and .core 8

Lpd - Examples

  • All examples using
using Lpd.ObjectFaker;
using Lpd.ObjectFaker.Exts;
  • Example - RandomManyPairs
RandomManyPairs<string, string> pdBuilder = new RandomManyPairs<string, string>(
    new Lpd.ObjectFaker.Pops.NamesList(), 
    new Lpd.ObjectFaker.Pops.SurnamesList()
);

var fullnames = pdBuilder.GetAsDictionary(10);
foreach (var fullname in fullnames)
{
    Console.WriteLine(fullname);
}
            RandomManyItems<int?> randomItems = new RandomManyItems<int?>(
                Enumerable.Range(1, 1000)
                .Select(v => (int?)v)
                .ToArray()
                );
            var vals = randomItems.GetManyItems(10);
            Console.WriteLine("Without null");
            foreach (var item in vals)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine("Some items should be null");
            vals = vals
                .AsEnumerable()
                .MakeNullWithProbability(0.8)
                .ToList();
            foreach (var item in vals)
            {
                Console.WriteLine(item);
            }
  • Example - Any type Randomizer via GeneratorBuilder<T>

//Call
var rnd = PersonGenerator.CreateBuilderFor_RandomSimplePerson();
for (int i = 0; i < 10; i++)
{
    var obj = rnd.Get();
    Console.WriteLine(obj);
}

public class SimplePerson
{
    public string Id { get; set; }

    public string Name { get; set; }

    public string Surname { get; set; }

    public string Email { get; set; }

    public override string ToString()
    {
        return JsonConvert.SerializeObject(this, Formatting.Indented);
    }
}

public static class PersonGenerator
{
    public static GeneratorBuilder<SimplePerson> CreateBuilderFor_RandomSimplePerson()
    {
        var builder = new GeneratorBuilder<SimplePerson>(new SimplePerson());
        builder
            .With(x => x.Id, () => System.Guid.NewGuid().ToString())
            .With(x => x.Name, () => Lpd.ObjectFaker.RandomItem<string>.Random(new Lpd.ObjectFaker.Pops.NamesList().ToArray()))
            .With(x => x.Surname, () => Lpd.ObjectFaker.RandomItem<string>.Random(new Lpd.ObjectFaker.Pops.SurnamesList().ToArray()))
            .WithSelf(x => x.Email, it => $"{it.GetCurrentState().Name}-{it.GetCurrentState().Surname}@example.com")
            ;

        //it will generate by setters when you call Get()
        return builder;
    }

}

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 was computed.  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. 
.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.0.0 85 11/28/2024