All Projects → emrecaglar → MockDataGenerator

emrecaglar / MockDataGenerator

Licence: MIT License
Generate mock data for POCO

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to MockDataGenerator

Mocktopus
Mocking framework for Rust
Stars: ✭ 179 (+1391.67%)
Mutual labels:  mocking, testing-tools
network image mock
Mock response for Image.network to help Flutter widget tests pass.
Stars: ✭ 22 (+83.33%)
Mutual labels:  mocking, testing-tools
Django Mock Queries
A library for mocking django queryset functions in memory for testing
Stars: ✭ 187 (+1458.33%)
Mutual labels:  mocking, unittest
mock-inspect
Mocks network requests and allows you to make assertions about how these requests happened. Supports auto-mocking of graphQL requests given a valid schema.
Stars: ✭ 19 (+58.33%)
Mutual labels:  mocking, testing-tools
better-mock
Forked from Mockjs, Generate random data & Intercept ajax request. Support miniprogram.
Stars: ✭ 140 (+1066.67%)
Mutual labels:  mocking, mock-data
Httpretty
Intercept HTTP requests at the Python socket level. Fakes the whole socket module
Stars: ✭ 1,930 (+15983.33%)
Mutual labels:  mocking, testing-tools
Mockoon
Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source.
Stars: ✭ 3,448 (+28633.33%)
Mutual labels:  mocking, mock-data
Nsubstitute
A friendly substitute for .NET mocking libraries.
Stars: ✭ 1,646 (+13616.67%)
Mutual labels:  mocking, testing-tools
php-test-generator
Generate test cases for existing PHP files
Stars: ✭ 47 (+291.67%)
Mutual labels:  mocking, testing-tools
fakerfactory
伪造数据的API服务
Stars: ✭ 53 (+341.67%)
Mutual labels:  testing-tools, mock-data
Hoverfly
Lightweight service virtualization/API simulation tool for developers and testers
Stars: ✭ 1,814 (+15016.67%)
Mutual labels:  mocking, testing-tools
Retromock
Java library for mocking responses in a Retrofit service.
Stars: ✭ 48 (+300%)
Mutual labels:  mocking, testing-tools
Mockbin
Mock, Test & Track HTTP Requests and Response for Microservices
Stars: ✭ 1,782 (+14750%)
Mutual labels:  mocking, testing-tools
Mockito
Most popular Mocking framework for unit tests written in Java
Stars: ✭ 12,453 (+103675%)
Mutual labels:  mocking, testing-tools
Hoverfly Java
Java binding for Hoverfly
Stars: ✭ 130 (+983.33%)
Mutual labels:  mocking, testing-tools
Fake Xrm Easy
The testing framework for Dynamics CRM and Dynamics 365 which runs on an In-Memory context and deals with mocks or fakes for you
Stars: ✭ 216 (+1700%)
Mutual labels:  mocking, unittest
Unit Threaded
Advanced unit test framework for D
Stars: ✭ 100 (+733.33%)
Mutual labels:  mocking, unittest
Prig
Prig is a lightweight framework for test indirections in .NET Framework.
Stars: ✭ 106 (+783.33%)
Mutual labels:  mocking, testing-tools
laika
Log, test, intercept and modify Apollo Client's operations
Stars: ✭ 99 (+725%)
Mutual labels:  mocking, testing-tools
Wasmite
Now WebAssembly has proper testing, unit-testing and debugging 🤗
Stars: ✭ 20 (+66.67%)
Mutual labels:  unittest, testing-tools

MockDataGenerator

Generate mock data for POCO

NuGet Nuget AppVeyor AppVeyor tests

namespace XUnitTestProject1
{
    public class MockGeneratorTests
    {
        [Fact]
        public void Test()
        {
            var productGenerator = new MockDataGenerator<Product>()
                .Register(x => x.Name, x => x.Name())
                .Register(x => x.Explanation, x => x.LoremIpsum())
                .Register(x => x.Category, x => x.Object(
                    new MockDataGenerator<Category>()
                        .Register(cat => cat.Id, cat => cat.AutoIncrement())
                        .Register(cat => cat.Name, cat => cat.Random())
                 ))
                .Register(x => x.CategoryId, model => model.Category.Id)
                .Register(x => x.Comments, x => x.List())
                .Register(x => x.Price, x => x.Random())
                .Register(x => x.Unit, x => x.Random(5, 15))
                .Register(x => x.Amount, (model) => model.Price * model.Unit)
                .Register(x => x.Id, x => x.Guid())
                .Register(x => x.Barcodes, x => x.Array())
                .Register(x => x.CurrencySymbol, x => x.CurrencySymbol())
                .Register(x => x.Hash, x => x.MD5())
                .Register(x => x.Size, x => x.FromEnum())
                .Register(x => x.Sales, x => x.List(
                      new MockDataGenerator<Sales>()
                              .Register(sale => sale.CardNumber, sale => sale.CreditCard())
                              .Register(sale => sale.Iban, sale => sale.IBAN())
                              .Register(sale => sale.SaleDate, sale => sale.Random())
                              .Register(sale => sale.Customer, sale => sale.Object(
                                  new MockDataGenerator<Customer>()
                                        .Register(cust => cust.Email, cust => cust.Email())
                                        .Register(cust => cust.Gender, cust => cust.Gender())
                                        .Register(cust => cust.Id, cust => cust.Guid())
                                        .Register(cust => cust.Name, cust => cust.Name())
                                        .Register(cust => cust.PersonalPage, cust => cust.Url(true))
                                        .Register(cust => cust.Phone, cust => cust.Phone())
                                        .Register(cust => cust.Region, cust => cust.Region())
                                        .Register(cust => cust.Surname, cust => cust.Surname())
                              ))
                      ));


            var data = productGenerator.Generate(5);
        }
    }

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

        public string Name { get; set; }

        public string Surname { get; set; }

        public string Phone { get; set; }

        public string Email { get; set; }

        public string PersonalPage { get; set; }

        public string Region { get; set; }

        public string Gender { get; set; }
    }

    public class Sales
    {
        public DateTime SaleDate { get; set; }

        public Customer Customer { get; set; }

        public string Iban { get; set; }

        public string CardNumber { get; set; }
    }

    public class Category
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }

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

        public string Name { get; set; }

        public string Explanation { get; set; }

        public decimal Price { get; set; }

        public int Unit { get; set; }

        public decimal Amount { get; set; }

        public int CategoryId { get; set; }
        public Category Category { get; set; }

        public string[] Barcodes { get; set; }

        public List<Sales> Sales { get; set; }

        public List<Guid> Comments { get; set; }

        public string Hash { get; set; }

        public string CurrencySymbol { get; set; }

        public SizeCategory Size { get; set; }
    }

    public enum SizeCategory
    {
        Small,
        Medium,
        Large
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].