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

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

Israel Quiroz

2 года назад

15,202 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@user-fx2se1ri2m
@user-fx2se1ri2m - 01.12.2023 23:38

This is a good video. I was curious if you had a video or GitHub page for unit testing the actual repository (mocking the DbSet) not testing the controller. I've found lots of content on unit testing the controller but finding an asynchronous create (post), edit (patch), delete EF Core unit that actually works testing the repo layer has been challenging.

Ответить
@user-yp1qn9kq6c
@user-yp1qn9kq6c - 20.07.2023 15:15

I am not an expert but this does not make much sense. When you provide It.IsAny<Employee>() as a parameter to repo-level Post method, it's just a bogus test. What exactly is the test achieving?

Ответить
@sashaostrenko3286
@sashaostrenko3286 - 21.05.2023 15:37

Дякую, друже, все максимально зрозуміло!

Ответить
@sandeepkundu258
@sandeepkundu258 - 08.04.2023 21:05

thank you

Ответить
@user-dv4yn7ng7r
@user-dv4yn7ng7r - 04.04.2023 23:23

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!

Ответить
@godwinmensah1230
@godwinmensah1230 - 01.04.2023 02:46

Exactly what I have been looking for all day long. Thank you 🙏

Ответить
@barnyarkoudos3373
@barnyarkoudos3373 - 23.01.2023 07:32

Amazing video my bro, well explained and to the point.

Ответить
@prakashroyal6386
@prakashroyal6386 - 01.12.2022 04:36

Good explanation!! . Simple and straightforward. Keep doing more videos.

Ответить
@viktortindula5707
@viktortindula5707 - 12.11.2022 12:02

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.

Ответить
@user-lz2pr8ob1j
@user-lz2pr8ob1j - 24.10.2022 16:32

repositories with ef)))

Ответить
@jebarcha
@jebarcha - 18.10.2022 07:24

Could you also make a video about unit testing your repositories/services if possible? Thanks :)

Ответить
@jebarcha
@jebarcha - 18.10.2022 07:10

Amazing video. Have you try/use NSubstitute vs Moq? Thanks.

Ответить
@PabloMartinezfr
@PabloMartinezfr - 17.10.2022 16:45

Amazing and clean explanation. Congrats!!!

Ответить
@narasimha._sai
@narasimha._sai - 28.09.2022 17:02

I am searching for this kind of video, Well explained 👍👍

Ответить
@rongliao9255
@rongliao9255 - 18.09.2022 05:45

Exactly what I was looking for! Like your clear explanation!

Ответить
@lastidea4925
@lastidea4925 - 28.08.2022 22:14

The tutorial is straightforward, but how can I test my repository methods? Or Service methods (business logic)?

Ответить
@dem0niker136
@dem0niker136 - 15.08.2022 13:38

Thanks for this! Loved the autofixture it saved me some time creating mock db sets

Ответить
@IsraelQuiroz
@IsraelQuiroz - 25.05.2022 01:50

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!

Ответить