Search This Blog

Tuesday, 2 June 2020

Best way to compare json files online

Compare json files online.

Problem statement: How can I compare whether two JSON objects are equal using online tool/website, disregarding the order of lists?

first_sample.json document:

{
    "errors": [
        {"error": "invalid", "field": "email"},
        {"error": "required", "field": "name"}
    ],
    "success": false
}
        

second_sample.json document:
{
    "success": false,
    "errors": [
        {"error": "required", "field": "name"},
        {"error": "invalid", "field": "email"}
    ]
}
      
'first_sample.json' and 'second_sample.json' should compare equal, even though the order of the "errors" lists are different.



Solution

Step as below
  1. Sort both ('first_sample.json' and 'second_sample.json') file using Json sort online tool/website. ( json-sorter)
  2. Comapre json file using online compare tool/website. (diffnow)


Sort JSON screenshot as below



Compare JSON screenshot as below


Monday, 1 June 2020

Test Explorer (Visual Studio) shows 'Unknown Project'

Problem: Test Explorer (Visual Studio) shows '<Unknown project>'

 

Details: I created an class library project with Unit Tests project, and added a few unit tests. However, I have removed the failing test case from file but test explorer shows that Test Explore.


Solution

Steps as below

  1. Close Visual Sudio
  2. Go to project folder
  3. Find ".vs" folder. (Make sure your are also checking hidden item)
  4. Delete ".vs" folder.
  5. Good to go, Open visual studio, build and run project.



Wednesday, 15 April 2020

ASP.NET Core web API

Introduction to ASP.NET Core

ASP.NET Core :supports creating RESTful services, also known as web APIs, using C#. To handle requests, a web API uses controllers. Controllers in a web API are classes that derive from ControllerBase. This article shows how to use controllers for handling web API requests.


Saturday, 11 January 2020

Savvy SQL CHART (Book)

Savvy SQL CHART (Book)
Who is this book For?

if you can answer "YES" to all of these
  • Do you want to Learn "SQL"?
  • Do you like to tinker - Do you learn by doing. rather than just reading?
  • Do you want to brush up on SQL skill?
Shows you just what you need to know to stay competitive in a shifting marketplace.


Sample sql queries. Download Code

You will find correction, updates, all code listings and sample SQL script.

Please send me (harshalschaudhari@gmail.com) question, suggestions, corrections and gripes related to this book.



Tuesday, 12 November 2019

Wednesday, 30 October 2019

Cross-Platform Unit Testing and Code Coverage with Coverlet

How to check code coverage (using Unit Test cases)

Code coverage and report generation using coverlet (global tool).

Coverlet is a cross-platform code coverage framework for .NET, with support for the line, branch and method coverage. It works with .NET Framework on Windows and .NET Core on all supported platforms.


Steps as below
  • Step 1:Create the SetupGlobalTool.bat file in your project folder.
    Sample path: "C:\YourProjectFolder\BuildCodeCoverageReport\SetupGlobalTool.bat"
  • Step 2: Create the RunCodeCoverage.bat file in your project folder.
    Sample path: "C:\YourProjectFolder\BuildCodeCoverageReport\RunCodeCoverage.bat"
  • Step 3 Execute both file from command prompt respectively.
  • Note: File content provided in below seactions.

SetupGlobalTool.bat


@ECHO OFF

dotnet tool install --global coverlet.console  --ignore-failed-sources

dotnet tool install -g dotnet-reportgenerator-globaltool --ignore-failed-sources

pause

RunCodeCoverage.bat


@ECHO OFF

coverlet "..\TestProjectName\bin\Release\netcoreapp2.2\TestProjectName.dll" --target "dotnet" --targetargs "test ..\TestProjectName\TestProjectName.csproj -c Release --no-build --logger:trx" --threshold 0 --format "opencover" -f json -f lcov  --output "CodeCoverage"

reportgenerator "-reports:CodeCoverage.opencover.xml" "-targetdir:CodeCoverage\Reports"

pause

Note: Create the RunCodeCoverage.bat and SetupGlobalTool.bat file in BuildCodeCoverageReport folder.

Commands

  • Step 1: Install global tools.
    SetupGlobalTool.bat
  • To verify tools has been installed execute below command
    dotnet tool list -g
  • RunCodeCoverage.bat

Note: If command is not recognized, please check the environment variable PATH.

Sample Report

API Authentication

Reference · Identity & Access API Authentication Methods Four common ways a client proves who it is to a server, ord...

Recent Post