Building a .NET 6 API Using TDD

  Рет қаралды 149,749

Wes Doyle

Wes Doyle

Күн бұрын

In this video, we're going to build a .NET 6 Web API from scratch using test driven development! We'll cover creating a new solution, adding new web and unit test projects to the solution, and writing unit tests. In following videos in this series, we'll launch our application to a highly-available environment in AWS and look at various ways to configure, deploy, and monitor the application.
• 🤝 Support the Channel on Patreon! •
Patreon supporters get access to source code!
/ productivedev
• 👋 Get in Touch! •
► Facebook bit.ly/product...
► LinkedIn bit.ly/wesd-li...
► Twitter bit.ly/wesd-tw...
• 🧑🏽‍💻 Udemy Courses •
Learn Full Stack Development with .NET and Vue.js in 2022!
► Udemy bit.ly/wesd-udemy
• 🕘 Timestamps
• 📚 Topics Covered in This Video
► .NET 6
► Web API Development
► TDD
► Test Driven Development
► Unit Testing
► HttpClient
► .NET Dependency Injection
► Inversion of Control
► SOLID Design Principles
► REST APIs
► dotnet CLI

Пікірлер: 174
@CripplingDuality
@CripplingDuality 3 жыл бұрын
Your content is always worth the wait. I trust your goal is to teach TDD by practice with this series, but I do wonder if the world needs more demonstrations of RESTful APIs...maybe a graphql api or a grpc application in the future? Just a thought. Looking forward to this series!
@WesDoyle
@WesDoyle 3 жыл бұрын
great feedback. thanks Natesh!
@hackerprincess8810
@hackerprincess8810 2 жыл бұрын
duh yes we do? The world still uses REST APIs in abundance and alot of us value diff content creators sharing how they go about teaching it.
@影片程式
@影片程式 2 жыл бұрын
@@WesDoyle Can u provide a series of course about Unit Test for C# . Your course is really helpful, thanks !
@invictuz4803
@invictuz4803 2 жыл бұрын
Better to focus content and teach one thing at a time.
@EduardoSanchez-un2hh
@EduardoSanchez-un2hh 2 жыл бұрын
Well, most Businesses hire devs to make or maintain RestApis.
@Veretax
@Veretax Жыл бұрын
This is quite possibly one of the best C# TDD examples, with an API/WebRequest I've seen on KZbin.
@Greenthum6
@Greenthum6 2 жыл бұрын
Thanks for the video! The code looks clean, but I want to give feedback to avoid pitfalls when going into more complex application testing: - Unit testing controllers is rarely necessary. This is a controversial topic, but I recommend keeping controller layer as a pass-through for example with mediator pattern and use integration tests to cover the controller code. When doing the design this way there is usually no need to mock anything, just use a real data storage for the tests instead. This makes understanding the code and debugging the failure much easier. - Test behavior, not implementation details. The main test here tests that a service calls an external API when calling the controller method. When testing the controller we are not interested how it gets the users, but the fact that it does so. Now the test is dependent on both controller and service interface code. When the service interface changes, the test breaks even though it will return the users correctly. - When considering the two issues above and the fact that we still need an integration test to make sure that the users are returned correctly to the caller we start to see why unit testing controllers is not a good idea. - Use setup (and teardown) methods to put shared initialization code into one place. The tests are almost the same and are already pretty long for what they do. - TDD is much wider concept than unit testing. I see TDD as a tool to test how the system should behave. You start the process before writing any actual production code. This is tough for development-oriented mind. It is easier to think about testing "did it return 404" or "was that method called" instead of "were the requested details of the users stored returned back to the caller correctly". The commentary, phasing and the code layout is good. Keep posting!
@WesDoyle
@WesDoyle 2 жыл бұрын
All great points, thanks for sharing. Hopefully I’ll make a follow up sharing integration and e2e tests with a larger codebase in the future. All the best 😀
@n0pee349
@n0pee349 2 жыл бұрын
Hello @Greenthum6 I have a question about this statement: "When the service interface changes, the test breaks even though it will return the users correctly". Imagine we have sarvice A and this service uses service B. How would u write (unit) tests for service A, that will not breaks after changing interface of service B? Are you testing everything with a "balck box tests" (testing income and outcome) without mocking? You wrote that we should not unit test controllers because of integration/e2e tests are covering them. I disagree. Integration/e2e tests are the next layer of tests (they are testing how "integration" with 3-party software works) and they should not be the reason to not write unit tests. Can you help me by showing what I'm missing? I'm ready to change my mind.
@Greenthum6
@Greenthum6 2 жыл бұрын
@Tantol You are probably confusing the scope of unit and integration tests. Integration tests are for testing two or more units together. Not only 3rd party, but also your own code components. In your example, testing services A and B together is essentially an integration test. If there is already an integration test for testing them together, what value does a unit test add? Controllers should have simple logic and only a very few code paths. You ideally want to test all those code paths with integration tests. Then again, unit tests don't add more value. If you only rely on unit tests, you can't be sure how your code works with the rest of the application. My advice is to start testing at the service level first and add unit tests where they add value. This helps to understand how your service works and how it solves the actual business problem.
@n0pee349
@n0pee349 2 жыл бұрын
​@@Greenthum6 "testing services A and B together is essentially an integration test" I meant not togheter. I meant testing only service A that uses service B that I'm mocking in ex.: I would test if my function X from service A calls function Y from service B by mocking and verifying if it was called. And now if I change interface code for service B my tests on service A will not work even if outcome of function Y is the same as before - "When the service interface changes, the test breaks even though it will return the users correctly" My function Y (from service B) still returns same users after interface change. How to test this scenario to prevent breaking tests after interface change? This is where I have struggle for service scenario. For controller scenario now I see your point that this makes no sens to write unit tests on top of integration tests (waste of time and money). But for me it dose not make sense when testing service with mocking. These tests will always break after interface change and those I call unit tests (I'm separating logic by mocking). Or mb. I misinterpreted you and that sentence was only meant with controller in mind? If so I have no more questions.
@Greenthum6
@Greenthum6 2 жыл бұрын
@Tantol My response was mainly for controller testing. Unit testing a service does not make sense as you unit test only a part of it. When service B changes its interface, your unit test for service A still works since the mock is using the previous interface. When you update the production code in service A to newer service B your unit test may also break at build time, or it could just work depending on the mock code. Service interface changes should be rare, but unavoidable. If you have a lot of mocks there may be some manual rewriting needed. This is where an integration test is often better as it tests more the behavior than the implementation details. As a side note, I hate to read abundant mock code. It is really hard to understand later.
@torrvic1156
@torrvic1156 3 ай бұрын
Thank you so much for clarification of this very complex and complicated topic! It would be nice if you show how to test actual repositories and services using this repositories. But you actually showed how to test controllers and proxies.
@2005Azm
@2005Azm 3 жыл бұрын
I was waiting for this! Good to see you back!
@WesDoyle
@WesDoyle 3 жыл бұрын
Thanks! Great to hear from you. All the best
@Kudaty1407
@Kudaty1407 Жыл бұрын
I think I understand the most of ot, but I will have to retake that lesson later becasue the part about MockHttpRequest is a little bit too fast and complicated for me. I need to disassemble it into smaller pieces :D Great video though! But im my opinion there are things that you should change a bit : -Go a little slower, I had to stop the recording several times in order to find myself and catchup. -you should Go more into details, because you go like " I do that, and then that" bo no explenation why etc. - sometimes you just click stuff really fast without additional comments. That would also be nice :)
@girornsveinsson7970
@girornsveinsson7970 3 жыл бұрын
Thanks for a great video. I have kind of the same question as Cris Yapp though. It looks like you changed SetupBasicGetResourceList(List expectedResponse, string endpoint) method off camera so there you are no longer using the endpoint parameter. When left unchanged the test will fail for reasons I do not understand, even though the UsersService is not harcoded with the foo endpoint but using the config. It would be great to get some explanations for this.
@fatihgenc7385
@fatihgenc7385 2 жыл бұрын
Yes, actually I think it was an unnecessary parameter even at beginning, we are giving endpoint to conf ( options ) then giving it to UserService through constructor, that means it will request to endpoint we give, no need to give it also at the mockhandler method call. I guess he noticed and changed it but forgot the record or editing video.
@pedrofreitaslima
@pedrofreitaslima 2 жыл бұрын
Thank you very much, your content help me because i need learn TDD and you taught very well now i can implement this patterns
@TheYasieso
@TheYasieso 3 жыл бұрын
Great you're back Wes!! And with great content, as always!!
@the_lucas
@the_lucas 9 ай бұрын
The video is good. do you program with Java or javascrip? Why fight with visual studio adjusting the curly brackets 😅?
@VinuP2023
@VinuP2023 3 жыл бұрын
Hi Wes!, glad to see you back We hope you create more videos this year.. Its always great to learn from you😊
@WesDoyle
@WesDoyle 3 жыл бұрын
Hi Vinay Palaksha, thanks for the message! Lots of content planned for this year. All the best
@EduardoMartinez-dm5pp
@EduardoMartinez-dm5pp 2 жыл бұрын
I'd like to help out adding some hot keys and commands to make your coding even swifter: Edit a class or object's name and replace it in all its callings: -}> Ctrl + R + R Add a new file .cs (interface, class, etc) -}> ctrl + shift + A Open the Quick actions and refactorings: -}> Ctrl + . (dot) I'll keep adding more hot keys as I follow the video
@ryadean
@ryadean 3 жыл бұрын
Welcome back Wes, hope you are well. Strangely I was on your channel the other day and was wondering where you had gone!
@WesDoyle
@WesDoyle 3 жыл бұрын
Thanks for the message Ryan! More to come!
@vuhoang5903
@vuhoang5903 8 ай бұрын
Oh god, this is the exact tutor I need right now.
@javierolazaran7227
@javierolazaran7227 3 жыл бұрын
Great to see you back! Great content as usual.
@WesDoyle
@WesDoyle 3 жыл бұрын
Thanks, Javier. Great to be back!
@chrisyapp3308
@chrisyapp3308 3 жыл бұрын
Great video Wes! Glad to se your vids back!.. I just had one question though as I was following along, when you set up the mock HttpMessageHandler and then you created the overloaded function SetUpBasicGetResourceList(List expectedResponse, string endPoint), I noticed that at first you created a custom HttpRequestMessage obj, then passed that in as a parameter in to the handlerMock.Protected().SetUp() instead of using ItExpr.IsAny(), then at the end when the test failed and you returned to that Mock it was changed back to ItExpr.IsAny() and there wasnt a custom HttpRequestMessage obj being used... what did I miss? Keep up the content dude!
@vladdragomir2804
@vladdragomir2804 2 жыл бұрын
Thank you so much for this comment! :) I kept searching where I deviated from the code and finally found this comment - saved me a lot of headaches!
@abhishekdube9004
@abhishekdube9004 2 жыл бұрын
Hi Wes, This is really a great video and helped me a lot to gain a new perspective to approach a problem statement or requirement. You made me fall in love with the TDD approach :D I would really like to see how we can further use this approach to create loosely coupled architecture with a database (SQL / No SQL). Will we see more continuation of this video?
@superdev4024
@superdev4024 Жыл бұрын
Good explanation on TDD. thanks.
@damianfijoek2037
@damianfijoek2037 3 жыл бұрын
53:27 to remove all the unnecessary usings you can just press ctrl + k + e. Also, instead of replacing positions of brackets, you can set in IDE how ctrl + k +d should place them
@FabioGalanteMans
@FabioGalanteMans 3 жыл бұрын
ctrl + r + g
@WesDoyle
@WesDoyle 3 жыл бұрын
thanks! i’m using a combination of vim and resharper keybindings
@stevehiggin
@stevehiggin 3 жыл бұрын
Please do not place { on the same line as the method, thats nots the dotnet way 🤣…
@sudidav
@sudidav 2 жыл бұрын
@@stevehiggin it seems weird to have that in C#.🤣🤣
@jephrennaicker4584
@jephrennaicker4584 Жыл бұрын
Great video, for beginners, shows how easy unit tests can be to how complex unit test could be
@zakitl6323
@zakitl6323 3 жыл бұрын
Thank you Wes, we missed your videos😀
@rodrigo6459
@rodrigo6459 2 жыл бұрын
PURE GOLD!!! Loved it!
@saeed-ahmadvand
@saeed-ahmadvand Жыл бұрын
Thanks for sharing. This video was very useful for me.
@abbasfais
@abbasfais Жыл бұрын
A video on a web api/web dev project that is solid compliant would also be very much appreciated.
@Mo-ef9yt
@Mo-ef9yt 3 жыл бұрын
Hi Wes! Nice to have you back 🙂
@WesDoyle
@WesDoyle 3 жыл бұрын
Great to be back!
@kitsurubami
@kitsurubami 2 жыл бұрын
This video is great! Thank you for making it for us. I'll definitely check out your other stuff.
@VladyslavHorbachov
@VladyslavHorbachov Жыл бұрын
Great example bro!
@miklosmoricz
@miklosmoricz 2 жыл бұрын
Thumbs up! But I cannot really understand, why you fight againt your IDE in order to force Javascript-type bracket indentation. :)
@WesDoyle
@WesDoyle 3 жыл бұрын
Thanks for watching! What would you like to see next?
@ahmedelgendy5363
@ahmedelgendy5363 2 жыл бұрын
Thanks a lot I am now very interest to Apply the TDD Concept in my work.
@eduardkoryagin4792
@eduardkoryagin4792 3 жыл бұрын
Thanks a lot! Usually I decare tested class and mocks as local variables in test class and create it in constructor. In this case in test method all we have to do - setup mocks, execute method and do assert/verify. If we add new parameter into tested class constructor - refactoring is much easier.
@WesDoyle
@WesDoyle 3 жыл бұрын
Great insight on a nice way to set up tests, Eduard.Thanks!
@sshado2
@sshado2 2 жыл бұрын
This is such a valuable tutorial. Thank you so much.
@WesDoyle
@WesDoyle 2 жыл бұрын
Glad it was helpful!
@zeldaire7484
@zeldaire7484 Жыл бұрын
Such an awesome and concise video.
@geeksy2278
@geeksy2278 3 жыл бұрын
Love it! Very cool! Can you make a video on how to become a .NET developer. In my area there are tons of jobs for .net and I would love to make the switch. Keep it up!
@WesDoyle
@WesDoyle 3 жыл бұрын
Great suggestion!
@danzaverdk
@danzaverdk 3 жыл бұрын
hi wes!, just keep on doing what you are doing, honestly this channel needs more views, i learned alot from wes and will always learn more. thank you so much wes!
@WesDoyle
@WesDoyle 3 жыл бұрын
I appreciate that, Albert!
@martinrohwedder6618
@martinrohwedder6618 Жыл бұрын
Out of curiosity. Why do you create your project files using the command line, rather than just using Visual Studio GUI? BTW I love your video. Very educational :)
@hussainhussaini2267
@hussainhussaini2267 Жыл бұрын
Prestigious
@FreemanFromSteppe
@FreemanFromSteppe Жыл бұрын
it much faster
@andydevtrost3587
@andydevtrost3587 Жыл бұрын
thanks for this awersome course .
@markozilkovskyi9338
@markozilkovskyi9338 6 ай бұрын
hey, appreciate the video. what fonts are you using?
@AayushRastogiKnowMe
@AayushRastogiKnowMe 2 жыл бұрын
Very well explained Wes. Great work. I recently started watching your videos , and love them.
@primavera919
@primavera919 2 жыл бұрын
Thank you for the tutorial but do you have an "INSERT" OCD? Why do you need to press "insert" every other keyboard press?
@vladeb1104
@vladeb1104 10 ай бұрын
hi - in this example tests of the external api takes a place - do you /have a video where you testing dbcontext? My application controllers are handling crud operations on existing db and its tables. I was wondering if you can show how to mock this type of scenario?
@simplepycodes
@simplepycodes 2 жыл бұрын
Thanks a lot, very informative and helpful, perfect ..
@muyiwaishola3196
@muyiwaishola3196 3 жыл бұрын
Thanks for sharing, Wes!
@WesDoyle
@WesDoyle 3 жыл бұрын
Thanks for watching, Muyiwa Ishola!
@RoamingAdhocrat
@RoamingAdhocrat 2 жыл бұрын
1:26:00 why are we setting up a near-duplicate of `SetupBasicGetResourceList` rather than just adding an `endpoint` parameter to the original method?
@pitthp
@pitthp Жыл бұрын
Hi there, you mentioned that we can use some factory implementation for repeating (duplicate) code. Do you have example for that?
@jimmydavila7196
@jimmydavila7196 3 жыл бұрын
Thank you Wes. Good tutorial as usual.
@WesDoyle
@WesDoyle 3 жыл бұрын
Glad it was helpful! Thanks Jimmy.
@amartinezldn
@amartinezldn 9 ай бұрын
Great tutorial, thank you!
@IgorTimarac
@IgorTimarac 2 жыл бұрын
Never return 404 instead of empty lists, it's a bad API design. Do return 404 for not found objects, though (e.g. for GET /users/42 when no user with the ID of 42 exists).
@ryanzwe
@ryanzwe 2 жыл бұрын
I'd love to see this done with NSubstitute
@kevinmarkandrada
@kevinmarkandrada 3 жыл бұрын
Hi Wes, would you prefer the typical Controller.cs or the new minimal api setup?
@WesDoyle
@WesDoyle 3 жыл бұрын
Hi Kevin, great question. I'd say it depends on a few factors! One consideration would be overall application architecture. The minimal API setup seems ideal for thinking small services / microservices pattern.
@kevinmarkandrada
@kevinmarkandrada 3 жыл бұрын
@@WesDoyle Looking forward to have that in your next content. Good to see you back sir!
@diegosramirez
@diegosramirez 3 жыл бұрын
This is so useful! thank you!
@alexwexov4298
@alexwexov4298 2 жыл бұрын
Glad to see that you use the Vim plugin :)
@primavera919
@primavera919 2 жыл бұрын
Hello, thank you for creating very educational content. I was wondering what is the console/termain you used in the beginning? The one with the tabbing options on top
@JosephRoberts247
@JosephRoberts247 Жыл бұрын
That is windows terminal.
@aminkhosravi5073
@aminkhosravi5073 Жыл бұрын
Hi Wes! I was wondering how I can test CRUD operations following your procedure. Take Delete for example. How should I register mock service when the API returns NoContent Status Code? something like mockService.Setup(service=> service.DeleteUser(id)).Returns()...I don't know how to complete this piece of code after Returns for a Delete Function which is registered as a task without any return object in UserService!
@mohammad.daglas
@mohammad.daglas 2 жыл бұрын
Thank you very much for the great content!
@finnbenson1826
@finnbenson1826 2 жыл бұрын
fantastic video thank you
@henrik3098
@henrik3098 Жыл бұрын
Wow nice video man =)
@danielcarlstrom1981
@danielcarlstrom1981 2 жыл бұрын
Thanks for this great video! I'm curious about what font / colors / theme settings you use for Visual Studio? Do you have some information on that somewhere? (new subscriber here) All the best!
@WesDoyle
@WesDoyle 2 жыл бұрын
Hi Daniel! I have a repo on my GitHub called dotfiles that contains settings for all of my tooling. All the best to you, thanks for subscribing!
@DayMan85Theater
@DayMan85Theater 2 жыл бұрын
I'm only recently working on wrapping my head around unit testing and TDD more specifically. I'm curious, in GetAllUsers_WhenCalled_ReturnsListOfUsers, would it be good to give the handlerMock a COPY of the expectedResponse Users list and then assert that result and expectedResponse contain the same items? By only asserting the count, you don't know for sure that the list isn't being manipulated in some other way after being returned from the HttpClient. Or is that overkill?
@ThugLifeModafocah
@ThugLifeModafocah 2 жыл бұрын
Are you using some Vim emulator for visual studio? If so, which one?
@WesDoyle
@WesDoyle 2 жыл бұрын
Yes, in VS I use VsVim
@ThugLifeModafocah
@ThugLifeModafocah 2 жыл бұрын
@@WesDoyle Thanks
@stomic50
@stomic50 Жыл бұрын
anyone else triggered by Wes moving { up with method names? :D
@eliasmonroy7257
@eliasmonroy7257 9 ай бұрын
Ctrl + K + D 😂😂😂
@samuhuse6706
@samuhuse6706 Ай бұрын
are you testing the controller implementation ? :(
@R.Daneel
@R.Daneel 2 жыл бұрын
Please change the settings on your editor style preferences so we don't have to watch you move the brackets every single time you add a line of code.
@milesvendetti-houser1889
@milesvendetti-houser1889 3 жыл бұрын
AYYYY WES IS BACK!
@prof_as
@prof_as 8 ай бұрын
how you are able to type this fast ? . I noticed you are using some sort of tool that looks like vim. can you tell the name of the tool. by the way the video is great, easy explanation.
@HuneSilver
@HuneSilver 2 жыл бұрын
Hi Wes, what's your theme? It's great !!
@tony-ma
@tony-ma 3 жыл бұрын
Hi @Wes, what browser and extension did you use to inspect the web API response at 1:38:17?
@WesDoyle
@WesDoyle 3 жыл бұрын
Hi Tony! I'm using Firefox Developer Edition here. Thanks for watching!
@marktide4632
@marktide4632 Жыл бұрын
Hi, I have some comments which are to help future tutorials. I managed to follow up to nearly the end and then boom all went pear shaped. Being a novice I have not the skills to work out the problems. My comments are, perhaps go a little slower, the keyboard clicking and the constant movement of your cursor for no reason is really distracting. It would be nice to have a resource file. Thus for people like me that have followed along but some where missed a key line and it goes wrong we would be able to look at the working code and see where we didn't follow your quick commentary close enough. I mean this by no means to be negative. :) Thanks for the video.
@danijelzg001
@danijelzg001 2 жыл бұрын
Does the creating interface IUserService first for that InvokesUserService breaks the tdd pattern? Don't see point in creating mock of something that does not exists, you get build errors and you lose intelisense
@josehuertas877
@josehuertas877 3 жыл бұрын
Great video!
@WesDoyle
@WesDoyle 3 жыл бұрын
Thanks for watching!
@geovannycardozocedeno6041
@geovannycardozocedeno6041 2 жыл бұрын
Muy bueno tu video saludos y suscrito
@jonwall9634
@jonwall9634 2 жыл бұрын
Hi Wes, thanks for posting this video I am learning some new concepts here. I am coding along with the video and have ran into a problem at around 1h14m when "GetAllUsers_WhenCalled_InvokesHttpGetRequest()" and "GetAllUsersWhenCalled_ReturnsListOfUsers()" both return the same failed test message. The message reads: "System.ArgumentException : No protected method HttpMessageHandler.SendAsync found whose signature is compatible with the provided arguments (HttpResponseMessage, CancellationToken)." As far as I am aware I have copied the coding perfectly, but it is possible I have made a mistake somewhere. Do you know what is causing these tests to fail? Thanks in advance, Jon
@heheh6345
@heheh6345 2 жыл бұрын
Why the heck do you use Insert on your keyboard so much? Drives me crazy. Fantastic video though. Appreciate it a lot. Thanks!
@WesDoyle
@WesDoyle 2 жыл бұрын
I’m using vim
@oleksiifatichiev
@oleksiifatichiev Жыл бұрын
Great teaching and explanation of the material. However, I watched it with some difficulty because the constant keyboard clicking was quite distracting.
@leeliquid85
@leeliquid85 2 жыл бұрын
Hi, this has always been a question I have on my mind. Is there any particular reason that you choose to use command line to create new solution and projects vs using Visual Studio or something has a GUI?
@WesDoyle
@WesDoyle 2 жыл бұрын
just for convenience!
@yt-1337
@yt-1337 2 жыл бұрын
why would you go to vs and click through all that shit, if you can just do 3 commands
@codingbloke
@codingbloke 3 жыл бұрын
Thumbs up. (Despite unnecessary use of Newtonsoft 😜).
@WesDoyle
@WesDoyle 3 жыл бұрын
:) Old habits! Thanks for watching!
@yavuzalter359
@yavuzalter359 3 жыл бұрын
Thanks for the video.
@WesDoyle
@WesDoyle 3 жыл бұрын
Thanks for watching!
@RoamingAdhocrat
@RoamingAdhocrat 2 жыл бұрын
OK, got a really weird bug here / user error - I can't get the project to build / rebuild within Visual Studio. I make an edit e.g. change `return Ok("all good");` to `return Ok(users);` . Save the file. Hit "Run" in Test Explorer and the test is still failed. Run `dotnet test` in the terminal and it actually rebuilds the project and shows the test passing. How do I convince VS to actually rebuild the project?
@RoamingAdhocrat
@RoamingAdhocrat 2 жыл бұрын
Found it. But am more baffled as a result. I had the Solution Explorer in Folder View - which somehow stops the tests from rebuilding the projects...?
@emredevstudio
@emredevstudio Жыл бұрын
Hey, I came across your videos, they are awesome but you really need to write longer and better titles for visibility
@diegomelgar2696
@diegomelgar2696 Жыл бұрын
Hi @Wes, wondering if there would be a TDD video using factories, seeding data? Do you know or anyone here an excellent resource where I can find TDD with factories, mocking, seeding using .NET and that uses .NET CORE 6 or above?
@anushathomas6882
@anushathomas6882 2 жыл бұрын
Great explanation, Thank you ! Just one question any particular reason why you did not choose MS TEST project in VS instead of XUnit ? Is it a hard rule that we should use XUnit project for TDD or can we do the same with MS Test ?
@WesDoyle
@WesDoyle 2 жыл бұрын
Hi Anusha, MS Test can be used, it’s just a matter of framework preference. Each framework is a bit different! 😄
@mr.nobody4494
@mr.nobody4494 3 жыл бұрын
Thanks! 👌
@WesDoyle
@WesDoyle 3 жыл бұрын
👍
@ammarmangala9814
@ammarmangala9814 2 жыл бұрын
why is there no link to the repo?
@ItsSalesGabriel
@ItsSalesGabriel 3 жыл бұрын
Thanks for video
@WesDoyle
@WesDoyle 3 жыл бұрын
Thanks for watching!
@keychain8886
@keychain8886 2 жыл бұрын
Hello, I've question how do you solve this error on moq "Handler did not return a response message.", I try using same URL Address but still got that error
@ghostslinger3148
@ghostslinger3148 2 жыл бұрын
getting the same error, fixed it, double check the handlerMock 1:35:24 , he changed back to any httpRequestMessage
@abbasfais
@abbasfais Жыл бұрын
Amazing tutorial. So much better than the stupid tutorials that show you some kind of TDD in a command line project with no follow up on how it would be applied to the real world development. Also your way of mocking the HttpClient is something I tried to find a couple of times but failed.
@FabioGalanteMans
@FabioGalanteMans 3 жыл бұрын
Can you make the repository available for this project?
@WesDoyle
@WesDoyle 3 жыл бұрын
Hi Fabio, thanks for reaching out. At this time, source code is available to those supporting the channel on Patreon! You can find many other open source projects on my GitHub.
@ashrafmir9991
@ashrafmir9991 2 жыл бұрын
Great
@seth6072
@seth6072 2 жыл бұрын
In your Get_OnSuccess_InvokeUserServiceExactlyOnce(), you define a sut and result but never do anything with them. Whats the point of this? 42:59
@peculiarpeculiar2504
@peculiarpeculiar2504 2 жыл бұрын
Mehn, how I missed you.
@nomadnoland
@nomadnoland 2 жыл бұрын
Thanks for the tutorial, but why on earth should we spend one hour and a half to write a simple method that returns a list in a real environment? really I can't get my head around it.
@WesDoyle
@WesDoyle 2 жыл бұрын
in time it takes far less time, of course. and sometimes the answer is likely that you shouldn’t. there always tradeoffs, and everything depends on context.
@turkerkaraoglu1675
@turkerkaraoglu1675 2 жыл бұрын
Its nice until 1:16:00 , then everything is getting messy. Also not using mouse, instead always using keyboard why? Its very annoying.
@sivaprakas2830
@sivaprakas2830 Жыл бұрын
Why can't find NUnit tutorial
@newabyuser
@newabyuser 3 жыл бұрын
Been a while
@WesDoyle
@WesDoyle 3 жыл бұрын
Yes indeed, great to hear from you!
@atabayilker
@atabayilker Жыл бұрын
It's an awesome content for people getting into testing, but those unnecessary amounts of key presses got me a bit too hard :D Like WHY :D 17:14 - 17:17. Way too loud for me to concentrate on the actual thing that's going on.
@Ashmaelx
@Ashmaelx Жыл бұрын
This is not pure TDD. I think you make things more difficult for people who actually want to look at net core TDD, as a 3rd or 4th language, but actually know TDD ...
@kresnofatihimani5073
@kresnofatihimani5073 2 жыл бұрын
this feels like integration tests instead if unit tests
@WesDoyle
@WesDoyle 2 жыл бұрын
Hi Kresno, since I'm mocking out dependencies to test the method calls in isolation, I refer to this as unit testing. I tend to call integration tests those tests which encompass a greater system (e.g. integrating a database, network, or hardware). Thanks for watching!
@kresnofatihimani5073
@kresnofatihimani5073 2 жыл бұрын
@@WesDoyle i shouldnt have said that sorry. Im a noob. Plz disregard my comment XD just keep the videos comin bro
@WesDoyle
@WesDoyle 2 жыл бұрын
@@kresnofatihimani5073 no problem at all! i appreciate the question! all the best
@yoanncatala3525
@yoanncatala3525 2 жыл бұрын
Very good content. Thanks a lot for this guide. Just a comment as a viewer on something a bit annoying, too many code highlighting and navigation keyboard tricks, as your keystrokes are very loud. It's sometimes hard to focus on what you're saying seeing you going back and forward and highlighting every piece of code. 😉 Nevertheless, appreciate your effort doing such good video.
@danielwilkowski5899
@danielwilkowski5899 Жыл бұрын
13:00 - in TDD, you would remove that controller completely, and let tests drive creation of it. 13:20 - premature creation of Helpers and Fixtures 16:23 - explanation of why it's okay to leave the users controller "we know that's what it's going to look like". that's not tdd. that's coming up with code without tests. 24:10 - the "all good" string is not necessary for the tests to pass. 32:10 - you have added the service, the mock and the inject without any tests for that at all. not tdd. you should first write an assertion without ever writing the mock, see the test fail, then implement the service without mocks, and then write another test for the overriden behaviour. in TDD you should not write any code without tests (but you did), and you should not write any more test code that is necessary to make the test fail (which you again did do). Not watching anymore since that's clearly not TDD. it's probably a good start to testing, a good introduction to TDD, but that's not TDD.
@grumpydeveloper69
@grumpydeveloper69 2 жыл бұрын
Like the explanation and the way you show this subject. But man does this become a cluttered mess and this is just a few lines of actual controller and service code. The TDD code and all it's setup and mocking takes up so moch lines and time. What is a reasonable size this will be when you actually have implemented this on a true production app. I get that this pays off when you modify stuff then without breaking things without you knowing but man, won't this slow down development cycles and drive up cost to triple? Really not trying to dis TDD I really want to use this but I have no reference with production size apps
Intro to Unit Testing in C# using XUnit
1:42:09
IAmTimCorey
Рет қаралды 424 М.
Dockerize .NET 6 in 10 Minutes
13:33
Wes Doyle
Рет қаралды 154 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 918 М.
Secure a .NET Core API with Bearer Authentication
1:06:56
Les Jackson
Рет қаралды 192 М.
THIS stops 90% of C# Developers Learning TDD
19:40
Gui Ferreira
Рет қаралды 15 М.
I just tried o3-mini
6:31
ThePrimeTime
Рет қаралды 236 М.
10 Signs Your Software Project Is Heading For FAILURE
17:59
Continuous Delivery
Рет қаралды 46 М.
Dependency Injection in .NET Core (.NET 6)
1:00:32
IAmTimCorey
Рет қаралды 198 М.
Start Your TDD Journey with C# in 15 MINUTES
14:55
Gui Ferreira
Рет қаралды 24 М.