{"id":14008,"date":"2023-10-16T07:46:09","date_gmt":"2023-10-16T07:46:09","guid":{"rendered":"https:\/\/positiwise.com\/blog\/?p=14008"},"modified":"2023-10-16T09:05:43","modified_gmt":"2023-10-16T09:05:43","slug":"unit-testing-in-net-core-using-nunit","status":"publish","type":"post","link":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit","title":{"rendered":"Unit Testing in .NET Core Using NUnit"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong class=\"pw-highlight-text-color\"><em>Quick Overview:<\/em><\/strong><br>The blog &#8220;Unit Testing In .NET Core Using NUnit&#8221; offers a complete process to integrate the NUnit testing framework with your ASP.NET API project and test its functionality. The step-by-step process will help you create a project, add files, put relevant code, and test them using NUnit. Through this, you will grasp how to invoke the methods and confirm if they return the correct data using unit tests in NUnit.<\/p><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\/#A_Run-Through_NET_Core_vs_Nodejs\" >A Run-Through: .NET Core vs Node.js<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\/#NET_Core\" >.NET Core<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\/#Pros_of_using_NET_Core\" >Pros of using .NET Core<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\/#Nodejs\" >Node.js<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\/#A_Deep_Dive_into_NET_Core_vs_Nodejs\" >A Deep Dive into .NET Core vs. Node.js<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\/#Processing_Approach_and_Performance\" >Processing Approach and Performance<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\/#Security\" >Security<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\/#Scalability\" >Scalability<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\/#Platform_Adaptability\" >Platform Adaptability<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\/#Support_from_Community\" >Support from Community<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\/#Comparison_Table_between_NET_Core_and_Nodejs\" >Comparison Table between .NET Core and Node.js<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\/#Wrapping_Up_on_NET_Core_vs_Nodejs\" >Wrapping Up on .NET Core vs Node.js<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<h2 class=\"wp-block-heading\">How to Use NUnit for Unit Testing in ASP.NET Core<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In <a href=\"https:\/\/positiwise.com\/technologies\/dot-net-development\">.NET development<\/a>, developers widely use NUnit, one of the most popular frameworks, for unit testing multiple programs or an individual code block. Its fundamentals are based on JUnit, but its primary functioning is to test the .NET web applications and the .NET Web API project.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are a .NET developer, then you must know this framework and how to integrate and use it with ASP.NET Core applications. It will help you offer the best-in-class dotnet development services to clients.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, let\u2019s have a look at it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Unit Testing?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Unit testing is a <a href=\"https:\/\/positiwise.com\/blog\/what-is-software-development-methodology\">software testing methodology<\/a> performed by developers to check the functionality of an individual code block or a set of programs. The main aim of unit testing is to identify and solve errors at the developers\u2019 end.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Unit testing can reduce the time testers take to verify the functionality, compatibility, and security of .NET web applications. In addition, it will also help the developers to push streamlined and well-working code to the final product.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Process To Perform Unit Test in .NET Core Using NUnit<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To learn the unit testing process with NUnit, we will create an ASP.NET Core web API project in Visual Studio. Ensure that your system has a 2019 or later version of the IDE; otherwise, compatibility issues can arise.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In addition, with the NUnit testing framework, this tutorial also includes a significant use of Moq. We will employ the Moq method to make the data call for testing an<a href=\"https:\/\/positiwise.com\/hire\/net-web-api-development\"> ASP.NET Web API<\/a> call, and then we will use NUnit to test the returned value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this procedure, we divide the complete process into phases, which, in turn, break down into smaller steps. It will help you understand every process and execute it properly. So, let\u2019s start with it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Phase 1: Creating the Project<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open your Visual Studio IDE and navigate to <strong><em>File &gt;&gt; New &gt;&gt; Project.<\/em><\/strong><\/li>\n\n\n\n<li>Choose the <strong><em>ASP.NET Core Web Application<\/em><\/strong> from the available project templates, and to finalize it, left-click the <strong><em>Next<\/em><\/strong> button.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"979\" height=\"646\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/create-new-project-window.png\" alt=\"Create New Project Window\" class=\"wp-image-14023\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/create-new-project-window.png 979w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/create-new-project-window-300x198.png 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/create-new-project-window-768x507.png 768w\" sizes=\"auto, (max-width: 979px) 100vw, 979px\" \/><\/figure>\n\n\n\n<ol start=\"3\">\n<li>The Visual Studio will ask for the <strong>project details<\/strong>. Fill them up and move to the next step by clicking on the <strong>Create<\/strong> button. <\/li>\n<li>The IDE will provide the option to <strong><em>select the type<\/em><\/strong> of ASP.NET Core web application project. Firstly, choose <strong><em>.NET Core<\/em><\/strong> and <strong><em>ASP.NET Core 3.1<\/em><\/strong> from the drop-down list at the top. After that, select the API similar to the following snippet.<\/li>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"953\" height=\"613\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/select-api-option.png\" alt=\"Select API Option\" class=\"wp-image-14036\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/select-api-option.png 953w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/select-api-option-300x193.png 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/select-api-option-768x494.png 768w\" sizes=\"auto, (max-width: 953px) 100vw, 953px\" \/><\/figure>\n\n\n\n<ol start=\"5\"><li>Click on <strong><em>Create<\/em><\/strong>, and your project will be displayed on the screen. <\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Here, our first phase is completed.<\/p>\n\n\n\n<div class=\"wp-block-group border rounded bg-light has-global-padding is-layout-constrained wp-container-core-group-is-layout-71df2e02 wp-block-group-is-layout-constrained\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\">\n<p class=\"has-text-align-center fs-2 text-blue lh-sm has-contrast-color has-text-color wp-block-paragraph\"><strong>Develop .NET Web Application with ASP.NET Technologies&nbsp;<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-center mt-2 wp-block-paragraph\">Bring your web app ideas to ASP.NET development experts. Hire our skilled .NET developers to build secure, scalable web &amp; desktop web applications.<\/p>\n\n\n\n<div class=\"wp-block-buttons mt-3 is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-20959078 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-base-color has-text-color has-background wp-element-button\" href=\"https:\/\/positiwise.com\/hire-asp-net-developers\" style=\"border-radius:100px;background-color:#ed7923;padding-top:10px;padding-right:30px;padding-bottom:10px;padding-left:30px\"><strong>Hire .NET Developers Now<\/strong><\/a><\/div>\n<\/div>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Phase 2: Integration of NUnit and Moq (Creation of Unit Test Project)<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Navigate to the project solution and right-click on it. From its menu, choose <strong><em>Add &gt;&gt; New Project<\/em><\/strong>.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1033\" height=\"618\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/add-a-new-project-option.png\" alt=\"Add a New Project\" class=\"wp-image-14021\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/add-a-new-project-option.png 1033w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/add-a-new-project-option-300x179.png 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/add-a-new-project-option-1024x613.png 1024w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/add-a-new-project-option-768x459.png 768w\" sizes=\"auto, (max-width: 1033px) 100vw, 1033px\" \/><\/figure>\n\n\n\n<ol start=\"2\"><li>From the project templates, choose the <strong><em>NUnit Test Project (.NET Core)<\/em><\/strong>. Click on the <strong><em>Next<\/em><\/strong> button to move further.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"944\" height=\"623\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/nunit-test-project.png\" alt=\"NUnit Test Project\" class=\"wp-image-14033\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/nunit-test-project.png 944w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/nunit-test-project-300x198.png 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/nunit-test-project-768x507.png 768w\" sizes=\"auto, (max-width: 944px) 100vw, 944px\" \/><\/figure>\n\n\n\n<ol start=\"3\">\n<li>Set the <strong><em>project name<\/em><\/strong> and use the <strong><em>Create<\/em><\/strong> button to finalize it. In the solutions explorer, you will see the unit test project and associated files.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"342\" height=\"261\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/solution-explorer-project1.jpg\" alt=\"Solution Explorer Project1\" class=\"wp-image-14042\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/solution-explorer-project1.jpg 342w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/solution-explorer-project1-300x229.jpg 300w\" sizes=\"auto, (max-width: 342px) 100vw, 342px\" \/><\/figure>\n\n\n\n<ol start=\"4\">\n<li>For <strong><em>Projetc1.Tests<\/em><\/strong>, open the NuGet package manager, and find the <strong><em>Moq<\/em><\/strong>. Match the result with the following snippet and integrate the correct package.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1232\" height=\"371\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/nuget-pack-manager.jpg\" alt=\"NuGet Pack Manager\" class=\"wp-image-14032\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/nuget-pack-manager.jpg 1232w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/nuget-pack-manager-300x90.jpg 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/nuget-pack-manager-1024x308.jpg 1024w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/nuget-pack-manager-768x231.jpg 768w\" sizes=\"auto, (max-width: 1232px) 100vw, 1232px\" \/><\/figure>\n\n\n\n<ol start=\"5\">\n<li>After installation of Moq, it will be displayed in the <strong><em>Solutions Explorer<\/em><\/strong>.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1031\" height=\"346\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/installing-moq-nuget-package.jpg\" alt=\"Installing Moq NuGet Package\" class=\"wp-image-14045\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/installing-moq-nuget-package.jpg 1031w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/installing-moq-nuget-package-300x101.jpg 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/installing-moq-nuget-package-1024x344.jpg 1024w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/installing-moq-nuget-package-768x258.jpg 768w\" sizes=\"auto, (max-width: 1031px) 100vw, 1031px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Here, we complete the second phase.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Phase 3: Creation of Unit Test Case<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In this phase, we are going to test an addition program using the NUnit. The method in the program provides the addition of two numbers as a result. Also, when you <a href=\"https:\/\/positiwise.com\/hire\/hire-dot-net-core-developers\">hire .NET core developers<\/a>, they create test cases to ensure that every component will be checked before reaching the production stage. <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to <strong><em>Solutions Explorer<\/em><\/strong> and under the <strong><em>Project.Main.Test<\/em><\/strong> add a <strong><em>MathBL.cs<\/em><\/strong> file containing the <strong><em>Sum()<\/em><\/strong> method as below.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"991\" height=\"311\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/declaring-a-class-to-test.png\" alt=\"Declaring a Class to Test\" class=\"wp-image-14027\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/declaring-a-class-to-test.png 991w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/declaring-a-class-to-test-300x94.png 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/declaring-a-class-to-test-768x241.png 768w\" sizes=\"auto, (max-width: 991px) 100vw, 991px\" \/><\/figure>\n\n\n\n<ol start=\"2\">\n<li>Again, navigate to Project1.Test to <strong><em>add MathTestBL.cs<\/em><\/strong> class file.<\/li>\n<li>Open the MathTestBL.cs file and add the <strong><em>Setup()<\/em><\/strong> and <strong><em>TestSum()<\/em><\/strong> methods.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"924\" height=\"395\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/adding-a-test-method.png\" alt=\"Adding a Test Method\" class=\"wp-image-14022\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/adding-a-test-method.png 924w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/adding-a-test-method-300x128.png 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/adding-a-test-method-768x328.png 768w\" sizes=\"auto, (max-width: 924px) 100vw, 924px\" \/><\/figure>\n\n\n\n<ol start=\"4\">\n<li>Now, add the reference if <strong><em>Project.Main.Test to Project1.Test<\/em><\/strong>. By right-clicking on Project1.Test, you will get the option to add project references.<\/li>\n<li>In the <strong>MathTestBL.cs<\/strong> class file, <strong><em>include<\/em><\/strong> the below-highlighted code block.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1030\" height=\"408\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/defining-the-test-method.png\" alt=\"Defining the Test Method\" class=\"wp-image-14028\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/defining-the-test-method.png 1030w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/defining-the-test-method-300x119.png 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/defining-the-test-method-1024x406.png 1024w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/defining-the-test-method-768x304.png 768w\" sizes=\"auto, (max-width: 1030px) 100vw, 1030px\" \/><\/figure>\n\n\n\n<ol start=\"6\">\n<li>Go to <strong><em>View<\/em><\/strong> and choose <strong><em>Test Explorer<\/em><\/strong> under it. It will help you build the project and check the code.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"394\" height=\"297\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/opening-test-explorer.png\" alt=\"Opening Test Explorer\" class=\"wp-image-14034\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/opening-test-explorer.png 394w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/opening-test-explorer-300x226.png 300w\" sizes=\"auto, (max-width: 394px) 100vw, 394px\" \/><\/figure>\n\n\n\n<ol start=\"7\">\n<li>The Test Explorer will display all the methods. You have to use right-click on <strong><em>MathTestBL<\/em><\/strong> and choose the <strong><em>Run<\/em><\/strong> option. The following snippet demonstrates that the IDE will test the class file and provide results.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"324\" height=\"351\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/running-the-test.png\" alt=\"Running the Test\" class=\"wp-image-14035\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/running-the-test.png 324w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/running-the-test-277x300.png 277w\" sizes=\"auto, (max-width: 324px) 100vw, 324px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The test is successful if you see all the green checks; otherwise, some error has been encountered.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"531\" height=\"162\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/test-result.png\" alt=\"Test Result\" class=\"wp-image-14037\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/test-result.png 531w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/test-result-300x92.png 300w\" sizes=\"auto, (max-width: 531px) 100vw, 531px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Here, the phase three is completed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Phase 4: Testing the Data Access Service Call and Mock Database<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This is the last phase of this tutorial of NUnit for unit testing in ASP.NET Core. We have to create a database context first with the name Customer.cs.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Under the <strong><em>Solutions Explorer<\/em><\/strong>, create the classes and add code like the following snippet.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"950\" height=\"462\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/customer-model-class.png\" alt=\"Customer Model Class\" class=\"wp-image-14026\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/customer-model-class.png 950w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/customer-model-class-300x146.png 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/customer-model-class-768x373.png 768w\" sizes=\"auto, (max-width: 950px) 100vw, 950px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"963\" height=\"344\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/customer-db-context.png\" alt=\"CustomerDB Context\" class=\"wp-image-14025\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/customer-db-context.png 963w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/customer-db-context-300x107.png 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/customer-db-context-768x274.png 768w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/figure>\n\n\n\n<ol start=\"2\">\n<li>Create the data access logic. You have to implement this logic by creating an <strong><em>EntityRepository.cs<\/em><\/strong> file, having an interface named <strong><em>IEntityRepository.cs<\/em><\/strong>.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"950\" height=\"480\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/entity-repository.png\" alt=\"Entity Repository\" class=\"wp-image-14029\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/entity-repository.png 950w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/entity-repository-300x152.png 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/entity-repository-768x388.png 768w\" sizes=\"auto, (max-width: 950px) 100vw, 950px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"964\" height=\"317\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/entity-repository-interface.png\" alt=\"Entity Repository Interface\" class=\"wp-image-14030\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/entity-repository-interface.png 964w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/entity-repository-interface-300x99.png 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/entity-repository-interface-768x253.png 768w\" sizes=\"auto, (max-width: 964px) 100vw, 964px\" \/><\/figure>\n\n\n\n<ol start=\"3\">\n<li>Create the business logic by adding a new <strong><em>CustomerBL.cs<\/em><\/strong> file. Further, add the <strong><em>getActiveCustomer()<\/em><\/strong> and <strong><em>SaveCustomer()<\/em><\/strong> methods in the file.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"989\" height=\"567\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/customer-bl-class.png\" alt=\"CustomerBL Class\" class=\"wp-image-14024\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/customer-bl-class.png 989w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/customer-bl-class-300x172.png 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/customer-bl-class-768x440.png 768w\" sizes=\"auto, (max-width: 989px) 100vw, 989px\" \/><\/figure>\n\n\n\n<ol start=\"4\">\n<li>Under the Project1.Tests, create <strong><em>CustomerTestBL.cs<\/em><\/strong> and a method under the name <strong><em>TestGetActiveCustomer().<\/em><\/strong><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1001\" height=\"540\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/unit-test-case-for-customer-bl-class.jpg\" alt=\"Unit Test Case for CustomerBL Class\" class=\"wp-image-14046\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/unit-test-case-for-customer-bl-class.jpg 1001w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/unit-test-case-for-customer-bl-class-300x162.jpg 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/unit-test-case-for-customer-bl-class-768x414.jpg 768w\" sizes=\"auto, (max-width: 1001px) 100vw, 1001px\" \/><\/figure>\n\n\n\n<ol start=\"5\">\n<li>Create a mock instance for <strong><em>IEntityRepository&lt;Customer&gt;<\/em><\/strong>. A fixed customer list will be returned when the program uses the <strong><em>GetQueriable()<\/em><\/strong> method. Below is the code for it that you need to implement.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"638\" height=\"435\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/mock-and-test-code.png\" alt=\"Mock and Test\" class=\"wp-image-14061\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/mock-and-test-code.png 638w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/mock-and-test-code-300x205.png 300w\" sizes=\"auto, (max-width: 638px) 100vw, 638px\" \/><\/figure>\n\n\n\n<ol start=\"6\">\n<li>Open the <strong><em>View<\/em><\/strong> menu and select <strong><em>Test Explorer<\/em><\/strong> to view the test case list.<\/li>\n<li>From the available test cases, open the options for <strong><em>TestGetActiveRecords<\/em><\/strong> by right-clicking on it.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"393\" height=\"321\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/running-the-test-cases.jpg\" alt=\"Running the Test Cases\" class=\"wp-image-14048\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/running-the-test-cases.jpg 393w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/running-the-test-cases-300x245.jpg 300w\" sizes=\"auto, (max-width: 393px) 100vw, 393px\" \/><\/figure>\n\n\n\n<ol start=\"8\">\n<li>The Test Explorer will display the results. NUnit provides all these results, as we are using it for unit testing.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"502\" height=\"216\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/project1-tests-result.jpg\" alt=\"Project1 Tests Result\" class=\"wp-image-14050\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/project1-tests-result.jpg 502w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/project1-tests-result-300x129.jpg 300w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">The Need of Dotnet Development Company for NUnit Testing<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To avail of the benefits of NUnit, you need a <a href=\"https:\/\/positiwise.com\/technologies\/dot-net-development\">dot NET development<\/a> services company. Such firms provide you with the right team of developers, experienced in building .NET applications, creating test cases, and ensuring software functionality, compatibility, and security.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In addition, the .NET development company leverages extended support to maintain your business software and test every component before deployment. They even help with patching loopholes and removing errors and bugs after deployment. But, you should make sure to collaborate with a trustworthy and .NET expert company like Positiwise Software Pvt Ltd.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up on Unit Testing In .NET Core Using NUnit<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">NUnit is a top choice of .NET developers for unit testing the application. This framework allows testing applications written in all .NET-compatible languages. We integrated our ASP.NET Core web API in this tutorial and tested the call function. In addition, we have also used Moq with NUnit to help with testing the dependencies.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The complete procedure is divided into four phases. The first two phases represent the steps for creating an ASP.NET project and integrating the required testing framework. The next two phases provide the step for testing the API calls using the NUnit and mocking framework. Completing all these phases will help you understand the implementation and working of NUnit in .NET.<\/p>\n  <div class=\"related-post slider\">\r\n        <div class=\"headline\">Related Posts<\/div>\r\n    <div class=\"post-list owl-carousel\">\r\n\r\n            <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\".Net Core vs. Java \u2013 Which One You Should Use for Your Projects?\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-java-technology\">\r\n\r\n      <img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"800\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2021\/12\/web-security-partner-1.jpg\" class=\"attachment-full size-full wp-post-image\" alt=\".Net Core vs. Java \u2013 Which One You Should Use for Your Projects?\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2021\/12\/web-security-partner-1.jpg 1200w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2021\/12\/web-security-partner-1-300x200.jpg 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2021\/12\/web-security-partner-1-1024x683.jpg 1024w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2021\/12\/web-security-partner-1-768x512.jpg 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\".Net Core vs. Java \u2013 Which One You Should Use for Your Projects?\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-java-technology\">\r\n        .Net Core vs. Java \u2013 Which One You Should Use for Your Projects?  <\/a>\r\n\r\n        <\/div>\r\n              <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\"Precise Road Map for ASP.NET Developers\" href=\"https:\/\/positiwise.com\/blog\/roadmap-for-asp-dot-net-developers\">\r\n\r\n      <img loading=\"lazy\" decoding=\"async\" width=\"1021\" height=\"621\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/dealership-1200x800-1.jpg\" class=\"attachment-full size-full wp-post-image\" alt=\"Hire ASP.NET Developers - A Precise Road Map to Employ ASP.NET Developers\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/dealership-1200x800-1.jpg 1021w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/dealership-1200x800-1-300x182.jpg 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/dealership-1200x800-1-768x467.jpg 768w\" sizes=\"auto, (max-width: 1021px) 100vw, 1021px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\"Precise Road Map for ASP.NET Developers\" href=\"https:\/\/positiwise.com\/blog\/roadmap-for-asp-dot-net-developers\">\r\n        Precise Road Map for ASP.NET Developers  <\/a>\r\n\r\n        <\/div>\r\n              <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\".NET Core vs Node.js: The Difference Explained by Web Expert\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\">\r\n\r\n      <img loading=\"lazy\" decoding=\"async\" width=\"1021\" height=\"621\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/NET-Core-VS-Node-js-jpg.webp\" class=\"attachment-full size-full wp-post-image\" alt=\"NET-Core-VS-Node-js\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/NET-Core-VS-Node-js-jpg.webp 1021w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/NET-Core-VS-Node-js-300x182.webp 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/NET-Core-VS-Node-js-768x467.webp 768w\" sizes=\"auto, (max-width: 1021px) 100vw, 1021px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\".NET Core vs Node.js: The Difference Explained by Web Expert\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-node-js\">\r\n        .NET Core vs Node.js: The Difference Explained by Web Expert  <\/a>\r\n\r\n        <\/div>\r\n      \r\n  <\/div>\r\n\r\n  <script>\r\n      <\/script>\r\n  <style>\r\n    .related-post {}\r\n\r\n    .related-post .post-list {\r\n      text-align: left;\r\n          }\r\n\r\n    .related-post .post-list .item {\r\n      margin: 5px;\r\n      padding: 0px;\r\n          }\r\n\r\n    .related-post .headline {\r\n      font-size: 2rem !important;\r\n      color: #212529 !important;\r\n          }\r\n\r\n    .related-post .headline {\r\nmargin-top: 0;\r\npadding-left: 1%;\r\n}.related-post .post-list .item .post_thumb {\r\n      max-height: 220px;\r\n      margin: 0px 0px 10px 0px;\r\n      padding: 0px;\r\n      display: block;\r\n          }\r\n\r\n    .related-post .post-list .item .post_title {\r\n      font-size: 1rem;\r\n      color: #212529;\r\n      margin: 10px 0px;\r\n      padding: 0px;\r\n      display: block;\r\n      text-decoration: none;\r\n          }\r\n\r\n    .related-post .post-list .item .post_excerpt {\r\n      font-size: 13px;\r\n      color: #3f3f3f;\r\n      margin: 10px 0px;\r\n      padding: 0px;\r\n      display: block;\r\n      text-decoration: none;\r\n          }\r\n\r\n    .related-post .owl-dots .owl-dot {\r\n          }\r\n\r\n      <\/style>\r\n      <script>\r\n      jQuery(document).ready(function($) {\r\n        $(\".related-post .post-list\").owlCarousel({\r\n          items: 3,\r\n          responsiveClass: true,\r\n          responsive: {\r\n            0: {\r\n              items: 1,\r\n            },\r\n            768: {\r\n              items: 2,\r\n            },\r\n            1200: {\r\n              items: 3,\r\n            }\r\n          },\r\n                      rewind: true,\r\n                                loop: true,\r\n                                center: true,\r\n                                autoplay: true,\r\n            autoplayHoverPause: true,\r\n                                nav: true,\r\n            navSpeed: 1000,\r\n            navText: ['<i class=\"fas fa-chevron-left\"><\/i>', '<i class=\"fas fa-chevron-right\"><\/i>'],\r\n                                dots: true,\r\n            dotsSpeed: 1200,\r\n                                                    rtl: false,\r\n          \r\n        });\r\n      });\r\n    <\/script>\r\n  <\/div>\r\n","protected":false},"excerpt":{"rendered":"<p>Quick Overview:The blog &#8220;Unit Testing In .NET Core Using NUnit&#8221; offers a complete process to integrate the NUnit [&hellip;]<\/p>\n  <div class=\"related-post slider\">\r\n        <div class=\"headline\">Related Posts<\/div>\r\n    <div class=\"post-list owl-carousel\">\r\n\r\n            <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\".Net Core vs. Java \u2013 Which One You Should Use for Your Projects?\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-java-technology\">\r\n\r\n      <img width=\"1200\" height=\"800\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2021\/12\/web-security-partner-1.jpg\" class=\"attachment-full size-full wp-post-image\" alt=\".Net Core vs. Java \u2013 Which One You Should Use for Your Projects?\" decoding=\"async\" loading=\"lazy\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2021\/12\/web-security-partner-1.jpg 1200w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2021\/12\/web-security-partner-1-300x200.jpg 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2021\/12\/web-security-partner-1-1024x683.jpg 1024w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2021\/12\/web-security-partner-1-768x512.jpg 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\".Net Core vs. Java \u2013 Which One You Should Use for Your Projects?\" href=\"https:\/\/positiwise.com\/blog\/net-core-vs-java-technology\">\r\n        .Net Core vs. Java \u2013 Which One You Should Use for Your Projects?  <\/a>\r\n\r\n        <\/div>\r\n              <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\"Precise Road Map for ASP.NET Developers\" href=\"https:\/\/positiwise.com\/blog\/roadmap-for-asp-dot-net-developers\">\r\n\r\n      <img width=\"1021\" height=\"621\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/dealership-1200x800-1.jpg\" class=\"attachment-full size-full wp-post-image\" alt=\"Hire ASP.NET Developers - A Precise Road Map to Employ ASP.NET Developers\" decoding=\"async\" loading=\"lazy\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/dealership-1200x800-1.jpg 1021w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/dealership-1200x800-1-300x182.jpg 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/dealership-1200x800-1-768x467.jpg 768w\" sizes=\"auto, (max-width: 1021px) 100vw, 1021px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\"Precise Road Map for ASP.NET Developers\" href=\"https:\/\/positiwise.com\/blog\/roadmap-for-asp-dot-net-developers\">\r\n        Precise Road Map for ASP.NET Developers  <\/a>\r\n\r\n        <\/div>\r\n              <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\"A Descriptive Guide to .NET Framework\" href=\"https:\/\/positiwise.com\/blog\/a-descriptive-guide-to-dot-net-framework\">\r\n\r\n      <img width=\"1021\" height=\"621\" src=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/a-descriptive-guide-to-dot-net-framework.jpg\" class=\"attachment-full size-full wp-post-image\" alt=\"A Descriptive Guide to .NET Framework\" decoding=\"async\" loading=\"lazy\" srcset=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/a-descriptive-guide-to-dot-net-framework.jpg 1021w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/a-descriptive-guide-to-dot-net-framework-300x182.jpg 300w, https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2022\/01\/a-descriptive-guide-to-dot-net-framework-768x467.jpg 768w\" sizes=\"auto, (max-width: 1021px) 100vw, 1021px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\"A Descriptive Guide to .NET Framework\" href=\"https:\/\/positiwise.com\/blog\/a-descriptive-guide-to-dot-net-framework\">\r\n        A Descriptive Guide to .NET Framework  <\/a>\r\n\r\n        <\/div>\r\n      \r\n  <\/div>\r\n\r\n  <script>\r\n      <\/script>\r\n  <style>\r\n    .related-post {}\r\n\r\n    .related-post .post-list {\r\n      text-align: left;\r\n          }\r\n\r\n    .related-post .post-list .item {\r\n      margin: 5px;\r\n      padding: 0px;\r\n          }\r\n\r\n    .related-post .headline {\r\n      font-size: 2rem !important;\r\n      color: #212529 !important;\r\n          }\r\n\r\n    .related-post .headline {\r\nmargin-top: 0;\r\npadding-left: 1%;\r\n}.related-post .post-list .item .post_thumb {\r\n      max-height: 220px;\r\n      margin: 0px 0px 10px 0px;\r\n      padding: 0px;\r\n      display: block;\r\n          }\r\n\r\n    .related-post .post-list .item .post_title {\r\n      font-size: 1rem;\r\n      color: #212529;\r\n      margin: 10px 0px;\r\n      padding: 0px;\r\n      display: block;\r\n      text-decoration: none;\r\n          }\r\n\r\n    .related-post .post-list .item .post_excerpt {\r\n      font-size: 13px;\r\n      color: #3f3f3f;\r\n      margin: 10px 0px;\r\n      padding: 0px;\r\n      display: block;\r\n      text-decoration: none;\r\n          }\r\n\r\n    .related-post .owl-dots .owl-dot {\r\n          }\r\n\r\n      <\/style>\r\n      <script>\r\n      jQuery(document).ready(function($) {\r\n        $(\".related-post .post-list\").owlCarousel({\r\n          items: 3,\r\n          responsiveClass: true,\r\n          responsive: {\r\n            0: {\r\n              items: 1,\r\n            },\r\n            768: {\r\n              items: 2,\r\n            },\r\n            1200: {\r\n              items: 3,\r\n            }\r\n          },\r\n                      rewind: true,\r\n                                loop: true,\r\n                                center: true,\r\n                                autoplay: true,\r\n            autoplayHoverPause: true,\r\n                                nav: true,\r\n            navSpeed: 1000,\r\n            navText: ['<i class=\"fas fa-chevron-left\"><\/i>', '<i class=\"fas fa-chevron-right\"><\/i>'],\r\n                                dots: true,\r\n            dotsSpeed: 1200,\r\n                                                    rtl: false,\r\n          \r\n        });\r\n      });\r\n    <\/script>\r\n  <\/div>\r\n","protected":false},"author":3,"featured_media":14063,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-14008","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dot-net-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Unit Testing In .NET Core Using NUnit<\/title>\n<meta name=\"description\" content=\"Learn to implement unit testing in .NET Core with NUnit. Covers test setup, assertions, and best practices for effective unit testing.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unit Testing In .NET Core Using NUnit\" \/>\n<meta property=\"og:description\" content=\"Learn to implement unit testing in .NET Core with NUnit. Covers test setup, assertions, and best practices for effective unit testing.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit\" \/>\n<meta property=\"og:site_name\" content=\"Positiwise\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/positiwise\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-16T07:46:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-16T09:05:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/unit-testing-in-net-core-using-nunit.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1021\" \/>\n\t<meta property=\"og:image:height\" content=\"621\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Parag Mehta\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@positiwise\" \/>\n<meta name=\"twitter:site\" content=\"@positiwise\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Parag Mehta\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/unit-testing-in-net-core-using-nunit#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/unit-testing-in-net-core-using-nunit\"},\"author\":{\"name\":\"Parag Mehta\",\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/#\\\/schema\\\/person\\\/b4b3d9970ea94f5914a615f70345353a\"},\"headline\":\"Unit Testing in .NET Core Using NUnit\",\"datePublished\":\"2023-10-16T07:46:09+00:00\",\"dateModified\":\"2023-10-16T09:05:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/unit-testing-in-net-core-using-nunit\"},\"wordCount\":1304,\"publisher\":{\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/unit-testing-in-net-core-using-nunit#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/unit-testing-in-net-core-using-nunit.jpg\",\"articleSection\":[\".NET Development\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2022\",\"copyrightHolder\":{\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/unit-testing-in-net-core-using-nunit\",\"url\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/unit-testing-in-net-core-using-nunit\",\"name\":\"Unit Testing In .NET Core Using NUnit\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/unit-testing-in-net-core-using-nunit#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/unit-testing-in-net-core-using-nunit#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/unit-testing-in-net-core-using-nunit.jpg\",\"datePublished\":\"2023-10-16T07:46:09+00:00\",\"dateModified\":\"2023-10-16T09:05:43+00:00\",\"description\":\"Learn to implement unit testing in .NET Core with NUnit. Covers test setup, assertions, and best practices for effective unit testing.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/unit-testing-in-net-core-using-nunit#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/positiwise.com\\\/blog\\\/unit-testing-in-net-core-using-nunit\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/unit-testing-in-net-core-using-nunit#primaryimage\",\"url\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/unit-testing-in-net-core-using-nunit.jpg\",\"contentUrl\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/unit-testing-in-net-core-using-nunit.jpg\",\"width\":1021,\"height\":621,\"caption\":\"Unit Testing in .NET Core Using NUnit\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/unit-testing-in-net-core-using-nunit#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/positiwise.com\\\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unit Testing in .NET Core Using NUnit\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/\",\"name\":\"Positiwise\",\"description\":\"Providing Full-cycle Software Development Services\",\"publisher\":{\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/#organization\"},\"alternateName\":\"Positiwise Software Pvt Ltd\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/#organization\",\"name\":\"Positiwise\",\"alternateName\":\"Positiwise Software Pvt Ltd\",\"url\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/logo.png\",\"contentUrl\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/logo.png\",\"width\":202,\"height\":29,\"caption\":\"Positiwise\"},\"image\":{\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/positiwise\\\/\",\"https:\\\/\\\/x.com\\\/positiwise\",\"https:\\\/\\\/github.com\\\/positiwise\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/positiwise\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/#\\\/schema\\\/person\\\/b4b3d9970ea94f5914a615f70345353a\",\"name\":\"Parag Mehta\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/072ea4a638415a77610a840228d51b8225ad88856ed34d69cbe1fcd638390535?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/072ea4a638415a77610a840228d51b8225ad88856ed34d69cbe1fcd638390535?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/072ea4a638415a77610a840228d51b8225ad88856ed34d69cbe1fcd638390535?s=96&r=g\",\"caption\":\"Parag Mehta\"},\"description\":\"Parag Mehta, the CEO and Founder of Positiwise Software Pvt Ltd has extensive knowledge of the development niche. He is implementing custom strategies to craft highly-appealing and robust applications for its clients and supporting employees to grow and ace the tasks. He is a consistent learner and always provides the best-in-quality solutions, accelerating productivity.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/paragcmehta\"],\"url\":\"https:\\\/\\\/positiwise.com\\\/blog\\\/author\\\/parag-mehta\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Unit Testing In .NET Core Using NUnit","description":"Learn to implement unit testing in .NET Core with NUnit. Covers test setup, assertions, and best practices for effective unit testing.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit","og_locale":"en_US","og_type":"article","og_title":"Unit Testing In .NET Core Using NUnit","og_description":"Learn to implement unit testing in .NET Core with NUnit. Covers test setup, assertions, and best practices for effective unit testing.","og_url":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit","og_site_name":"Positiwise","article_publisher":"https:\/\/www.facebook.com\/positiwise\/","article_published_time":"2023-10-16T07:46:09+00:00","article_modified_time":"2023-10-16T09:05:43+00:00","og_image":[{"width":1021,"height":621,"url":"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/unit-testing-in-net-core-using-nunit.jpg","type":"image\/jpeg"}],"author":"Parag Mehta","twitter_card":"summary_large_image","twitter_creator":"@positiwise","twitter_site":"@positiwise","twitter_misc":{"Written by":"Parag Mehta","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit#article","isPartOf":{"@id":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit"},"author":{"name":"Parag Mehta","@id":"https:\/\/positiwise.com\/blog\/#\/schema\/person\/b4b3d9970ea94f5914a615f70345353a"},"headline":"Unit Testing in .NET Core Using NUnit","datePublished":"2023-10-16T07:46:09+00:00","dateModified":"2023-10-16T09:05:43+00:00","mainEntityOfPage":{"@id":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit"},"wordCount":1304,"publisher":{"@id":"https:\/\/positiwise.com\/blog\/#organization"},"image":{"@id":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit#primaryimage"},"thumbnailUrl":"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/unit-testing-in-net-core-using-nunit.jpg","articleSection":[".NET Development"],"inLanguage":"en-US","copyrightYear":"2022","copyrightHolder":{"@id":"https:\/\/positiwise.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit","url":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit","name":"Unit Testing In .NET Core Using NUnit","isPartOf":{"@id":"https:\/\/positiwise.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit#primaryimage"},"image":{"@id":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit#primaryimage"},"thumbnailUrl":"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/unit-testing-in-net-core-using-nunit.jpg","datePublished":"2023-10-16T07:46:09+00:00","dateModified":"2023-10-16T09:05:43+00:00","description":"Learn to implement unit testing in .NET Core with NUnit. Covers test setup, assertions, and best practices for effective unit testing.","breadcrumb":{"@id":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit#primaryimage","url":"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/unit-testing-in-net-core-using-nunit.jpg","contentUrl":"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/10\/unit-testing-in-net-core-using-nunit.jpg","width":1021,"height":621,"caption":"Unit Testing in .NET Core Using NUnit"},{"@type":"BreadcrumbList","@id":"https:\/\/positiwise.com\/blog\/unit-testing-in-net-core-using-nunit#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/positiwise.com\/blog"},{"@type":"ListItem","position":2,"name":"Unit Testing in .NET Core Using NUnit"}]},{"@type":"WebSite","@id":"https:\/\/positiwise.com\/blog\/#website","url":"https:\/\/positiwise.com\/blog\/","name":"Positiwise","description":"Providing Full-cycle Software Development Services","publisher":{"@id":"https:\/\/positiwise.com\/blog\/#organization"},"alternateName":"Positiwise Software Pvt Ltd","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/positiwise.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/positiwise.com\/blog\/#organization","name":"Positiwise","alternateName":"Positiwise Software Pvt Ltd","url":"https:\/\/positiwise.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/positiwise.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/07\/logo.png","contentUrl":"https:\/\/positiwise.com\/blog\/wp-content\/uploads\/2023\/07\/logo.png","width":202,"height":29,"caption":"Positiwise"},"image":{"@id":"https:\/\/positiwise.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/positiwise\/","https:\/\/x.com\/positiwise","https:\/\/github.com\/positiwise","https:\/\/www.linkedin.com\/company\/positiwise"]},{"@type":"Person","@id":"https:\/\/positiwise.com\/blog\/#\/schema\/person\/b4b3d9970ea94f5914a615f70345353a","name":"Parag Mehta","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/072ea4a638415a77610a840228d51b8225ad88856ed34d69cbe1fcd638390535?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/072ea4a638415a77610a840228d51b8225ad88856ed34d69cbe1fcd638390535?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/072ea4a638415a77610a840228d51b8225ad88856ed34d69cbe1fcd638390535?s=96&r=g","caption":"Parag Mehta"},"description":"Parag Mehta, the CEO and Founder of Positiwise Software Pvt Ltd has extensive knowledge of the development niche. He is implementing custom strategies to craft highly-appealing and robust applications for its clients and supporting employees to grow and ace the tasks. He is a consistent learner and always provides the best-in-quality solutions, accelerating productivity.","sameAs":["https:\/\/www.linkedin.com\/in\/paragcmehta"],"url":"https:\/\/positiwise.com\/blog\/author\/parag-mehta"}]}},"_links":{"self":[{"href":"https:\/\/positiwise.com\/blog\/wp-json\/wp\/v2\/posts\/14008","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/positiwise.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/positiwise.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/positiwise.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/positiwise.com\/blog\/wp-json\/wp\/v2\/comments?post=14008"}],"version-history":[{"count":18,"href":"https:\/\/positiwise.com\/blog\/wp-json\/wp\/v2\/posts\/14008\/revisions"}],"predecessor-version":[{"id":14064,"href":"https:\/\/positiwise.com\/blog\/wp-json\/wp\/v2\/posts\/14008\/revisions\/14064"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/positiwise.com\/blog\/wp-json\/wp\/v2\/media\/14063"}],"wp:attachment":[{"href":"https:\/\/positiwise.com\/blog\/wp-json\/wp\/v2\/media?parent=14008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/positiwise.com\/blog\/wp-json\/wp\/v2\/categories?post=14008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/positiwise.com\/blog\/wp-json\/wp\/v2\/tags?post=14008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}