Very nice. I mostly use Inlinedata, but knowing the others is nice. I think also with the class you could data drive the test by pulling the data from a file. Small nit on your naming I use a very similar format but I think putting _Should_ in every test name is redundant. Instead of Create_Should_ReturnNull_WhenValueIsNull() I would use Create_ReturnsNull_WhenValueIsNull() Keep up the great videos.
Quick question, I noticed when switching over to using ClassData the values used are no longer showing in the VS Test Explorer like they would for InlineData. Do you know of a way for it to show?
@@MilanJovanovicTechfigured it out, any data object you're using you have to use IXunitSerializable on it and tell xunit what the value types you're trying to use. We added a simple auto serialization helper class to handle this. Great video btw, never used Class Data until now, super clean!
@@MilanJovanovicTech Recently there was a security test at my company and the test pointed out that it is possible to log in with the same user at the same time, I use identity to manage users and I would like to know how to prevent more than one person from being able to log in with the same account at the same time
Great channel and coverage on architecture. :) I have a question, which may lead you to new content ideas! If an application has multiple contexts would you still use the repository & unit of work patterns? For example, an application has 2 databases both with Product tables where data will be read from both and persisted in many Handlers. Having two UnitOfWork objects seems to defeat the purpose of the UnitOfWork pattern? What are your thoughts?
The question is why it has multiple contexts? - Different DBs -> Can't do transactions, since they won't work - Logical splitting -> Transactions are fine, but be warry of coupling If they are indeed logically separate, it still makes sense to have two UnitOfWork abstractions. But you don't want to ever mix these together. So only work with one DbContext at a time.
Another comparable situation is when your application support two or several types of providers, for example MSSql and SQLite, dependent on your users' preferences. In this case you may end up duplicating or multiplying all tests if the "Arrange" part is not parameterized.
Feed your Sku to the ChatGPT and ask to write unit tests with Moq, xUnit and FluentAssertions, you will be surprised. If not - ask it to use Theory instead of Fact.
@@krccmsitp2884 Hmm, why not use data passing to mock behavior ? PS. Actually he uses static methods in the sku, and it have to be rewritten to interface and instance methods to mock it properly, but it can easily be rewritten just by asking ChatGPT. Also it uses Factory template, but would be created by the DI.
Want to master Clean Architecture? Go here: bit.ly/3PupkOJ
Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt
Good, clear and simple.
Thanks a lot, I'm glad you liked it :)
Thanks Malin, Keep up the good work.
Will do!
absolutely awesome and useful,
thank you Milan
You're welcome!
Very nice. I mostly use Inlinedata, but knowing the others is nice. I think also with the class you could data drive the test by pulling the data from a file.
Small nit on your naming I use a very similar format but I think putting _Should_ in every test name is redundant.
Instead of
Create_Should_ReturnNull_WhenValueIsNull()
I would use
Create_ReturnsNull_WhenValueIsNull()
Keep up the great videos.
That's a nice convention. Might consider adopting it 🤔
Thank you, great content as always
Thanks for watching, I'm glad you liked it!
I love your videos. Thank you. Keep going.
Thanks a lot :)
Great share!
Thanks nove!
Nice topic! 🙌
Thanks Miko :)
1:08 how do you delete the entire using block like that?
Ctrl + R, Ctrl + G = I think that's the command
Smashed that 👍
Thanks! 🔥
Quick question, I noticed when switching over to using ClassData the values used are no longer showing in the VS Test Explorer like they would for InlineData. Do you know of a way for it to show?
I'm not sure there is, but it doesn't really matter to me. The test cases are still there in the report and they're executed just fine.
@@MilanJovanovicTechfigured it out, any data object you're using you have to use IXunitSerializable on it and tell xunit what the value types you're trying to use. We added a simple auto serialization helper class to handle this. Great video btw, never used Class Data until now, super clean!
great video! I would use Autofixture with customizations
Haven't tried it, will look into Autofixture
@@MilanJovanovicTech ua-cam.com/video/ivEke62spOg/v-deo.html
@@MilanJovanovicTech Autofixture and Bogus are great for generating data/objects for tests.
Love your videos, in the future you can make one about preventing multiple logged users in a application? a hug from brazil
How is that practical? 🤔
@@MilanJovanovicTech
Recently there was a security test at my company and the test pointed out that it is possible to log in with the same user at the same time, I use identity to manage users and I would like to know how to prevent more than one person from being able to log in with the same account at the same time
What do you use to record your screen
OBS Studio
Great channel and coverage on architecture. :)
I have a question, which may lead you to new content ideas! If an application has multiple contexts would you still use the repository & unit of work patterns?
For example, an application has 2 databases both with Product tables where data will be read from both and persisted in many Handlers.
Having two UnitOfWork objects seems to defeat the purpose of the UnitOfWork pattern? What are your thoughts?
The question is why it has multiple contexts?
- Different DBs -> Can't do transactions, since they won't work
- Logical splitting -> Transactions are fine, but be warry of coupling
If they are indeed logically separate, it still makes sense to have two UnitOfWork abstractions. But you don't want to ever mix these together. So only work with one DbContext at a time.
Another comparable situation is when your application support two or several types of providers, for example MSSql and SQLite, dependent on your users' preferences. In this case you may end up duplicating or multiplying all tests if the "Arrange" part is not parameterized.
Feed your Sku to the ChatGPT and ask to write unit tests with Moq, xUnit and FluentAssertions, you will be surprised. If not - ask it to use Theory instead of Fact.
Note, however, that mocking is about bevahior, not data.
@@krccmsitp2884 Hmm, why not use data passing to mock behavior ?
PS. Actually he uses static methods in the sku, and it have to be rewritten to interface and instance methods to mock it properly, but it can easily be rewritten just by asking ChatGPT. Also it uses Factory template, but would be created by the DI.
What happens?
when to use xunit and when nunit?
Just use what you like