Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion DevDatesAPI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevDatesAPI", "DevDatesAPI\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevDates.Model", "DevDates.Model\DevDates.Model.csproj", "{2FD5579F-464F-432B-B0DD-510B636CC921}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevDates.DBModel", "DevDates.DBModel\DevDates.DBModel.csproj", "{59BD3631-3C1A-4487-9CE6-36B8E1CC36FC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevDates.DBModel", "DevDates.DBModel\DevDates.DBModel.csproj", "{59BD3631-3C1A-4487-9CE6-36B8E1CC36FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MockData", "MockData\MockData.csproj", "{D3911377-5509-42F8-88BE-4616F8124F23}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -27,6 +29,10 @@ Global
{59BD3631-3C1A-4487-9CE6-36B8E1CC36FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59BD3631-3C1A-4487-9CE6-36B8E1CC36FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59BD3631-3C1A-4487-9CE6-36B8E1CC36FC}.Release|Any CPU.Build.0 = Release|Any CPU
{D3911377-5509-42F8-88BE-4616F8124F23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3911377-5509-42F8-88BE-4616F8124F23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3911377-5509-42F8-88BE-4616F8124F23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3911377-5509-42F8-88BE-4616F8124F23}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
37 changes: 37 additions & 0 deletions MockData/DataGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Bogus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static MockData.Person;

namespace MockData
{
public class DataGenerator
{

public static Faker<Person> GetPersonGenerator()
{
return new Faker<Person>()
.RuleFor(e => e.FirstName, f => f.Name.FirstName())
.RuleFor(e => e.LastName, f => f.Name.LastName())
.RuleFor(e => e.DateFBirth, f => f.Person.DateOfBirth)
.RuleFor(e => e.GenderSelection, f => f.Person.Gender.ToString())
.RuleFor(e => e.Bio, f => f.Lorem.Paragraph(1))
.RuleFor(e => e.Email, (f, e) => f.Internet.Email(e.FirstName, e.LastName))
/*.RuleFor(e => e.Created, f => f.PickRandom)*/
.RuleFor(e => e.Modified, f => f.Date.Recent())
.RuleFor(e => e.ModifiedBy, (f, e) => f.Name.FirstName());

}
public static readonly List<Person> Persons = new List<Person>();
public const int NumOfPeople = 7;
public static void ResultData()
{
var generated = GetPersonGenerator();
var generatedU = generated.Generate(NumOfPeople);
Persons.AddRange(generatedU);
}
}
}
14 changes: 14 additions & 0 deletions MockData/MockData.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus" Version="34.0.2" />
</ItemGroup>

</Project>
28 changes: 28 additions & 0 deletions MockData/Person.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace MockData
{
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime DateFBirth { get; set; }
public string GenderSelection { get; set; }
public string Bio { get; set; }
public string Email { get; set; }
public DateTime Created { get; set; }
public DateTime Modified { get; set; }
public string ModifiedBy { get; set; }


public override string ToString()
{
return System.Text.Json.JsonSerializer.Serialize(this, new JsonSerializerOptions { WriteIndented = true });
}
}
}
17 changes: 17 additions & 0 deletions MockData/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Bogus;
using System;

namespace MockData // Note: actual namespace depends on the project name.
{
public class Program
{
static void Main(string[] args)
{

Console.WriteLine("Initializing data with Bogus...");
DataGenerator.ResultData();
Console.WriteLine("Several Users: ");
DataGenerator.Persons.ForEach(Console.WriteLine);
}
}
}