Giter Club home page Giter Club logo

mockresult's Introduction

MockResult

Introduce

  1. Until today,this toolkit does not recognize any interfaces and does not implement initialization of common interfaces.
  2. This tool can automatically create generic classes and fill all property fields with random values.
  3. If the attribute has a default value, it is not filled in.for example, Boolean values,integers,DateTime.
  4. If the attribute type is a string, fill in the attribute name.

Example

MockConvert.SetLength(3); //Set default length for lists and arrays

MockConvert.SetDeep(4);//Set the recursion depth of the class to prevent infinite nesting

var apple = MockConvert.NewObject<Apple>(); //OK

var apples = MockConvert.NewObject<List<Apple>>(); //OK

var appleArray = MockConvert.NewObject<Apple[]>(); //OK

var example = MockConvert.NewObject<ExampleDemo>(); //OK

var exampleDic = MockConvert.NewObject<Dictionary<ExampleDemo, Apple>>(); //OK

var error = MockConvert.NewObject<IEnumerable<Apple>>(); //error is null

var error2 = MockConvert.NewObject<ICollection<Apple>>(); //error is null

public class Apple 
{
    public Guid Id {  get; set; }
    public string Name { get; set; } = string.Empty;
    public string OtherName { get; set; } = "OtherName";
}

public struct ExampleDemo
{
    public byte P1 { get; set; }
    public byte P2 { get; set; }
    public byte P3 { get; set; }
    public byte P4 { get; set; }
    public DayType Day { get; set; }
}

public enum DayType :short
{
    HappyDay,
    SadDay,
}

The generated JSON string

{
    "OtherName":"OtherName",
    "Id":"56a62db5-627c-4cff-9761-7e4b97083014",
    "Name":"NAME",
    "Description":"DESCRIPTION"
}
{"P1":90,"P2":136,"P3":220,"P4":61,"Day":0}

Functional iteration

1.plan to use more reasonable padding values to fill your newly created classes and structures. 2.Perhaps in the future, it can support initialization of common IEnumerable interfaces

mockresult's People

Watchers

shengruozhimu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.