Generating realistic fake data in .NET using Bogus
Вставка
- Опубліковано 6 лип 2020
- Become a Patreon and get source code access: / nickchapsas
Check out my courses: dometrain.com
Hello everybody I'm Nick and in this .NET tutorial I will show you how you can generate unlimited realistic looking fake data using a Nuget package called Bogus. Bogus is an open source project and it supports multiple locales so it will definitely have something useful for you.
Give Bogus a star: github.com/bchavez/Bogus
Don't forget to comment, like and subscribe :)
Social Media:
Follow me on GitHub: bit.ly/ChapsasGitHub
Follow me on Twitter: bit.ly/ChapsasTwitter
Connect on LinkedIn: bit.ly/ChapsasLinkedIn
#dotnet #data #bogus
Thanks for this - very apropos for me! Never heard of this package until now! Thanks!
I like your channel and topics for .net. this is also an interesting one!
Your videos and content is invaluable. Thanks
Great video, this would help me to test simple apis on net core.
Thanks. Great one
Nice one, thanks!
Thank you Thank you!!
Thanks for video.
Interesting, thank you! :)
Good share. Thanks
Thanks for the video! really useful, i have a question, i am generating countrys whith name and CountryCode ISO 33166. All the 245 that exist, but as it is randomly generated, repeted countrys apear. how can i avoid repeted country names and country codes using The faker (Address.Country and Address.CountryCode) ?
This is cool!
Super!
can you please talk about background services in dotnet core?
Bravo Poly😀
Hey, is there a way to have coherent address like not having an American Lake in the Country Reunion for example?
think you
Hi Nick I haven’t watched the video yet but do you know how this compares with Autofixture which I use?
If you want realistic looking data then it’s better
Bogus, to me, is used for generating real looking data that I need to read. Something I would use to seed my Local/QA/Test database(es) and then display in a UI.
AutoFixture I've used in unit tests where I wanted complex objects but don't necessarily need properties to be readable.
Example, for property Firstname, Bogus would create a string of "Sally", "Kevin" or "Nick". Whereas AutoFixture would create a string of "Firstname_9b003ae7-f6e6-45c8-836a-e8d1c4d6c403', 'Firstname_3f739a19-8b61-4214-b628-2cae4cb6f31d', or 'Firstname_dea11d42-9cff-44b3-94e2-5192c09eb110'.
My unit test for Firstname just cares that its a string, not necessarily the contents of the property.
What about Autofixture?
What's the comparison between Bogus and GenFu. GenFu pretty much does the same
I wonder if you can use it to fake 2 objects that are related. For example, you have entity & dto class and you want to fake both with same data, then I can test a mapper logic to make sure the return dto has the correct mappings.
In this case you need to populate one object, then map it manually to the other object and compare this with what your mapper returns. Or, maybe you want to test your mapper, but there is other way to map these objects which you can trust. For example serialize one object to json and deserialize as another object. Then again you populate one object and compare your mapper with this method.
@@izobrr what I meant is using the faker instead of doing it manually. Almost: var objectToMap = new faker(); var mappedDto = mapper(objectToMap); var expected = new faker(); mappedDto.shouldBeEquivalentTo(expected);
I love bogus!
It would be cool if it could generate the values automatically. Maybe I should write something like that 🤔
How to quickly populate in Visual Studio 2022 like 5:50 ?