Skip to main content

Getting Started

Getting Started

There are three quick ways to get started easily but as Mockdoor is available as a docker image and in source code the number of ways a development team could deploy and use it is practically endless. This guide will cover using a docker container and raw docker commands, using Microsoft Tye a tool created by Microsoft to simplify running and deploying multiple dotnet and/or docker containers (this guide will only cover running them) and finally running Mockdoor using the existing solutions and a suitable IDE such as Visual Studio or Jet brains Rider.

Installation and Running Mockdoor

Prerequisites

 If running via source code

If you are using the source code and solution file method or Microsoft Tyes source code options you will first need to download the Mockdoor project from  https://github.com/mymockdoor/mockdoor (using git most likely), as well as downloading Mockdoor you need the following prerequisites

  • dotnet 6.0 SDK
  • A dotnet IDE/Editor such as Visual Studio, VS Code or Jet brains Rider
  • If using Tye you need to install it:
    • to install run this command (for full instructions see https://github.com/dotnet/tye)
    • dotnet tool install -g Microsoft.Tye --version "0.11.0-alpha.22111.1"
  • For anything other than testing Mockdoor it is recommended you use a SQL database as well which means having access to a MS SQL database with a valid connection string ready


If running via Docker
  • Docker installed locally (see https://www.docker.com/ for more details)
  • If using Tye you need to install it:
    • to install run this command (for full instructions see https://github.com/dotnet/tye)
    • dotnet tool install -g Microsoft.Tye --version "0.11.0-alpha.22111.1"
  • For anything other than testing Mockdoor it is recommended you use a SQL database as well which means having access to a MS SQL database with a valid connection string ready 


Getting started with Docker

The official Mockdoor docker hub page can be accessed at https://hub.docker.com/r/mockdoor/server, at time of writing the current latest version of Mockdoor is “0-50-04”, this can be downloaded from docker using the tag “0-50-04” or the default “latest” which will always be the latest version. 

To run Mockdoor you can run the following command

docker run -d -p 44304:80 --name mockdoor mockdoor/server

To run Mockdoor against a Microsoft SQL Server (replacing <> with your connection string)

docker run -d -p 44304:80 --name mockdoor -e DeploymentConfiguration__DatabaseConfig__Provider=1 -e DeploymentConfiguration__DatabaseConfig__ConnectionString="<<connection string>>" mockdoor/server

Once running navigate to http://localhost:44304

If you wish to play with the configuration you can reference the configuration guide for more details

Getting started with Microsoft Tye

Ensure you have Microsoft Tye installed.

to install run this command (for full instructions see https://github.com/dotnet/tye)

dotnet tool install -g Microsoft.Tye --version "0.11.0-alpha.22111.1"

Note: Avast and possibly other Anti virus software,have been known to block the install of Microsoft Tye. It is an official microsoft project and you can verify it for yourself if desired in the above link on github. If this happens and assuming you are comfortable doing so just set an exclusion for Tye and retry the install.

To start Mockdoor using tye

  • Open a command/terminal window
  • Navigate to “[your repo]/Mockdoor/Server
  • Use the command “tye run tye.yaml"

You can open Mockdoor at https://localhost:44304/

If you wish to play with the configuration you can reference the configuration guide for more details

Getting started with source code and solution file

When running from source it is recommended you use the “Mockdoor.Server” launch configuration from the “launchSettings.json” (located at  “[your repo]/Mockdoor/Server/Properties/laucnSettings.json”), this profile defaults to running Mockdoor on a custom base path. This is because Mockdoor is developed by default on custom paths to avoid introducing bugs in this setup (as its easy to introduce a bug on this setup that would not appear during testing on the default root path). 

Note: If you wish to change the path base you must change it in the “launchSettings.json” and in the “appsettings.development.json” file as well under the setting “DeploymentConfiguration__PathBase”, changing it to the value “/” or null will restore Mockdoor to the default hosting path.

  • Open the Mockdoor.sln file in your IDE of choice
  • Set Mockdoor.Server as your start up project
  • Start Mockdoor

Mockdoor should by launched by your IDE, if it is not you can open Mockdoor at https://localhost:44304/dev/mockdoor/ or if you opted to run from root using the above guide https://localhost:44304/

If you wish to play with the configuration you can reference the configuration guide for more details

First Steps

Launching Mockdoor for the first time

The first time you run Mockdoor you will be greeted with a update screen that shows pending updates to run on the database. If you specified a custom connection string and there is an issue a diagnostics screen may appear, be sure to enabled “Debug” mode if you do no see this diagnostics screen.


Valid connection startup update screen
Diagnostics page

You once you get the valid update screen (shown above) simply click apply migrations and you are done.

Your First Mocks

tbc

Automatic Mocking

tbc

Manual Mocking

tbc

Testing your Mocks

tbc

Troubleshooting

tbc