 So, in this video, we'll try to see what exactly is the end unit testing and how do we use end unit testing which is fundamentally nothing but a unit testing framework for .NET applications in a sharpdialup. And when we are talking about .NET applications, we are specifically focusing on C sharp. Okay. So, let us see like what is the outcome is associated with this video. Make sure by watching this video, the participant will be able to understand what is end unit and how we can use the end unit testing framework in sharpdialup to test the small C sharp code snippets. The query requisite to this hands-on session, I expect you know what are the fundamentals of C sharp language and I expect you all to have a .NET framework installed on your machines compatible with your operating systems and we need a stable and latest sharpdialup ID. So, if you are using the one which is compatible to my machine, your machine could be anything it even a Linux machine would do, but you need to have a different idea is the configurations of that machine is already different. So, let us do an hands-on here which to sharpdialup and I don't have anything created as of now. So, I'll first create a small solution and I'll and that solution would be a console application and I'll name this solution as even odd and I'll click on create and rest all parameters I'll keep everything in the default here. So, I'll click create and I do have some collected let me clear this build output window and let me delete the template comments. So, I'll increase the font here. The shortcut is hold the control and move up your scroll bar the control increases yes, okay fine. So, I have the proper font here, okay maybe this is this is fine now here I won't need all this stuff here so I'll just remove this and I'll just retain this console dot I'll even remove this because we were not gonna execute that method we are not gonna execute the program and test it. We're gonna test the working of method just by executing them through an unit. So, we have this methods and let's also write a methods here and for a quick ease of access in accessing those methods I'll make this method static so public static and return type would be boolean and the method name would be ease evan so the name itself is very self-explanatory the role of this method is to check whether the number which is passed to it is even or not so if I need to write a if code to check the condition for evenness and I'll write else block here now you can recall that number mod 2 if it is equal to 0 then the number is even so let me put a bracket here it's a good coding practice. So, if number mod 2 equals 0 means it's an even number and if it is even the function will return true and if it is not this will return false okay so I'll repeat the same code for okay so this is to test whether the number is even or not remember when I'm saying a number is this methods object it will just return you true if the number is even whether it returns false whether it is or no we're gonna write a separate method for that okay so let me just quickly copy and paste and convert that method into ease odd so now here instead of even I'll call ease odd yes so when would be already this mod is equal to 1 if it is say after dividing by 2 if you have remained a 1 number is odd and if it is not it's false so I have two different methods you pass a number to this method if the number is even it should return you true you pass a number to this odd if the number is odd it should return you to if it is not it it's gonna return you the other value which is false here in the both the cases fine so now I want to check whether my definition is right or not to check this we have two ways the one is to execute this method provide few numbers take a number from a user and make sure but we are not gonna do that what we are interested in we are interested in testing it with the help of unit testing framework and here specifically it is an unit so let us see how do I write a test cases to execute this method and then we'll see like how we can execute the test cases so to add a test case to this so select your solution right click and click on add okay so now while there are multiple ways to add a new item so click on add an item fine okay so let me do one thing if it is not okay so select the project not the solution select the solution so see that way I am clicking here on even here on that the the project window this is a project window it's a solution right click on this click on add new item and here make sure you're selecting C sharp dialogue here C sharp the moment you select here you will find a class called as unit test so I'm moving my mouse over this this is important that you select this unit test class and give a proper name to it I'm gonna call this as even odd test cases so you can always choose a proper name the extension would be dot CS remember even this is a CS file so I am clicking on create so let me clear clear the build output window here okay so now I have this test cases you can say this was my program and this is a test case which I have automatically added I'm increasing the font of this so let me remove this comments here so you can note that here it added the end unit framework this is what I was talking about it comes with dot net framework and with the help of this framework I can test the test cases here now it it's it's some kind of boilerplate code generated for us when I wanted a test kit to be generated so note down that both the classes belong to a same namespace both classes belong to same namespace here I have a class name event or test cases and this lets this this annotation here this specifically tells the dot net environment that this class is a test case it is meant to be executed as a testing under any unit framework which comes with dot net so this is not then something a main application or library which can be loaded or executed and here this exactly the test case which lets me write my assertions so here in a test cases in an unit form if you want to test whether methods working or not we would we are actually invoking that method and we see if the method is returning to or not so it's like saying that I expect true from this method so I'm gonna pass to as input to this method and I expect that method will return true and this is what the entire clause I'm asking the my annual framework to test so here I'm asking the end unit to assert whether it is giving me true or false and I'm expecting true and I'm expecting false here so quickly will execute that so delete this so I'm first writing a small test case to just test the event remember I use assertion here so this is the standard class available so assert dot there is a method called as is true now when you open this there are multiple methods what I'm using main is this Boolean condition so we are not going into more details it could be like you can further with the help of bibliography you can go to documentation you can explore further methods but here I'm going to directly invoke the method so I am saying I'm asserting it whether the method which I'm providing here will be returning true or not so the my method was a static method so I can access it by class name dot is even and here I'll pass even number two is even okay let's do one thing we'll fire pass a four so four is so this is a test case so now if I execute the test case would pass if this method call returns true so I'm asserting whether this is returning true or not if my assertion succeeds then it's indication of my test case being passed and indirectly it's an assertion that my method is working fine but at the same time as we have defined the method is even to return false if a number is not false so to properly ascertain if that method is perfectly working that method has to assert false when I pass a odd number so here I'll call is false now here if both the math more the test cases pass then I can ascertain that my is even method implementation is as per the expectations so let me execute this so I have two test methods let us call it a test method one and let us call the test method two save it and build your first solution after executing this so I'll output a build successful so warnings you can ignore here and so now I need to execute this so how do I exit I don't I'm not going to run this program remember I need to execute the test cases so to execute the test cases open an unit window here so I am at the view menu and I'll go to tools and when you go under tools here you will find a menu called unit test click on this it opens a unit test window here at this here expand this it will list out all the test cases which are written test method one and test method two so now you want to execute both it all the test cases present in this you click on this green double arrow double execute button click on this it executes test cases if both the test cases have passed then it will show you in a green colored buttons that both the test cases have passed so here let us suppose here if I pass instead of four I'm passing a value three so I'm just saying actually I'm testing something very odd configuration here but just to show you an output like what would happen if this assertion fails so it is expecting true and will this give a true as per our implementation this won't give a true so what happens here is this test case would fail so now given the change so earlier it was four I made it to three given this change if I execute unit test cases once again you can see that test method one has failed but two has executed okay so it also points out so sometimes you can also give us some message so this message appears in as a debug message so you can see like what happens if I so for some standard reporting in analytics developers are always required to give proper message here but I'm just putting a generic message to see like what exactly happens with that message okay and no no no and I don't want to execute this so go to unit test and execute here you can see that so this method appears here so this for many automated testing frameworks when you execute your application in continuous integration and deployment pipelines this method might have a lot of hidden meaning and the lot of configuration and another further sequence of chain events may be dependent on this methods so that's the role of this method here okay so we'll come back to normal one is six seven number yes so now if I execute fine it will execute both you can find the both they have turned on you can even execute a single test case as well so you can select this and you can only select this is so single test case method to can run so in short this is is an unit testing framework so you by now you might have had a free idea like what exactly is unit testing and how we can unit test a C sharp applications so what do you think like you you have watched this and you have done something background work on unit testing or testing so what do you think what what how you think a unit testing framework could be beneficial to a dotnet developer so yes the answer is once again the same like what we do here is this testing frameworks help dotnet developers execute methods without even making sure the entire module our entire application is completed so generally what we do is we have an application we split it into modules and assume without any unit testing you will be only able to test the application only after entire application is done so which has to wait for all modules to complete the execution and all but by using unit testing frameworks what advantage we get is we did not wait for all other modules to complete we can test every module individually and this all depends upon what's the method signature what this is what are the assertion class which you've seen we only asserted a Boolean conditions but those as that asset class is too long and there are a lot of other methods so I can show you here for example asset is false so there are these all are a very big set of assertion methods so you can also see what it contains does it throw fail falls there are multiple there's a plethora of methods which let developer test a variety of modules with a variety of written numbers so the for a further reading you can refer Microsoft documentation and for a detailed and better understanding of any unit and all the intricacies of unit testing especially and unit framework I would refer you to go through any unit documentation and and if you need a even more better introduction of unit testing and what exactly it is a tool a lemon based definitions of your unit testing refer to Wikipedia okay so that's it for this video thank you