Generating Fake Data in C# with Bogus

  Рет қаралды 21,890

IAmTimCorey

IAmTimCorey

Жыл бұрын

Having data to test with is important. Whether you want to create unit tests that better replicate the real world or you want to insert sample data in the database, the key is to have representative data without spending a lot of time generating it.
That's where the Bogus library comes in. This open-source NuGet package allows us to quickly generate fake data that can be used for any number of purposes in our application or our database. In this video, we are going to look at how to quickly spin up an application that makes use of fake data that is generated by Bogus.
Full Training Courses: IAmTimCorey.com
Source Code: leadmagnets.app/?Resource=Bog...
Mailing List: signup.iamtimcorey.com/

Пікірлер: 62
@d3tn3tracer
@d3tn3tracer Жыл бұрын
Thank you Tim! Our team is learning Unit Tests right now and you have one about Bogus. Thank you for your work for community! 😊
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thank you!
@YazanGplay
@YazanGplay Жыл бұрын
This is the second time you upload a problem solving video after I discuss with my colleague about it. Yesterday we were discussing how should we seed the database every time we run a new instance in docker. Very useful video, Thanks Tim!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Just keep talking near my hidden microphone. 😉
@steveclarke8720
@steveclarke8720 Жыл бұрын
As always great demos and instruction. Perfectly timed as I am creating large sets of data for a product demo.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thank you!
@lukaszrutkowski
@lukaszrutkowski Жыл бұрын
Thank you Tim for all your and your team work. I have learned tons from your courses library (each course is a masterpiece on it's own), as well as from YT. Cannot wait for new things :) PS. Bogus is a Polish name :))
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Awesome! I’m glad my content has been so helpful.
@EluviumMC
@EluviumMC Жыл бұрын
Great find and demonstration of this library! Thanks for sharing!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@troybryantIII
@troybryantIII Жыл бұрын
Started a new project and this was the testing suit selected. Life saver...
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Great!
@tresaidh3y90
@tresaidh3y90 Жыл бұрын
Amazing as always Tim! Thanks so much!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@jesusdelarua5995
@jesusdelarua5995 Жыл бұрын
Great video!!! Thank you Tim.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@claudiocespon4128
@claudiocespon4128 Жыл бұрын
Thanks Tim! This seems to be an excellent tool to test database performance degradation too!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@CodeLlama
@CodeLlama Жыл бұрын
This is awesome! I can see a lot of use cases!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Great!
@MrMAbukhadra
@MrMAbukhadra Жыл бұрын
Great tool for testing the application. Thank you
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome!
@KorruFreez
@KorruFreez Жыл бұрын
Bogus is extremely helpful, thanks for the video!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@ahmeddabas
@ahmeddabas Жыл бұрын
as always , great video thanx bro
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@dmytrohryhsyn8382
@dmytrohryhsyn8382 Жыл бұрын
Thank you Tim. I started to implement random generator by myself. I should probably google for existing solutions at first :)
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@khangle6872
@khangle6872 Жыл бұрын
having worked with many frameworks across languages, I do see the appeal of a heavy battery-included framework. The industry nowadays tend toward micro-framework that start out small and open for plugin or addon to expand functionality, and we add things as we need it. Which make sense in its own right But for heavy frameworks, everything is streamlined and function with each other much more coherent. Laravel, for example, had almost every layer of a typical application built into its core. The DataGenerator, which they called DatabaseFactory, and the Seeder itself where you define the rule for each model, using the popular FakerPHP that they also maintain; are all configured in the fresh installation of the framework. Which, also heavily documented. Also, things like data-aware input validation. Even something that could be as simple as "username must be unique" can be quite a hassle in Python Flask or Java Spring Boot, or even Asp.net, since the data access isnt really a part of the framework. Though it do open for us the freedom to choose our Orm. I really miss 'username' => [ 'required', 'unique:users,email_address', 'max:20', 'min:10' ],
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thanks for sharing.
@andywalter7426
@andywalter7426 Ай бұрын
Did you know that bogus had a dumpstring method. If you used the DumpString method, it would return the json. Then a normal class for the model would be fine.
@HollandHiking
@HollandHiking Жыл бұрын
I like it a lot, but for other countries than the US you may need to create extensions, f.i. to generate valid phone numbers, addresses, and ZIP codes. For example, the Dutch ZIP code is structured like this: four digits, a space and the two characters like 2231 ZZ. I have seen you can do that. I will give it a try.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You can do that. Here is an issue with an example of how to do so: github.com/bchavez/Bogus/issues/242
@M0nedula
@M0nedula Жыл бұрын
Is there a way to generate data specific for a country? Zip codes have different formats. Maybe use names of people and streets and cities that can occur in a country?
@IAmTimCorey
@IAmTimCorey Жыл бұрын
For zip codes, you can format them for any region using the region pattern: github.com/bchavez/Bogus/issues/242
@marcoguerra6349
@marcoguerra6349 Жыл бұрын
Interesting, for sure it can be useful
@IAmTimCorey
@IAmTimCorey Жыл бұрын
I’m glad.
@microtech2448
@microtech2448 9 ай бұрын
Hi, how is it possible to give sequential Id instead of random?
@killpopers
@killpopers Жыл бұрын
Always use this for unit testing it ensures you don't have know values in your test for values that don't need to be fixed forcing the dev to think about the logic not the data.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Great!
@hadrien03
@hadrien03 Жыл бұрын
Wow, I was just checking fake data libraries for a work project today!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Great!
@harrivayrynen
@harrivayrynen Жыл бұрын
Any news when monthly pass is available. Would be nice to try it before going to year pass.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Very soon but I don’t have a date. Email help@iamtimcorey.com and Tom can probably get you in early.
@agentsmith8434
@agentsmith8434 Жыл бұрын
Great video. Do you have a video about Repository Pattern?
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Not yet.
@agentsmith8434
@agentsmith8434 Жыл бұрын
@@IAmTimCorey Thanks you
@MarioStaats
@MarioStaats Жыл бұрын
awesome idea to save it in the DB, to have "real environment" Test Data *ThumbUp
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thanks!
@h.jpouya4715
@h.jpouya4715 Жыл бұрын
Awesome
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thanks!
@rodrigo6459
@rodrigo6459 Жыл бұрын
Is there a way to correlate a name with an enum for gender?
@anassnassim
@anassnassim 5 ай бұрын
thank you for this tutorial is there any way for exemple with this nuget or anything else if i send him as string "CityName" return This Is A City in bogus is these possible ?
@IAmTimCorey
@IAmTimCorey 5 ай бұрын
I'm not sure what you want to do here. Sorry.
@anassnassim
@anassnassim 5 ай бұрын
​@@IAmTimCorey First thank you for your replay I want to develop an app using C#. The app should receive a string, for example, 'FullName,' and generate fake data that represents a name. I'm uncertain if there's a package available to assist with this or if I'll need to utilize 'bogus' and potentially some conditional statements to achieve the desired result.
@IAmTimCorey
@IAmTimCorey 5 ай бұрын
Bogus plus conditionals is probably your best bet.
@anassnassim
@anassnassim 5 ай бұрын
@@IAmTimCorey ok thank you so much
@JorijnLamberink
@JorijnLamberink Жыл бұрын
Decent introduction to Bogus. The demonstration could have been more to the point, now we have a 36 minute video without chapters filled with a hole bunch of blazor azor content.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Well, it sounds like you got more than you paid for, so that’s good.
@manilladrift
@manilladrift Жыл бұрын
​@@IAmTimCorey clever response 😅
Intro to Unit Testing in C# using XUnit
1:42:09
IAmTimCorey
Рет қаралды 407 М.
Generating realistic fake data in .NET using Bogus
13:12
Nick Chapsas
Рет қаралды 33 М.
Pray For Palestine 😢🇵🇸|
00:23
Ak Ultra
Рет қаралды 36 МЛН
Ну Лилит))) прода в онк: завидные котики
00:51
Factory Pattern in C# with Dependency Injection
1:07:33
IAmTimCorey
Рет қаралды 101 М.
How Do I Document My Code?
20:17
IAmTimCorey
Рет қаралды 20 М.
Unit Testing in C# 2022: 7. Web API Controllers
36:19
Teddy Smith
Рет қаралды 36 М.
How to use Discriminated Unions Today in C#
17:09
Nick Chapsas
Рет қаралды 58 М.
Dependency Injection in .NET Core (.NET 6)
1:00:32
IAmTimCorey
Рет қаралды 181 М.
How to Mock RESTFUL APIs - The Easy way!
24:30
CoderOne
Рет қаралды 121 М.
Advanced C# - LINQ Tutorial
3:07:24
freeCodeCamp.org
Рет қаралды 105 М.
Distributed Systems in One Lesson by Tim Berglund
49:00
Devoxx Poland
Рет қаралды 409 М.