项目作者: DominikPawlocki

项目描述 :
Demonstrates usage of (original Ruby) PACT on .Net Core 2.3. Working broker and PACT uploading script.
高级语言: C#
项目地址: git://github.com/DominikPawlocki/pact-demo-netcore2.git
创建时间: 2019-01-16T21:34:50Z
项目社区:https://github.com/DominikPawlocki/pact-demo-netcore2

开源协议:GNU General Public License v3.0

下载


pact-demo-netcore2

UPDATE to .NET8 and PACT 5

Time passes, things changes.. I updated this old .Net Core to .Net 8 and Pact 5.0.0-beta2 Nuget. Many things changed in pact, however idea stays the same.

How to

1) Install, configure and run Pact broker on localhost (or anywhere) from the DockerHub (https://hub.docker.com/r/pactfoundation/pact-broker), using docker compose. There are 3 images there - Postgres db, ngnix and pact-broker itself. There is need to do some simple setup like Postgres password etc.
I have run it on localhost :
Alt text
Check if broker is working via browser :
Alt text
2) Run Consumer tests in VS
After a run a pact json file is created in folder : …\pact-demo-netcore2\consumers\Pact.Consumer.MVC\Pact.Consumer.MVC.PactTests\bin\pacts.
Remember the pact appends to the file (probably cause several concurrent xUnit processes (tests) to be running in parallel), so its worth to delete the file before a new run for new upload.
text:
3) Upload a pact file to Pact broker
The Powershell script from there doesn’t work anymore with new broker, so I just upload it manually by Postman… First, just CTRL-C all the content of pact json file from step 2 and do a base64 from it (ie via some online converter), then you can just paste it to the request body, increment ‘pacticipantVersionNumber’, branch, tags, etc and upload by HTTP Post (adjust authorization if you set it on step 1, I didn’t)
Upload
4) Run tests on Provider side
Alt text

#

#

#

——————————-OLD———————————————————-

A demo for Tricity .Net Group on 21/02/2019

You can upload your pact’s to broker (http://52.157.178.169/) by using upload.ps1 script.
(\consumers\Pact.Consumer.MVC\Pact.Consumer.MVC.PactTests.\upload.ps1 branch-name version)
Alt text

Build at least consumer solution first (Pact.Consumer.MVC) for create a Pact artifact file.

Feel free to contact me at pawlockiDmnk@gmail.com

Thx for attending !

CONSUMER:
Alt text

PROVIDER
Alt text