Тёмный

How To CORRECTLY Unit Test A .Net API Using Moq & AutoFixture 

Israel Quiroz
Подписаться 4,1 тыс.
Просмотров 17 тыс.
50% 1

Опубликовано:

 

25 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 48   
@godwinmensah1230
@godwinmensah1230 Год назад
Exactly what I have been looking for all day long. Thank you 🙏
@IsraelQuiroz
@IsraelQuiroz Год назад
Awesome!!! glad I could help u out :)
@sashaostrenko3286
@sashaostrenko3286 Год назад
Дякую, друже, все максимально зрозуміло!
@IsraelQuiroz
@IsraelQuiroz Год назад
i believe i translated this correctly haha, thank u? :)
@narasimha._sai
@narasimha._sai 2 года назад
I am searching for this kind of video, Well explained 👍👍
@IsraelQuiroz
@IsraelQuiroz 2 года назад
Glad to hear it was helpful :) Thank u!
@IsraelQuiroz
@IsraelQuiroz 2 года назад
This video is my preferred way of unit testing, I hope you guys find it helpful and if you did please drop a LIKE on the video! :) Do you guys use any other frameworks or libraries when unit testing? ide love to know, so drop a comment as well!
@jayakumar2927
@jayakumar2927 2 года назад
share github
@dem0niker136
@dem0niker136 2 года назад
Thanks for this! Loved the autofixture it saved me some time creating mock db sets
@IsraelQuiroz
@IsraelQuiroz 2 года назад
Your welcome! im happy to hear you found the video helpful, and exactly! autofixture is a life saver in those situations :)
@viktor_tindula
@viktor_tindula Год назад
Thank you for this video. I feel that I could understand everything, that you was trying to explain in the video. Very good and clean tutorial.
@IsraelQuiroz
@IsraelQuiroz Год назад
Im happy to hear that :) thank you!
@prakashroyal6386
@prakashroyal6386 Год назад
Good explanation!! . Simple and straightforward. Keep doing more videos.
@IsraelQuiroz
@IsraelQuiroz Год назад
Thank you! i appreciate the love and no worries there is always more content to come! :)
@barnyarkoudos3373
@barnyarkoudos3373 Год назад
Amazing video my bro, well explained and to the point.
@IsraelQuiroz
@IsraelQuiroz Год назад
Appreciate it!
@ShorifulIslam
@ShorifulIslam 6 месяцев назад
You are really great bro. You made my confidence high now
@IsraelQuiroz
@IsraelQuiroz 6 месяцев назад
Appreciate it!!! :)
@PabloMartinezfr
@PabloMartinezfr 2 года назад
Amazing and clean explanation. Congrats!!!
@IsraelQuiroz
@IsraelQuiroz 2 года назад
Thank you :) im happy its exactly what you needed!
@rongliao9255
@rongliao9255 2 года назад
Exactly what I was looking for! Like your clear explanation!
@IsraelQuiroz
@IsraelQuiroz 2 года назад
yay :) happy to hear it's exactly what u needed and u found it easy to understand!
@joycechoi3
@joycechoi3 8 месяцев назад
best video on youtube 😤
@IsraelQuiroz
@IsraelQuiroz 8 месяцев назад
Aw thank you :)
@joycechoi3
@joycechoi3 8 месяцев назад
@@IsraelQuiroz What do we do for the case where the method we're testing calls a private helper method?
@IsraelQuiroz
@IsraelQuiroz 8 месяцев назад
verify first if u really need it to be a private method, because if not you could change it to protected, secondly if its a helper method then you dont have to worry about it since your unit test really only cares about what happens when the code executes and you are looking for behavior so let your method that you are testing call out to it and execute and verify the result
@jebarcha
@jebarcha 2 года назад
Amazing video. Have you try/use NSubstitute vs Moq? Thanks.
@IsraelQuiroz
@IsraelQuiroz 2 года назад
Thank you! No i have never used NSubstitute but that might be a fun video idea, might check it out thanks!
@anjithhanumandla2764
@anjithhanumandla2764 5 месяцев назад
If my method is static, what should I do, which means unable test the static method, and I'm using one of the dotnet CMS, so there I'm using CMS API methods, how can we moq those
@jebarcha
@jebarcha 2 года назад
Could you also make a video about unit testing your repositories/services if possible? Thanks :)
@IsraelQuiroz
@IsraelQuiroz 2 года назад
I might explore doing an integration testing video since you are not the first to reply with that since usually you do not want to unit test a repo or services, thanks! I appreciate the comment and the sub :) Welcome i gotta lotta stuff on the channel and more to come!
@josedejesusbarajaschavez1374
@josedejesusbarajaschavez1374 2 года назад
@@IsraelQuiroz yeah sounds great! and contratulations for your channel, I found it very nice and interesting.
@jebarcha
@jebarcha 2 года назад
Awesome. I asked cause I have a bit crazy api haha with services layer, repository layer and unit of work so would be good to recommend and figure out what we should and what we should not test :o Tnks.
@IsraelQuiroz
@IsraelQuiroz 2 года назад
@@josedejesusbarajaschavez1374 Thank you! and stay tuned i got alot more to come!
@IsraelQuiroz
@IsraelQuiroz 2 года назад
@@jebarcha haha gotchu
@lastidea4925
@lastidea4925 2 года назад
The tutorial is straightforward, but how can I test my repository methods? Or Service methods (business logic)?
@IsraelQuiroz
@IsraelQuiroz 2 года назад
Thank you! appreciate it i try and make my videos useful and not difficult to understand so when it comes to testing the repository methods, you need to look into Integration Testing if you want to learn about how to test that layer because it's much more complicated and takes a lot more moving parts
@lastidea4925
@lastidea4925 2 года назад
@@IsraelQuiroz Thank you for answering. I will try to do it I hope I can success :)
@АлександраМифинова
Hi! Your video helped me a lot! It took me a long time to figure out how to use moq when there are repositories, interfaces, controllers, context, etc. I have already managed to write tests for several methods of methods of the BanksController class. I have a question that I haven't been able to find an answer to yet:( I understand how to use moq with methods that return values and how to make methods raise errors but.... how to use moq with methods that don't return values? I'm writing tests for the Delete method of BanksController class that calls DeleteBankAsync method (which returns nothing) of a BankRepository class. How can I skip that call or substitute it with some custom code? Something like "pass" in Python. Thanks!
@IsraelQuiroz
@IsraelQuiroz Год назад
Hey im happy to hear my video could help! :) so basically you could just verify on lets say a delete method that one it was called correctly, that indeed that call was made, but there isnt a whole lot u can verify since your repo is being mocked
@АлександраМифинова
@@IsraelQuiroz Thanks for replying:) Delete method that I'm testing returns status codes - if there are no exceptions have been caught it should be 204. And I cannot cover this part with my tests because in that part there is a call to DeleteBankAsync and then return OK. Once DeleteBankAsync gets called it throws an error (null reference exception). So I'm stuck and still don't know how to make my test skip this call:( I don't use context in my BanksControllerTests (I'll use it in BanksRepositoryTests when I'll be testing DeleteBankAsync for example), so I wanted to skip this method call in my current tests...
@АлександраМифинова
@@IsraelQuiroz instead of return OK I meant return NoContent
@sandeepkundu258
@sandeepkundu258 Год назад
thank you
@IsraelQuiroz
@IsraelQuiroz Год назад
You're welcome
@GermanCoder42
@GermanCoder42 4 месяца назад
Bro great content and the way you are representing it, but something is odd with the video quality, the light in background and how the camera capture your movement. Please fix that,the content is great but is difficult to watch.
@IsraelQuiroz
@IsraelQuiroz 4 месяца назад
appreciate the comment! this was one of my first videos i ever made on the channel, hopefully i have improved since then haha
@asketov_
@asketov_ 2 года назад
repositories with ef)))
Далее
Unit Testing in C# 2022: 7. Web API Controllers
36:19
UFC 308: Пресс-конференция
35:18
Просмотров 510 тыс.
Китайка и Красивые Глаза😂😆
00:20
DevTools 19: Упражнения с AutoFixture
1:01:34
Просмотров 1,1 тыс.
Introduction to Unit Testing Using AutoFixture
10:25
Просмотров 14 тыс.
Don't throw exceptions in C#. Do this instead
18:13
Просмотров 261 тыс.
ASP.NET Integration Testing
25:06
Просмотров 14 тыс.
Why We ALL Use xUnit over NUnit or MSTest?
17:51
Просмотров 9 тыс.
Intro to Unit Testing in C# using XUnit
1:42:09
Просмотров 417 тыс.
ASP.NET Core Integration Testing Tutorial
24:35
Просмотров 24 тыс.