GithubHelp home page GithubHelp logo

mporter45042 / mockdatagenerator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emrecaglar/mockdatagenerator

0.0 1.0 0.0 42 KB

Generate mock data for POCO

License: MIT License

C# 100.00%

mockdatagenerator's Introduction

MockDataGenerator

Generate mock data for POCO

NuGet Nuget AppVeyor AppVeyor tests

namespace XUnitTestProject1
{
    public class UnitTest1
    {

        [Fact]
        public void Test1()
        {
            var data = new MockDataGenerator<MyType>();

            data.Register(x => x.Id, new GuidGenerator());
            data.Register(x => x.Name, new FromArray<string>(new[] { "TestString1", "TestString2" }));
            data.Register(x => x.Active, new RandomBoolean());
            data.Register(x => x.Level, new IntegerGenerator(0, 20));
            data.Register(x => x.IBAN, new IBANGenerator());
            data.Register(x => x.Checksum, new MD5Generator());
            data.Register(x => x.InsertedDate, new DateTimeGenerator());
            data.Register(x => x.Explanation, new LoremIpsumGenerator(5, 3));
            data.Register(x => x.AllowedIp, new IPV4Generator());
            data.Register(x => x.SecureType, new FromEnum<MyEnum>());
            data.Register(x => x.SomeField, "Const value");

            data.Register(x => x.Provider, new ComplexObject<AnotherType>(
                                                        new MockDataGenerator<AnotherType>()
                                                            .Register(x => x.Name, new RandomString(5))
                                                            .Register(x => x.Id, new GuidGenerator())));

            var mockData = data.Generate(count: 10);
        }
    }
    
    public enum MyEnum
    {
        Foo,
        Bar
    }

    public class MyType
    {
        public Guid Id { get; set; }

        public string Name { get; set; }

        public bool Active { get; set; }

        public int Level { get; set; }

        public string IBAN { get; set; }

        public string Checksum { get; set; }

        public DateTime InsertedDate { get; set; }
        
        public AnotherType Provider { get; set; }

        public string Explanation { get; set; }

        public string AllowedIp { get; set; }
        
        public MyEnum SecureType { get; set; }

        public string SomeField { get; set; }
    }

    public class AnotherType
    {
        public Guid Id { get; set; }

        public string Name { get; set; }
    }
}

mockdatagenerator's People

Contributors

emrecaglar avatar

Watchers

James Cloos 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.