Code Monkey home page Code Monkey logo

dotnet-json-test's Introduction

C# JSON test demo

Simple C# integration test demo using NUnit framework

Tested setup

macOS Monterey
12.6.2
dotnet --info
.NET SDK:
 Version:   7.0.100
 Commit:    e12b7af219

Run NUnit tests

$ dotnet test

Example:

Janis-MBP:dotnet-json-test janijegoroff$ dotnet test
  Determining projects to restore...
  All projects are up-to-date for restore.
  dotnet-json-test -> /Users/janijegoroff/projects/dotnet-json-test/bin/Debug/net7.0/dotnet-json-test.dll
Test run for /Users/janijegoroff/projects/dotnet-json-test/bin/Debug/net7.0/dotnet-json-test.dll (.NETCoreApp,Version=v7.0)
Microsoft (R) Test Execution Command Line Tool Version 17.4.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:   121, Skipped:     0, Total:   121, Duration: 264 ms - dotnet-json-test.dll (net7.0)

Future improvement ideas

  • Static code analysis
  • JSON schema validation
  • Is Newtonsoft.Json the best library for handling JSON's?
  • Test results logging to XML file (.runsettings)
  • NUnit -> xUnit

Schemas

Albums:

{
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "type": "array",
  "default": [],
  "items": {
    "type": "object",
    "required": [
      "userId",
      "id",
      "title"
    ],
    "properties": {
      "userId": {
        "type": "integer"
      },
      "id": {
        "type": "integer"
      },
      "title": {
        "type": "string"
      }
    }
  }
}

Photos:

{
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "type": "array",
  "default": [],
  "items": {
    "type": "object",
    "required": [
      "albumId",
      "id",
      "title",
      "url",
      "thumbnailUrl"
    ],
    "properties": {
      "albumId": {
        "type": "integer"
      },
      "id": {
        "type": "integer"
      },
      "title": {
        "type": "string"
      },
      "url": {
        "type": "string"
      },
      "thumbnailUrl": {
        "type": "string"
      }
    }
  }
}

dotnet-json-test's People

Contributors

janijegoroff avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.