FatCat.Fakes 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package FatCat.Fakes --version 1.0.0                
NuGet\Install-Package FatCat.Fakes -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="FatCat.Fakes" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FatCat.Fakes --version 1.0.0                
#r "nuget: FatCat.Fakes, 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 FatCat.Fakes as a Cake Addin
#addin nuget:?package=FatCat.Fakes&version=1.0.0

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

FatCat.Fakes

Fake object data populate that are perfect for testing or when you need some complete fake data with an easy to use interface

https://www.nuget.org/packages/FatCat.Fakes/

Install-Package FatCat.Fakes -Version 1.0.0

Features include

  • All basic C# primitives
  • Will create a random interface/abstract implementation from the assembly of the type asked to be created.
  • Create List, Arrays, and Dictionaries
  • Callback to change object after creation before Faker returns

Future Features

  • Ignore properties from faking
  • Custom Type Fake Generators

Examples

Create a basic primitive
    var someNumber = Faker.Create<int>();
Create a fake 1 level class
    public class MyClass
    {
        public int NumberOfTimes { get; set; }

        public string Name { get; set; }

        public DateTime CreatedDate { get; set; }
    }
    
    var myClass = Faker.Create<MyClass>();

    // json of my class
    {
        "CreatedDate":"2052-08-29T13:29:26.7833974-04:00",
        "Name":"fIcc4ShcN6TC5GZohk7gsO4",
        "NumberOfTimes":623309770
    }
Create a list of numbers between 3 and 9 items
    var numbers = Faker.Create<List<int>>();

    // json of numbers
    [
        660525537,
        1763346267,
        145042704,
        1123996617,
        2114388821
    ]
Create a list with the given length
    var numbers = Faker.Create<List<int>>(length: 21);
Create a dictionary
    var dictionary = Faker.Create<Dictionary<string, MyClass>>(length: 3);

    // json of dictionary
    {
        "6Pab9r323z":{
            "CreatedDate":"2051-01-27T21:13:05.5176146-05:00",
            "Name":"gsscLi27PPhcK96pkjKpyo2vlmHtSYZ9QVM",
            "NumberOfTimes":1211802506
        },
        "gIdxE7sNE6m9fniZ2zr0wqZa9OrpHWp":{
            "CreatedDate":"2030-02-22T23:24:57.5179499-05:00",
            "Name":"qpjDYqgCFigZ",
            "NumberOfTimes":1319840685
        },
        "jHsaFapOJJPQaPIx83CpKOr33D":{
            "CreatedDate":"2041-04-15T10:26:38.517957-04:00",
            "Name":"n25PZHCzRcL9T8aX9e",
            "NumberOfTimes":729603723
        }
    }
Create an object with sub objects
    public class MultiLevelObject 
    {
        public MyClass ObjectOne { get; set; }

        public Guid Id { get; set; }
    }

    // All properties on top level and sub class are populated
    var levelObject = Faker.Create<MultiLevelObject>();

    // json of levelObject
    {
        "ObjectOne":{
            "CreatedDate":"2042-08-08T09:13:29.1457916-04:00",
            "Name":"u5XHZBhLmv2pVvszrKvexP1s5i59VbC",
            "NumberOfTimes":494396233
        },
        "Id":"e79256c9-06c6-44b5-a9d7-de26d61d892d"
    }
Create an interface or an abstract class
    public interface IDoSomeWork 
    {
        void DoWork();

        int Result { get; set; }

        string Name { get; }
    }

    public class FirstWorker : IDoSomeWork
    {
        public void DoWork() 
        {
            // Do first work
        }

        public int Result { get; set; }

        public string Name => "FirstWorker";
    }

    public class SecondWorker : IDoSomeWork
    {
        public void DoWork() 
        {
            // Do first work
        }

        public int Result { get; set; }

        public string Name => "SecondWorker";
    }

    // Can create the interface will pick a random implementation between FirstWorker and SecondWorker
    var worker = Faker.Create<IDoSomeWork>();

    // json of worker
    {
        "Result":1086374187,
        "Name":"SecondWorker"
    }
Change the object after it is created
    var myObject = Faker.Create<MyClass>(i => { i.Name = "I like fakes"; });

    // json of myObject
    {
        "CreatedDate":"2014-08-13T03:41:25.8911822-04:00",
        "Name":"I like fakes",
        "NumberOfTimes":958091195
    }

Please explore the unit tests for examples currently supported. Happy faking.

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 netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on FatCat.Fakes:

Package Downloads
FatCat.Toolkit

Package Description

FatCat.Toolkit.WebServer

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.27 2,235 5/27/2024
1.0.26 5,760 11/27/2023
1.0.25 386 11/15/2023
1.0.24 190 11/15/2023
1.0.23 263 10/29/2023
1.0.22 2,651 7/29/2023
1.0.21 199 7/27/2023
1.0.20 2,951 3/22/2023
1.0.19 1,421 2/9/2023
1.0.18 4,527 10/6/2022
1.0.17 806 9/17/2022
1.0.15 8,549 10/7/2021
1.0.14 380 10/5/2021
1.0.13 295 10/5/2021
1.0.12 318 10/5/2021
1.0.11 559 5/16/2021
1.0.10 639 10/7/2020
1.0.9 522 9/1/2020
1.0.8 576 2/25/2020
1.0.7 480 2/22/2020
1.0.6 523 1/19/2020
1.0.5 537 1/10/2020
1.0.4 574 1/9/2020
1.0.3 589 1/8/2020
1.0.2 531 1/6/2020
1.0.1 520 1/3/2020
1.0.0 535 1/1/2020