diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3729ff0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e645270 --- /dev/null +++ b/.gitignore @@ -0,0 +1,353 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ diff --git a/Auth.postman_collection.json b/Auth.postman_collection.json new file mode 100644 index 0000000..526e50d --- /dev/null +++ b/Auth.postman_collection.json @@ -0,0 +1,28 @@ +{ + "info": { + "_postman_id": "bac093ba-56a3-4d30-88fc-812c758eaa94", + "name": "Auth", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Delete Game By ID", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{baseurl}}/Game/28", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game", + "28" + ] + } + }, + "response": [] + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/Echo.postman_collection.json b/Echo.postman_collection.json new file mode 100644 index 0000000..dfdf53e --- /dev/null +++ b/Echo.postman_collection.json @@ -0,0 +1,368 @@ +{ + "info": { + "_postman_id": "7b8463af-1235-40b0-8be4-d4396ee2a56a", + "name": "Echo", + "description": "# Markdown Works Here Too!\n\n![alt tag](https://upload.wikimedia.org/wikipedia/commons/a/ae/Tic_Tac_Toe.gif \"a stamp\")\n\n \"Tic Tac Toe.gif\", by [SilverSpoon](https://commons.wikimedia.org/wiki/User:Silver_Spoon), is licensed under [GNU Free Documentation License](https://en.wikipedia.org/wiki/en:GNU_Free_Documentation_License)", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "echo", + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/x-www-form-urlencoded", + "type": "text" + } + ], + "body": { + "mode": "urlencoded", + "urlencoded": [ + { + "key": "RandomInt", + "value": "{{$randomInt}}", + "type": "text" + }, + { + "key": "Abbreviation", + "value": "{{$randomAbbreviation}}", + "type": "text" + }, + { + "key": "Business Image", + "value": "{{$randomBusinessImage}}", + "type": "text" + }, + { + "key": "Catch Phrase", + "value": "{{$randomCatchPhrase}}", + "type": "text" + }, + { + "key": "City", + "value": "{{$randomCity}}", + "type": "text" + }, + { + "key": "Bitcoin Address", + "value": "{{$randomBitcoin}}", + "type": "text" + }, + { + "key": "Color", + "value": "{{$randomColor}}", + "type": "text" + }, + { + "key": "Last Name", + "value": "{{$randomLastName}}", + "type": "text" + }, + { + "key": "Latitude", + "value": "{{$randomLatitude}}", + "type": "text" + }, + { + "key": "Date Past", + "value": "{{$randomDatePast}}", + "type": "text" + }, + { + "key": "Email", + "value": "{{$randomEmail}}", + "type": "text" + }, + { + "key": "Hex Color", + "value": "{{$randomHexColor}}", + "type": "text" + }, + { + "key": "Currency Code", + "value": "{{$randomCurrencyCode}}", + "type": "text" + }, + { + "key": "Lorem", + "value": "{{$randomLoremSlug}}", + "type": "text" + }, + { + "key": "Mime Type", + "value": "{{$randomMimeType}}", + "type": "text" + }, + { + "key": "Phone Ext", + "value": "{{$randomPhoneNumberExt}}", + "type": "text" + }, + { + "key": "Password", + "value": "{{$randomPassword}}", + "type": "text" + }, + { + "key": "Job Description", + "value": "{{$randomJobDescriptor}}", + "type": "text" + }, + { + "key": "Directory", + "value": "{{$randomDirectoryPath}}", + "type": "text" + }, + { + "key": "UUID", + "value": "{{$randomUUID}}", + "type": "text" + }, + { + "key": "Protocol", + "value": "{{$randomProtocol}}", + "type": "text" + }, + { + "key": "MAC Address", + "value": "{{$randomMACAddress}}", + "type": "text" + }, + { + "key": "Semver", + "value": "{{$randomSemver}}", + "type": "text" + }, + { + "key": "Street", + "value": "{{$randomStreetAddress}}", + "type": "text" + }, + { + "key": "IP v6", + "value": "{{$randomIPV6}}", + "type": "text" + } + ] + }, + "url": { + "raw": "{{baseurl}}/Echo", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Echo" + ] + }, + "description": "# Demonstrates Postman's random data fields.\n\n**Postman has a number pre-build random data generators:**\n1. Random Integers\n2. City\n3. Color\n4. Names\n5. and much more...\n\n*And even random image links!*\n\n![alt text](http://lorempixel.com/320/240/animals \"Random Business Image\")" + }, + "response": [ + { + "name": "echo", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/x-www-form-urlencoded", + "type": "text" + } + ], + "body": { + "mode": "urlencoded", + "urlencoded": [ + { + "key": "RandomInt", + "value": "{{$randomInt}}", + "type": "text" + }, + { + "key": "Abbreviation", + "value": "{{$randomAbbreviation}}", + "type": "text" + }, + { + "key": "Business Image", + "value": "{{$randomBusinessImage}}", + "type": "text" + }, + { + "key": "Catch Phrase", + "value": "{{$randomCatchPhrase}}", + "type": "text" + }, + { + "key": "City", + "value": "{{$randomCity}}", + "type": "text" + }, + { + "key": "Bitcoin Address", + "value": "{{$randomBitcoin}}", + "type": "text" + }, + { + "key": "Color", + "value": "{{$randomColor}}", + "type": "text" + }, + { + "key": "Last Name", + "value": "{{$randomLastName}}", + "type": "text" + }, + { + "key": "Latitude", + "value": "{{$randomLatitude}}", + "type": "text" + }, + { + "key": "Date Past", + "value": "{{$randomDatePast}}", + "type": "text" + }, + { + "key": "Email", + "value": "{{$randomEmail}}", + "type": "text" + }, + { + "key": "Hex Color", + "value": "{{$randomHexColor}}", + "type": "text" + }, + { + "key": "Currency Code", + "value": "{{$randomCurrencyCode}}", + "type": "text" + }, + { + "key": "Lorem", + "value": "{{$randomLoremSlug}}", + "type": "text" + }, + { + "key": "Mime Type", + "value": "{{$randomMimeType}}", + "type": "text" + }, + { + "key": "Phone Ext", + "value": "{{$randomPhoneNumberExt}}", + "type": "text" + }, + { + "key": "Password", + "value": "{{$randomPassword}}", + "type": "text" + }, + { + "key": "Job Description", + "value": "{{$randomJobDescriptor}}", + "type": "text" + }, + { + "key": "Directory", + "value": "{{$randomDirectoryPath}}", + "type": "text" + }, + { + "key": "UUID", + "value": "{{$randomUUID}}", + "type": "text" + }, + { + "key": "Protocol", + "value": "{{$randomProtocol}}", + "type": "text" + }, + { + "key": "MAC Address", + "value": "{{$randomMACAddress}}", + "type": "text" + }, + { + "key": "Semver", + "value": "{{$randomSemver}}", + "type": "text" + }, + { + "key": "Street", + "value": "{{$randomStreetAddress}}", + "type": "text" + }, + { + "key": "IP v6", + "value": "{{$randomIPV6}}", + "type": "text" + } + ] + }, + "url": { + "raw": "{{baseurl}}/Echo", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Echo" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Tue, 15 Oct 2019 21:45:58 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"RandomInt\": \"401\",\n \"Abbreviation\": \"COM\",\n \"Business Image\": \"http://lorempixel.com/640/480/business\",\n \"Catch Phrase\": \"Synergistic modular flexibility\",\n \"City\": \"North Chyna\",\n \"Bitcoin Address\": \"1U05W8IG6ZX78ULL20BCF64M9QSA5QA\",\n \"Color\": \"violet\",\n \"Last Name\": \"Bradtke\",\n \"Latitude\": \"10.4845\",\n \"Date Past\": \"Mon Jul 01 2019 07:17:50 GMT-0400 (Eastern Daylight Time)\",\n \"Email\": \"Keven_Hoppe@hotmail.com\",\n \"Hex Color\": \"#10603f\",\n \"Currency Code\": \"NIO\",\n \"Lorem\": \"ea-vitae-repellat\",\n \"Mime Type\": \"application/vnd.ntt-local.sip-ta_tcp_stream\",\n \"Phone Ext\": \"97-970-970-1249\",\n \"Password\": \"Y6HQAba68iuQdut\",\n \"Job Description\": \"Chief\",\n \"Directory\": \"/mnt\",\n \"UUID\": \"bfc5b542-c9e4-49fd-9d62-d69f3504a9fb\",\n \"Protocol\": \"http\",\n \"MAC Address\": \"5d:ec:dc:4c:26:65\",\n \"Semver\": \"6.5.9\",\n \"Street\": \"3387 Hagenes Trafficway\",\n \"IP v6\": \"5346:36f1:066f:9e03:a5ac:ee6d:c73e:d104\"\n}" + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "cbca3298-c472-4adf-94ea-9f3f93ca56ed", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "ae244563-9b83-4ab6-ac72-1f68959c6d7d", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/POSTMAN Delivers.pdf b/POSTMAN Delivers.pdf new file mode 100644 index 0000000..c610aa4 Binary files /dev/null and b/POSTMAN Delivers.pdf differ diff --git a/Postman Delivers.postman_collection.json b/Postman Delivers.postman_collection.json deleted file mode 100644 index d78e7f5..0000000 --- a/Postman Delivers.postman_collection.json +++ /dev/null @@ -1,1183 +0,0 @@ -{ - "info": { - "_postman_id": "8f3765a5-93fd-46e7-a42b-4547f4d66b85", - "name": "Postman Delivers", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "Happy Path", - "item": [ - { - "name": "Generate New Game", - "event": [ - { - "listen": "test", - "script": { - "id": "eb04b227-5d6b-4048-bf61-a286119f1b6c", - "exec": [ - "", - "const responseJson = pm.response.json();", - "", - "pm.test(\"Status code is 201\", function () {", - " pm.response.to.have.status(201);", - "});", - "", - "pm.environment.set(\"happy_path_game_id\", responseJson.id);", - "pm.environment.set(\"happy_path_playerx_id\", responseJson.playerXID);", - "pm.environment.set(\"happy_path_playero_id\", responseJson.playerOID);", - "pm.environment.set(\"happy_path_playerx_name\", responseJson.playerXName);", - "pm.environment.set(\"happy_path_playero_name\", responseJson.playerOName);", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "[\"Bob\", \"Janel\"]", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Game", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Game" - ] - } - }, - "response": [ - { - "name": "Generate New Game", - "originalRequest": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "[\"Bob\", \"Janel\"]", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Game", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Game" - ] - } - }, - "status": "Created", - "code": 201, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Date", - "value": "Sun, 06 Oct 2019 17:37:03 GMT" - }, - { - "key": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "key": "Server", - "value": "Kestrel" - }, - { - "key": "Transfer-Encoding", - "value": "chunked" - }, - { - "key": "Location", - "value": "https://localhost:5001/api/Game/30" - } - ], - "cookie": [], - "body": "{\n \"id\": 30,\n \"board\": {\n \"squares\": [\n null,\n null,\n null,\n null,\n null,\n null,\n null,\n null,\n null\n ],\n \"winner\": null\n },\n \"moves\": [],\n \"playerXName\": \"Bob\",\n \"playerXID\": \"nyIC8fduHXIqywtE\",\n \"playerOName\": \"Janel\",\n \"playerOID\": \"8HeuRqMruw7OGDHyTPkYLhxmZp\",\n \"winner\": 0,\n \"gameState\": 1\n}" - } - ] - }, - { - "name": "X Move To [1]", - "event": [ - { - "listen": "test", - "script": { - "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "const responseJson = pm.response.json();", - "", - "pm.test(\"Move is valid\", () => {", - " pm.expect(responseJson.isValid).to.be.true;", - "});", - "", - "pm.test(\"Game is in progress\", () => {", - " pm.expect(responseJson.gameIsOver).to.be.false; ", - "});", - "", - "pm.test(\"Move is valid so reason is null\", () => {", - " pm.expect(responseJson.reason).to.be.null; ", - "});", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Move", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Move" - ] - } - }, - "response": [ - { - "name": "X Move To [1]", - "originalRequest": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Move", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Move" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Date", - "value": "Sun, 06 Oct 2019 18:02:35 GMT" - }, - { - "key": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "key": "Server", - "value": "Kestrel" - }, - { - "key": "Transfer-Encoding", - "value": "chunked" - } - ], - "cookie": [], - "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" - } - ] - }, - { - "name": "Get Game By ID", - "event": [ - { - "listen": "test", - "script": { - "id": "97ad4eef-99b5-4a4d-896e-7e63d3bd14ab", - "exec": [ - "pm.test(\"Status code is 200\", () => {", - " pm.response.to.have.status(200);", - "});", - "", - "const responseJson = pm.response.json();", - "", - "const game_id = pm.environment.get(\"happy_path_game_id\");", - "", - "pm.test(`The game id is ${game_id}`, () => {", - " pm.expect(game_id).to.eq(responseJson.id);", - "});", - "", - "pm.test(\"Square 1 is null\", () => {", - " pm.expect(responseJson.board.squares[0]).to.be.null; ", - "});", - "", - "pm.test(\"Square 2 is an X\", () => {", - " pm.expect(\"X\").to.eq(responseJson.board.squares[1]); ", - "});", - "", - "for(let i = 2; i < 9; i++) {", - " pm.test(`Square ${i} is null`, () => {", - " pm.expect(responseJson.board.squares[i]).to.be.null; ", - " });", - "}", - "", - "pm.test(\"Board winner is null\", () => {", - " pm.expect(responseJson.board.winner).to.be.null; ", - "});", - "", - "pm.test(\"Game has only one move\", () => {", - " pm.expect(1).to.eq(responseJson.moves.length); ", - "});", - "", - "pm.test(`Move game id is ${game_id}`, () => {", - " pm.expect(game_id).to.eq(responseJson.moves[0].gameID);", - "});", - "", - "pm.test(\"Move used square 1\", () => {", - " pm.expect(1).to.eq(responseJson.moves[0].square);", - "});", - "", - "pm.test(\"Player was X\", () => {", - " pm.expect(1).to.eq(responseJson.moves[0].player);", - "});", - "", - "const playerxname = pm.environment.get(\"happy_path_playerx_name\");", - "pm.test(`Player X Name is ${playerxname}`, () => {", - " pm.expect(playerxname).to.eq(responseJson.playerXName); ", - "});", - "", - "const playeroname = pm.environment.get(\"happy_path_playero_name\");", - "pm.test(`Player O Name is ${playeroname}`, () => {", - " pm.expect(playeroname).to.eq(responseJson.playerOName); ", - "});", - "", - "const playerxid = pm.environment.get(\"happy_path_playerx_id\");", - "pm.test(`Player X id is ${playerxid}`, () => {", - " pm.expect(playerxid).to.eq(responseJson.playerXID);", - "});", - "", - "const playeroid = pm.environment.get(\"happy_path_playero_id\");", - "pm.test(`Player O id is ${playeroid}`, () => {", - " pm.expect(playeroid).to.eq(responseJson.playerOID);", - "});", - "", - "pm.test(\"Game winner is zero (None)\", () => {", - " pm.expect(0).to.eq(responseJson.winner); ", - "});", - "", - "pm.test(\"Game state is in progress\", () => {", - " pm.expect(1).to.eq(responseJson.gameState) ;", - "});", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Game", - "{{happy_path_game_id}}" - ] - } - }, - "response": [ - { - "name": "Game with one Move", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Game", - "{{happy_path_game_id}}" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Date", - "value": "Sun, 06 Oct 2019 18:28:40 GMT" - }, - { - "key": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "key": "Server", - "value": "Kestrel" - }, - { - "key": "Transfer-Encoding", - "value": "chunked" - } - ], - "cookie": [], - "body": "{\n \"id\": 46,\n \"board\": {\n \"squares\": [\n null,\n \"X\",\n null,\n null,\n null,\n null,\n null,\n null,\n null\n ],\n \"winner\": null\n },\n \"moves\": [\n {\n \"gameID\": 46,\n \"square\": 1,\n \"gameboardBefore\": \"[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"timestamp\": 1570386515,\n \"player\": 1\n }\n ],\n \"playerXName\": \"Bob\",\n \"playerXID\": \"SibDaxfPfIYRqmHF\",\n \"playerOName\": \"Janel\",\n \"playerOID\": \"ZRXH9TLbcc0ithGb\",\n \"winner\": 0,\n \"gameState\": 1\n}" - } - ] - }, - { - "name": "O Move To [3]", - "event": [ - { - "listen": "test", - "script": { - "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "const responseJson = pm.response.json();", - "", - "pm.test(\"Move is valid\", () => {", - " pm.expect(responseJson.isValid).to.be.true;", - "});", - "", - "pm.test(\"Game is in progress\", () => {", - " pm.expect(responseJson.gameIsOver).to.be.false; ", - "});", - "", - "pm.test(\"Move is valid so reason is null\", () => {", - " pm.expect(responseJson.reason).to.be.null; ", - "});", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"xoro\" : \"O\",\n\t\"whichSquare\" : 3,\n\t\"playerID\" : \"{{happy_path_playero_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Move", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Move" - ] - } - }, - "response": [ - { - "name": "O moves to square occupied by X", - "originalRequest": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Move", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Move" - ] - } - }, - "status": "Bad Request", - "code": 400, - "_postman_previewlanguage": "plain", - "header": [ - { - "key": "Date", - "value": "Sun, 06 Oct 2019 19:00:43 GMT" - }, - { - "key": "Content-Type", - "value": "text/plain; charset=utf-8" - }, - { - "key": "Server", - "value": "Kestrel" - }, - { - "key": "Transfer-Encoding", - "value": "chunked" - } - ], - "cookie": [], - "body": "Illegal Move. Reason: The square is already occupied by X. Turn aborted, try again., Game Board:\r\n[ ] [ X ] [ ]\r\n\r\n[ ] [ ] [ ]\r\n\r\n[ ] [ ] [ ]" - }, - { - "name": "X Move To [1]", - "originalRequest": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Move", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Move" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Date", - "value": "Sun, 06 Oct 2019 18:02:35 GMT" - }, - { - "key": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "key": "Server", - "value": "Kestrel" - }, - { - "key": "Transfer-Encoding", - "value": "chunked" - } - ], - "cookie": [], - "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" - } - ] - }, - { - "name": "X Move To [0]", - "event": [ - { - "listen": "test", - "script": { - "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "const responseJson = pm.response.json();", - "", - "pm.test(\"Move is valid\", () => {", - " pm.expect(responseJson.isValid).to.be.true;", - "});", - "", - "pm.test(\"Game is in progress\", () => {", - " pm.expect(responseJson.gameIsOver).to.be.false; ", - "});", - "", - "pm.test(\"Move is valid so reason is null\", () => {", - " pm.expect(responseJson.reason).to.be.null; ", - "});", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 0,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Move", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Move" - ] - } - }, - "response": [ - { - "name": "X Move To [1]", - "originalRequest": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Move", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Move" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Date", - "value": "Sun, 06 Oct 2019 18:02:35 GMT" - }, - { - "key": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "key": "Server", - "value": "Kestrel" - }, - { - "key": "Transfer-Encoding", - "value": "chunked" - } - ], - "cookie": [], - "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" - } - ] - }, - { - "name": "O Move To [7]", - "event": [ - { - "listen": "test", - "script": { - "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "const responseJson = pm.response.json();", - "", - "pm.test(\"Move is valid\", () => {", - " pm.expect(responseJson.isValid).to.be.true;", - "});", - "", - "pm.test(\"Game is in progress\", () => {", - " pm.expect(responseJson.gameIsOver).to.be.false; ", - "});", - "", - "pm.test(\"Move is valid so reason is null\", () => {", - " pm.expect(responseJson.reason).to.be.null; ", - "});", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"xoro\" : \"O\",\n\t\"whichSquare\" : 7,\n\t\"playerID\" : \"{{happy_path_playero_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Move", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Move" - ] - } - }, - "response": [ - { - "name": "X Move To [1]", - "originalRequest": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Move", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Move" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Date", - "value": "Sun, 06 Oct 2019 18:02:35 GMT" - }, - { - "key": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "key": "Server", - "value": "Kestrel" - }, - { - "key": "Transfer-Encoding", - "value": "chunked" - } - ], - "cookie": [], - "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" - } - ] - }, - { - "name": "X Move To [2]", - "event": [ - { - "listen": "test", - "script": { - "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "const responseJson = pm.response.json();", - "", - "pm.test(\"Move is valid\", () => {", - " pm.expect(responseJson.isValid).to.be.true;", - "});", - "", - "pm.test(\"Game is in progress\", () => {", - " pm.expect(responseJson.gameIsOver).to.be.true; ", - "});", - "", - "pm.test(\"Move is valid so reason is null\", () => {", - " pm.expect(responseJson.reason).to.eq(\"Game is Over. Congratulations to X\"); ", - "});", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 2,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Move", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Move" - ] - } - }, - "response": [ - { - "name": "X Move To [1]", - "originalRequest": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Move", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Move" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Date", - "value": "Sun, 06 Oct 2019 18:02:35 GMT" - }, - { - "key": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "key": "Server", - "value": "Kestrel" - }, - { - "key": "Transfer-Encoding", - "value": "chunked" - } - ], - "cookie": [], - "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" - } - ] - }, - { - "name": "Get End Game", - "event": [ - { - "listen": "test", - "script": { - "id": "97ad4eef-99b5-4a4d-896e-7e63d3bd14ab", - "exec": [ - "", - "const responseJson = pm.response.json();", - "", - "let moves = responseJson.moves;", - "", - "let game = [];", - "", - "let previous_move = { \"one\": \" \", \"two\": \" \", \"three\": \" \", \"four\": \" \", \"five\": \" \", \"six\": \" \", \"seven\": \" \", \"eight\": \" \", \"nine\": \" \"};", - "", - "for(let i = 0; i < moves.length; i++){", - " ", - " let player = moves[i].player === 1 ? 'X' : 'O';", - " ", - " let this_move = {", - " \"one\": moves[i].square === 0 ? player : previous_move.one,", - " \"two\": moves[i].square === 1 ? player : previous_move.two,", - " \"three\": moves[i].square === 2 ? player : previous_move.three,", - " \"four\": moves[i].square === 3 ? player : previous_move.four,", - " \"five\": moves[i].square === 4 ? player : previous_move.five,", - " \"six\": moves[i].square === 5 ? player : previous_move.six,", - " \"seven\": moves[i].square === 6 ? player : previous_move.seven,", - " \"eight\": moves[i].square === 7 ? player : previous_move.eight,", - " \"nine\": moves[i].square === 8 ? player : previous_move.nine", - " };", - " previous_move = this_move;", - " game.push(this_move);", - "}", - "", - "let tmplt = `", - " ", - " {{#each response}}", - " ", - " ", - " ", - " ", - "
{{one}}{{two}}{{three}}
{{four}}{{five}}{{six}}
{{seven}}{{eight}}{{nine}}
", - "
", - "{{/each}}`;", - " ", - "pm.visualizer.set(tmplt, {response: game});", - "", - "pm.test(\"Status code is 200\", () => {", - " pm.response.to.have.status(200);", - "});", - "", - "const game_id = pm.environment.get(\"happy_path_game_id\");", - "", - "pm.test(`The game id is ${game_id}`, () => {", - " pm.expect(game_id).to.eq(responseJson.id);", - "});", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Game", - "{{happy_path_game_id}}" - ] - } - }, - "response": [ - { - "name": "Game with one Move", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Game", - "{{happy_path_game_id}}" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Date", - "value": "Sun, 06 Oct 2019 18:28:40 GMT" - }, - { - "key": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "key": "Server", - "value": "Kestrel" - }, - { - "key": "Transfer-Encoding", - "value": "chunked" - } - ], - "cookie": [], - "body": "{\n \"id\": 46,\n \"board\": {\n \"squares\": [\n null,\n \"X\",\n null,\n null,\n null,\n null,\n null,\n null,\n null\n ],\n \"winner\": null\n },\n \"moves\": [\n {\n \"gameID\": 46,\n \"square\": 1,\n \"gameboardBefore\": \"[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"timestamp\": 1570386515,\n \"player\": 1\n }\n ],\n \"playerXName\": \"Bob\",\n \"playerXID\": \"SibDaxfPfIYRqmHF\",\n \"playerOName\": \"Janel\",\n \"playerOID\": \"ZRXH9TLbcc0ithGb\",\n \"winner\": 0,\n \"gameState\": 1\n}" - } - ] - } - ], - "description": "This folder contains requests that play an entire Tic Tac Toe game start to finish without errors.", - "protocolProfileBehavior": {} - }, - { - "name": "Get All Games", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{baseurl}}/Game", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Game" - ] - } - }, - "response": [] - }, - { - "name": "Get Game By ID", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{baseurl}}/Game/25", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Game", - "25" - ] - } - }, - "response": [] - }, - { - "name": "Generate New Game", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "[\"Bob\", \"Janel\"]", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Game", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Game" - ] - } - }, - "response": [] - }, - { - "name": "X Move To [1]", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 11,\n\t\"playerID\" : \"20OvFKGSSWvNQEXpLTdbSr2Kb\",\n\t\"gameId\" : 26\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseurl}}/Move", - "host": [ - "{{baseurl}}" - ], - "path": [ - "Move" - ] - } - }, - "response": [] - } - ], - "protocolProfileBehavior": {} -} \ No newline at end of file diff --git a/Postman Delivers.postman_globals.json b/Postman Delivers.postman_globals.json index bd6d5c3..cb373c9 100644 --- a/Postman Delivers.postman_globals.json +++ b/Postman Delivers.postman_globals.json @@ -5,10 +5,20 @@ "key": "game_visualizer", "value": "(function () {\n\n build_moves = function (moves) {\n\n let game = [];\n\n let previous_move = { \"one\": \" \", \"two\": \" \", \"three\": \" \", \"four\": \" \", \"five\": \" \", \"six\": \" \", \"seven\": \" \", \"eight\": \" \", \"nine\": \" \" };\n\n for (let i = 0; i < moves.length; i++) {\n\n let player = moves[i].player === 1 ? 'X' : 'O';\n\n let this_move = {\n \"one\": moves[i].square === 0 ? player : previous_move.one,\n \"two\": moves[i].square === 1 ? player : previous_move.two,\n \"three\": moves[i].square === 2 ? player : previous_move.three,\n \"four\": moves[i].square === 3 ? player : previous_move.four,\n \"five\": moves[i].square === 4 ? player : previous_move.five,\n \"six\": moves[i].square === 5 ? player : previous_move.six,\n \"seven\": moves[i].square === 6 ? player : previous_move.seven,\n \"eight\": moves[i].square === 7 ? player : previous_move.eight,\n \"nine\": moves[i].square === 8 ? player : previous_move.nine\n };\n previous_move = this_move;\n game.push(this_move);\n }\n\n return game;\n };\n\n let tmplt = `\n \n {{#each response}}\n \n \n \n \n
{{one}}{{two}}{{three}}
{{four}}{{five}}{{six}}
{{seven}}{{eight}}{{nine}}
\n
\n {{/each}}`;\n\n return { BuildMoves: build_moves, Template: tmplt };\n\n})();", "enabled": true + }, + { + "key": "azure_ad_client_id", + "value": "", + "enabled": true + }, + { + "key": "azure_ad_auth_url", + "value": "", + "enabled": true } ], "name": "Postman Delivers Globals", "_postman_variable_scope": "globals", - "_postman_exported_at": "2019-10-09T00:13:36.571Z", - "_postman_exported_using": "Postman/7.8.0" + "_postman_exported_at": "2019-12-28T19:23:38.242Z", + "_postman_exported_using": "Postman/7.14.0" } \ No newline at end of file diff --git a/PostmanDelivers.API/.config/dotnet-tools.json b/PostmanDelivers.API/.config/dotnet-tools.json new file mode 100644 index 0000000..6b2cf2d --- /dev/null +++ b/PostmanDelivers.API/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "3.1.0", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file diff --git a/PostmanDelivers.API/Controllers/EchoController.cs b/PostmanDelivers.API/Controllers/EchoController.cs index 96e0906..99fcc01 100644 --- a/PostmanDelivers.API/Controllers/EchoController.cs +++ b/PostmanDelivers.API/Controllers/EchoController.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using System; using System.Collections.Generic; namespace PostmanDelivers.API.Controllers @@ -7,10 +10,17 @@ namespace PostmanDelivers.API.Controllers [ApiController] public class EchoController : ControllerBase { + IConfiguration _config; + public EchoController(IConfiguration config) + { + _config = config; + } + [HttpPost] [Consumes("application/x-www-form-urlencoded")] public ActionResult Post([FromForm] Dictionary stringsToEcho) { + stringsToEcho.Add("env", _config.GetValue("APP_ENVIRONMENT") ?? "No environment configured"); return Ok(stringsToEcho); } } diff --git a/PostmanDelivers.API/Controllers/GameController.cs b/PostmanDelivers.API/Controllers/GameController.cs index 2fca9e5..f43ea86 100644 --- a/PostmanDelivers.API/Controllers/GameController.cs +++ b/PostmanDelivers.API/Controllers/GameController.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using System.Collections.Generic; using TikTakToe.Engine; @@ -16,7 +17,7 @@ public GameController(IConfiguration config) } [HttpPost] - public ActionResult Post(string[] playerNames) + public ActionResult Post([FromBody]string[] playerNames) { try { @@ -27,8 +28,26 @@ public ActionResult Post(string[] playerNames) } catch (System.Exception ex) { - throw; - } + return StatusCode(500, ex.Message); + } + } + + [HttpDelete] + [Authorize] + [Route("{id:int}")] + public ActionResult Delete(int id) + { + try + { + Game g = new Game(); + string cnxn = _config.GetValue("ConnectionStr"); + g.Delete(id, cnxn); + return Ok(); + } + catch (System.Exception ex) + { + return StatusCode(500, ex.Message); + } } [HttpGet] diff --git a/PostmanDelivers.API/Controllers/ValuesController.cs b/PostmanDelivers.API/Controllers/ValuesController.cs index 87b892d..5b75211 100644 --- a/PostmanDelivers.API/Controllers/ValuesController.cs +++ b/PostmanDelivers.API/Controllers/ValuesController.cs @@ -1,8 +1,5 @@ -using System; +using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; namespace PostmanDelivers.API.Controllers { diff --git a/PostmanDelivers.API/Dockerfile b/PostmanDelivers.API/Dockerfile new file mode 100644 index 0000000..6bcd821 --- /dev/null +++ b/PostmanDelivers.API/Dockerfile @@ -0,0 +1,23 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build +WORKDIR /src +COPY ["PostmanDelivers.API/PostmanDelivers.API.csproj", "PostmanDelivers.API/"] +COPY ["TikTakToe.Engine/TikTakToe.Engine.csproj", "TikTakToe.Engine/"] +RUN dotnet restore "PostmanDelivers.API/PostmanDelivers.API.csproj" +COPY . . +WORKDIR "/src/PostmanDelivers.API" +RUN dotnet build "PostmanDelivers.API.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "PostmanDelivers.API.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "PostmanDelivers.API.dll"] \ No newline at end of file diff --git a/PostmanDelivers.API/PostmanDelivers.API.csproj b/PostmanDelivers.API/PostmanDelivers.API.csproj index 259d051..a753636 100644 --- a/PostmanDelivers.API/PostmanDelivers.API.csproj +++ b/PostmanDelivers.API/PostmanDelivers.API.csproj @@ -3,11 +3,15 @@ netcoreapp2.2 InProcess + 44bf9484-c87a-4a81-a5dd-b74cfa9ba5b7 + Linux + + @@ -15,4 +19,10 @@ + + + Always + + + diff --git a/PostmanDelivers.API/PostmanDelivers.API.csproj.user b/PostmanDelivers.API/PostmanDelivers.API.csproj.user deleted file mode 100644 index 19a78af..0000000 --- a/PostmanDelivers.API/PostmanDelivers.API.csproj.user +++ /dev/null @@ -1,17 +0,0 @@ - - - - ApiControllerEmptyScaffolder - root/Controller - 600 - True - False - True - - False - PostmanDelivers.API - - - ProjectDebugger - - \ No newline at end of file diff --git a/PostmanDelivers.API/Program.cs b/PostmanDelivers.API/Program.cs index 5552aa9..6645c7e 100644 --- a/PostmanDelivers.API/Program.cs +++ b/PostmanDelivers.API/Program.cs @@ -1,12 +1,5 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; namespace PostmanDelivers.API { diff --git a/PostmanDelivers.API/Properties/launchSettings.json b/PostmanDelivers.API/Properties/launchSettings.json index 81d77bf..c06aa8f 100644 --- a/PostmanDelivers.API/Properties/launchSettings.json +++ b/PostmanDelivers.API/Properties/launchSettings.json @@ -21,9 +21,16 @@ "commandName": "Project", "launchUrl": "api/values", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "APP_ENVIRONMENT": "Debug" }, - "applicationUrl": "https://localhost:6001;http://localhost:6000" + "applicationUrl": "https://localhost:5001;http://localhost:5000" + }, + "Docker": { + "commandName": "Docker", + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/api/values", + "publishAllPorts": true, + "useSSL": true } } } \ No newline at end of file diff --git a/PostmanDelivers.API/Startup.cs b/PostmanDelivers.API/Startup.cs index b3ec4da..36e73a0 100644 --- a/PostmanDelivers.API/Startup.cs +++ b/PostmanDelivers.API/Startup.cs @@ -1,15 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.AzureAD.UI; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; namespace PostmanDelivers.API { @@ -25,6 +20,9 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { + services.AddAuthentication(AzureADDefaults.BearerAuthenticationScheme) + .AddAzureADBearer(options => Configuration.Bind("AzureAd", options)); + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); } @@ -42,6 +40,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) } app.UseHttpsRedirection(); + app.UseAuthentication(); app.UseMvc(); } } diff --git a/PostmanDelivers.API/appsettings.json b/PostmanDelivers.API/appsettings.json index 57faec2..39d8adb 100644 --- a/PostmanDelivers.API/appsettings.json +++ b/PostmanDelivers.API/appsettings.json @@ -5,5 +5,5 @@ } }, "AllowedHosts": "*", - "ConnectionStr": "Data Source=C:\\ProgramData\\postmandelivers\\GameDB.sqlite3;Version=3;" + "ConnectionStr": "Data Source=data/GameDB.sqlite3;Version=3;" } diff --git a/PostmanDelivers.API/data/GameDB.sqlite3 b/PostmanDelivers.API/data/GameDB.sqlite3 new file mode 100644 index 0000000..11f2f4f Binary files /dev/null and b/PostmanDelivers.API/data/GameDB.sqlite3 differ diff --git a/PostmanDelivers.sln b/PostmanDelivers.sln index fc5da7e..8a8ce17 100644 --- a/PostmanDelivers.sln +++ b/PostmanDelivers.sln @@ -10,13 +10,20 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C2E67A42-FE57-4B29-831D-376F569A87E8}" ProjectSection(SolutionItems) = preProject .gitignore = .gitignore + Auth.postman_collection.json = Auth.postman_collection.json CustomScript.js = CustomScript.js + data.json = data.json Database.sql = Database.sql + Echo.postman_collection.json = Echo.postman_collection.json + newman_script.txt = newman_script.txt Postman Delivers.postman_globals.json = Postman Delivers.postman_globals.json - PostmandDelivers HTTP.postman_environment.json = PostmandDelivers HTTP.postman_environment.json - PostmandDelivers HTTPS.postman_environment.json = PostmandDelivers HTTPS.postman_environment.json + PostmandDelivers Azure.postman_environment.json = PostmandDelivers Azure.postman_environment.json + PostmandDelivers Debug VS.postman_environment.json = PostmandDelivers Debug VS.postman_environment.json + PostmandDelivers Local.postman_environment.json = PostmandDelivers Local.postman_environment.json + PostmandDelivers Prod.postman_environment.json = PostmandDelivers Prod.postman_environment.json Script Order.postman_collection.json = Script Order.postman_collection.json - ScriptOrderEnv.postman_environment.json = ScriptOrderEnv.postman_environment.json + X Wins Manual.postman_collection.json = X Wins Manual.postman_collection.json + X Wins With Tests.postman_collection.json = X Wins With Tests.postman_collection.json EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PostmanDelivers.API", "PostmanDelivers.API\PostmanDelivers.API.csproj", "{6EFA36C6-1508-4116-8012-6448D0168FDA}" diff --git a/PostmandDelivers Azure.postman_environment.json b/PostmandDelivers Azure.postman_environment.json new file mode 100644 index 0000000..ff7588e --- /dev/null +++ b/PostmandDelivers Azure.postman_environment.json @@ -0,0 +1,39 @@ +{ + "id": "35082160-7464-4b12-a488-3e9b33cd7e1e", + "name": "PostmandDelivers Azure", + "values": [ + { + "key": "baseurl", + "value": "https://postmandelivers.azurewebsites.net/api", + "enabled": true + }, + { + "key": "happy_path_game_id", + "value": "", + "enabled": true + }, + { + "key": "happy_path_playero_id", + "value": "", + "enabled": true + }, + { + "key": "happy_path_playero_name", + "value": "", + "enabled": true + }, + { + "key": "happy_path_playerx_id", + "value": "", + "enabled": true + }, + { + "key": "happy_path_playerx_name", + "value": "", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2019-12-28T19:22:47.598Z", + "_postman_exported_using": "Postman/7.14.0" +} \ No newline at end of file diff --git a/PostmandDelivers Debug VS.postman_environment.json b/PostmandDelivers Debug VS.postman_environment.json new file mode 100644 index 0000000..0ca01d8 --- /dev/null +++ b/PostmandDelivers Debug VS.postman_environment.json @@ -0,0 +1,39 @@ +{ + "id": "c17f35a3-c932-4d37-b7eb-3cf2724e2ce9", + "name": "PostmandDelivers Debug VS", + "values": [ + { + "key": "baseurl", + "value": "", + "enabled": true + }, + { + "key": "happy_path_game_id", + "value": "", + "enabled": true + }, + { + "key": "happy_path_playero_id", + "value": "", + "enabled": true + }, + { + "key": "happy_path_playero_name", + "value": "", + "enabled": true + }, + { + "key": "happy_path_playerx_id", + "value": "", + "enabled": true + }, + { + "key": "happy_path_playerx_name", + "value": "", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2019-12-28T19:22:53.638Z", + "_postman_exported_using": "Postman/7.14.0" +} \ No newline at end of file diff --git a/PostmandDelivers HTTPS.postman_environment.json b/PostmandDelivers HTTPS.postman_environment.json index ed73a1d..29304f6 100644 --- a/PostmandDelivers HTTPS.postman_environment.json +++ b/PostmandDelivers HTTPS.postman_environment.json @@ -4,7 +4,7 @@ "values": [ { "key": "baseurl", - "value": "", + "value": "https://localhost:5001/api", "enabled": true }, { @@ -34,6 +34,6 @@ } ], "_postman_variable_scope": "environment", - "_postman_exported_at": "2019-10-09T00:13:13.464Z", - "_postman_exported_using": "Postman/7.8.0" + "_postman_exported_at": "2019-11-03T12:25:40.400Z", + "_postman_exported_using": "Postman/7.10.0" } \ No newline at end of file diff --git a/PostmandDelivers HTTP.postman_environment.json b/PostmandDelivers Local.postman_environment.json similarity index 76% rename from PostmandDelivers HTTP.postman_environment.json rename to PostmandDelivers Local.postman_environment.json index 610a1d5..0dbc898 100644 --- a/PostmandDelivers HTTP.postman_environment.json +++ b/PostmandDelivers Local.postman_environment.json @@ -1,10 +1,10 @@ { "id": "e902407c-6cce-4860-bd13-3860e93e6459", - "name": "PostmandDelivers HTTP", + "name": "PostmandDelivers Local", "values": [ { "key": "baseurl", - "value": "", + "value": "http://localhost:8082/api", "enabled": true }, { @@ -34,6 +34,6 @@ } ], "_postman_variable_scope": "environment", - "_postman_exported_at": "2019-10-09T00:13:06.232Z", - "_postman_exported_using": "Postman/7.8.0" + "_postman_exported_at": "2019-12-28T19:22:58.332Z", + "_postman_exported_using": "Postman/7.14.0" } \ No newline at end of file diff --git a/PostmandDelivers DEBUG.postman_environment.json b/PostmandDelivers Prod.postman_environment.json similarity index 76% rename from PostmandDelivers DEBUG.postman_environment.json rename to PostmandDelivers Prod.postman_environment.json index feefb5e..166656d 100644 --- a/PostmandDelivers DEBUG.postman_environment.json +++ b/PostmandDelivers Prod.postman_environment.json @@ -1,10 +1,10 @@ { "id": "f3c1560d-e9b7-4f17-be71-a278c012fdf8", - "name": "PostmandDelivers DEBUG", + "name": "PostmandDelivers Prod", "values": [ { "key": "baseurl", - "value": "", + "value": "http://localhost:8083/api", "enabled": true }, { @@ -34,6 +34,6 @@ } ], "_postman_variable_scope": "environment", - "_postman_exported_at": "2019-10-06T19:15:09.497Z", - "_postman_exported_using": "Postman/7.8.0" + "_postman_exported_at": "2019-12-28T19:23:02.568Z", + "_postman_exported_using": "Postman/7.14.0" } \ No newline at end of file diff --git a/README.md b/README.md index 1566745..adda9da 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ # PostmanDelivers + +[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/b709e2ea8a9229963e83) diff --git a/Script Order.postman_collection.json b/Script Order.postman_collection.json index 0eb23c3..6deabcd 100644 --- a/Script Order.postman_collection.json +++ b/Script Order.postman_collection.json @@ -36,21 +36,12 @@ "method": "GET", "header": [], "url": { - "raw": "https://localhost:5001/api/Values?order=1", - "protocol": "https", + "raw": "{{baseurl}}/Values", "host": [ - "localhost" + "{{baseurl}}" ], - "port": "5001", "path": [ - "api", "Values" - ], - "query": [ - { - "key": "order", - "value": "1" - } ] } }, @@ -84,21 +75,12 @@ "method": "GET", "header": [], "url": { - "raw": "https://localhost:5001/api/Values?order=2", - "protocol": "https", + "raw": "{{baseurl}}/Values", "host": [ - "localhost" + "{{baseurl}}" ], - "port": "5001", "path": [ - "api", "Values" - ], - "query": [ - { - "key": "order", - "value": "2" - } ] } }, @@ -157,21 +139,12 @@ "method": "GET", "header": [], "url": { - "raw": "https://localhost:5001/api/Values?order=2", - "protocol": "https", + "raw": "{{baseurl}}/Values", "host": [ - "localhost" + "{{baseurl}}" ], - "port": "5001", "path": [ - "api", "Values" - ], - "query": [ - { - "key": "order", - "value": "2" - } ] } }, @@ -205,21 +178,12 @@ "method": "GET", "header": [], "url": { - "raw": "https://localhost:5001/api/Values?order=3", - "protocol": "https", + "raw": "{{baseurl}}/Values", "host": [ - "localhost" + "{{baseurl}}" ], - "port": "5001", "path": [ - "api", "Values" - ], - "query": [ - { - "key": "order", - "value": "3" - } ] } }, diff --git a/ScriptOrderEnv.postman_environment.json b/ScriptOrderEnv.postman_environment.json deleted file mode 100644 index ae82a9e..0000000 --- a/ScriptOrderEnv.postman_environment.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "96ef8159-d7c9-4a6e-940a-7ff34d0bcb03", - "name": "ScriptOrderEnv", - "values": [], - "_postman_variable_scope": "environment", - "_postman_exported_at": "2019-10-09T00:15:35.241Z", - "_postman_exported_using": "Postman/7.8.0" -} \ No newline at end of file diff --git a/TikTakToe.Engine/Game.cs b/TikTakToe.Engine/Game.cs index 46cc3db..26c8242 100644 --- a/TikTakToe.Engine/Game.cs +++ b/TikTakToe.Engine/Game.cs @@ -182,14 +182,14 @@ LEFT OUTER JOIN PlayerMoves m PlayerXID = m.Key.PlayerXID, PlayerOID = m.Key.PlayerOID, Board = new GameBoard( - m.Key.SquareOne, - m.Key.SquareTwo, - m.Key.SquareThree, - m.Key.SquareFour, - m.Key.SquareFive, - m.Key.SquareSix, - m.Key.SquareSeven, - m.Key.SquareEight, + m.Key.SquareOne, + m.Key.SquareTwo, + m.Key.SquareThree, + m.Key.SquareFour, + m.Key.SquareFive, + m.Key.SquareSix, + m.Key.SquareSeven, + m.Key.SquareEight, m.Key.SquareNine), Moves = m.Select(mv => new PlayerMove { @@ -341,6 +341,15 @@ private int NewGame(string connection) } } + public void Delete(int game_id, string connection) + { + using (var conn = new SQLiteConnection(connection)) + { + conn.Open(); + conn.Execute(@"DELETE FROM Games WHERE Id = @game_id;", new { game_id }); + } + } + private string GenerateID() { var csp = RNGCryptoServiceProvider.Create(); diff --git a/X Wins Manual.postman_collection.json b/X Wins Manual.postman_collection.json index cb9e77b..ba4ba5b 100644 --- a/X Wins Manual.postman_collection.json +++ b/X Wins Manual.postman_collection.json @@ -26,10 +26,10 @@ "method": "POST", "header": [ { - "key": "Content-Type", - "name": "Content-Type", + "key": "au", + "value": "", "type": "text", - "value": "application/json" + "disabled": true } ], "body": { @@ -42,14 +42,11 @@ } }, "url": { - "raw": "https://localhost:5001/api/Game", - "protocol": "https", + "raw": "{{baseurl}}/Game", "host": [ - "localhost" + "{{baseurl}}" ], - "port": "5001", "path": [ - "api", "Game" ] } @@ -791,27 +788,7 @@ "script": { "id": "97ad4eef-99b5-4a4d-896e-7e63d3bd14ab", "exec": [ - "const response = pm.response.json();", - "", - "let tmplt = `", - " ", - " ", - " ", - " ", - "
{{one}}{{two}}{{three}}
{{four}}{{five}}{{six}}
{{seven}}{{eight}}{{nine}}
`;", - " ", - "pm.visualizer.set(tmplt, {response:", - "{", - " 'one': response.board.squares[0],", - " 'two': response.board.squares[1],", - " 'three': response.board.squares[2],", - " 'four': response.board.squares[3],", - " 'five': response.board.squares[4],", - " 'six': response.board.squares[5],", - " 'seven': response.board.squares[6],", - " 'eight': response.board.squares[7],", - " 'nine': response.board.squares[8]", - "}});" + "" ], "type": "text/javascript" } diff --git a/X Wins With Tests.postman_collection.json b/X Wins With Tests.postman_collection.json new file mode 100644 index 0000000..4b77e26 --- /dev/null +++ b/X Wins With Tests.postman_collection.json @@ -0,0 +1,2209 @@ +{ + "info": { + "_postman_id": "8f3765a5-93fd-46e7-a42b-4547f4d66b85", + "name": "X Wins With Tests", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Happy Path", + "item": [ + { + "name": "Generate New Game", + "event": [ + { + "listen": "test", + "script": { + "id": "eb04b227-5d6b-4048-bf61-a286119f1b6c", + "exec": [ + "", + "const responseJson = pm.response.json();", + "", + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", + "});", + "", + "pm.environment.set(\"happy_path_game_id\", responseJson.id);", + "pm.environment.set(\"happy_path_playerx_id\", responseJson.playerXID);", + "pm.environment.set(\"happy_path_playero_id\", responseJson.playerOID);", + "pm.environment.set(\"happy_path_playerx_name\", responseJson.playerXName);", + "pm.environment.set(\"happy_path_playero_name\", responseJson.playerOName);", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "[\"{{$randomFirstName}}\", \"{{$randomFirstName}}\"]", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Game", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game" + ] + } + }, + "response": [ + { + "name": "Generate New Game", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "[\"Bob\", \"Janel\"]", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Game", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game" + ] + } + }, + "status": "Created", + "code": 201, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 17:37:03 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Location", + "value": "https://localhost:5001/api/Game/30" + } + ], + "cookie": [], + "body": "{\n \"id\": 30,\n \"board\": {\n \"squares\": [\n null,\n null,\n null,\n null,\n null,\n null,\n null,\n null,\n null\n ],\n \"winner\": null\n },\n \"moves\": [],\n \"playerXName\": \"Bob\",\n \"playerXID\": \"nyIC8fduHXIqywtE\",\n \"playerOName\": \"Janel\",\n \"playerOID\": \"8HeuRqMruw7OGDHyTPkYLhxmZp\",\n \"winner\": 0,\n \"gameState\": 1\n}" + } + ] + }, + { + "name": "X Move To [1]", + "event": [ + { + "listen": "test", + "script": { + "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "const responseJson = pm.response.json();", + "", + "pm.test(\"Move is valid\", () => {", + " pm.expect(responseJson.isValid).to.be.true;", + "});", + "", + "pm.test(\"Game is in progress\", () => {", + " pm.expect(responseJson.gameIsOver).to.be.false; ", + "});", + "", + "pm.test(\"Move is valid so reason is null\", () => {", + " pm.expect(responseJson.reason).to.be.null; ", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "response": [ + { + "name": "X Move To [1]", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:02:35 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" + } + ] + }, + { + "name": "Get Game By ID", + "event": [ + { + "listen": "test", + "script": { + "id": "97ad4eef-99b5-4a4d-896e-7e63d3bd14ab", + "exec": [ + "pm.test(\"Status code is 200\", () => {", + " pm.response.to.have.status(200);", + "});", + "", + "const responseJson = pm.response.json();", + "", + "const game_id = pm.environment.get(\"happy_path_game_id\");", + "", + "pm.test(`The game id is ${game_id}`, () => {", + " pm.expect(game_id).to.eq(responseJson.id);", + "});", + "", + "pm.test(\"Square 1 is null\", () => {", + " pm.expect(responseJson.board.squares[0]).to.be.null; ", + "});", + "", + "pm.test(\"Square 2 is an X\", () => {", + " pm.expect(\"X\").to.eq(responseJson.board.squares[1]); ", + "});", + "", + "for(let i = 2; i < 9; i++) {", + " pm.test(`Square ${i} is null`, () => {", + " pm.expect(responseJson.board.squares[i]).to.be.null; ", + " });", + "}", + "", + "pm.test(\"Board winner is null\", () => {", + " pm.expect(responseJson.board.winner).to.be.null; ", + "});", + "", + "pm.test(\"Game has only one move\", () => {", + " pm.expect(1).to.eq(responseJson.moves.length); ", + "});", + "", + "pm.test(`Move game id is ${game_id}`, () => {", + " pm.expect(game_id).to.eq(responseJson.moves[0].gameID);", + "});", + "", + "pm.test(\"Move used square 1\", () => {", + " pm.expect(1).to.eq(responseJson.moves[0].square);", + "});", + "", + "pm.test(\"Player was X\", () => {", + " pm.expect(1).to.eq(responseJson.moves[0].player);", + "});", + "", + "const playerxname = pm.environment.get(\"happy_path_playerx_name\");", + "pm.test(`Player X Name is ${playerxname}`, () => {", + " pm.expect(playerxname).to.eq(responseJson.playerXName); ", + "});", + "", + "const playeroname = pm.environment.get(\"happy_path_playero_name\");", + "pm.test(`Player O Name is ${playeroname}`, () => {", + " pm.expect(playeroname).to.eq(responseJson.playerOName); ", + "});", + "", + "const playerxid = pm.environment.get(\"happy_path_playerx_id\");", + "pm.test(`Player X id is ${playerxid}`, () => {", + " pm.expect(playerxid).to.eq(responseJson.playerXID);", + "});", + "", + "const playeroid = pm.environment.get(\"happy_path_playero_id\");", + "pm.test(`Player O id is ${playeroid}`, () => {", + " pm.expect(playeroid).to.eq(responseJson.playerOID);", + "});", + "", + "pm.test(\"Game winner is zero (None)\", () => {", + " pm.expect(0).to.eq(responseJson.winner); ", + "});", + "", + "pm.test(\"Game state is in progress\", () => {", + " pm.expect(1).to.eq(responseJson.gameState) ;", + "});", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game", + "{{happy_path_game_id}}" + ] + } + }, + "response": [ + { + "name": "Game with one Move", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game", + "{{happy_path_game_id}}" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:28:40 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"id\": 46,\n \"board\": {\n \"squares\": [\n null,\n \"X\",\n null,\n null,\n null,\n null,\n null,\n null,\n null\n ],\n \"winner\": null\n },\n \"moves\": [\n {\n \"gameID\": 46,\n \"square\": 1,\n \"gameboardBefore\": \"[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"timestamp\": 1570386515,\n \"player\": 1\n }\n ],\n \"playerXName\": \"Bob\",\n \"playerXID\": \"SibDaxfPfIYRqmHF\",\n \"playerOName\": \"Janel\",\n \"playerOID\": \"ZRXH9TLbcc0ithGb\",\n \"winner\": 0,\n \"gameState\": 1\n}" + } + ] + }, + { + "name": "O Move To [3]", + "event": [ + { + "listen": "test", + "script": { + "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "const responseJson = pm.response.json();", + "", + "pm.test(\"Move is valid\", () => {", + " pm.expect(responseJson.isValid).to.be.true;", + "});", + "", + "pm.test(\"Game is in progress\", () => {", + " pm.expect(responseJson.gameIsOver).to.be.false; ", + "});", + "", + "pm.test(\"Move is valid so reason is null\", () => {", + " pm.expect(responseJson.reason).to.be.null; ", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"O\",\n\t\"whichSquare\" : 3,\n\t\"playerID\" : \"{{happy_path_playero_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "response": [ + { + "name": "O moves to square occupied by X", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "plain", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 19:00:43 GMT" + }, + { + "key": "Content-Type", + "value": "text/plain; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "Illegal Move. Reason: The square is already occupied by X. Turn aborted, try again., Game Board:\r\n[ ] [ X ] [ ]\r\n\r\n[ ] [ ] [ ]\r\n\r\n[ ] [ ] [ ]" + }, + { + "name": "X Move To [1]", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:02:35 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" + } + ] + }, + { + "name": "X Move To [0]", + "event": [ + { + "listen": "test", + "script": { + "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "const responseJson = pm.response.json();", + "", + "pm.test(\"Move is valid\", () => {", + " pm.expect(responseJson.isValid).to.be.true;", + "});", + "", + "pm.test(\"Game is in progress\", () => {", + " pm.expect(responseJson.gameIsOver).to.be.false; ", + "});", + "", + "pm.test(\"Move is valid so reason is null\", () => {", + " pm.expect(responseJson.reason).to.be.null; ", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 0,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "response": [ + { + "name": "X Move To [1]", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:02:35 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" + } + ] + }, + { + "name": "O Move To [7]", + "event": [ + { + "listen": "test", + "script": { + "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "const responseJson = pm.response.json();", + "", + "pm.test(\"Move is valid\", () => {", + " pm.expect(responseJson.isValid).to.be.true;", + "});", + "", + "pm.test(\"Game is in progress\", () => {", + " pm.expect(responseJson.gameIsOver).to.be.false; ", + "});", + "", + "pm.test(\"Move is valid so reason is null\", () => {", + " pm.expect(responseJson.reason).to.be.null; ", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"O\",\n\t\"whichSquare\" : 7,\n\t\"playerID\" : \"{{happy_path_playero_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "response": [ + { + "name": "X Move To [1]", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:02:35 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" + } + ] + }, + { + "name": "X Move To [2]", + "event": [ + { + "listen": "test", + "script": { + "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "const responseJson = pm.response.json();", + "", + "pm.test(\"Move is valid\", () => {", + " pm.expect(responseJson.isValid).to.be.true;", + "});", + "", + "pm.test(\"Game is over\", () => {", + " pm.expect(responseJson.gameIsOver).to.be.true; ", + "});", + "", + "pm.test(\"Move is valid so reason is null\", () => {", + " pm.expect(responseJson.reason).to.eq(\"Game is Over. Congratulations to X\"); ", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 2,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "response": [ + { + "name": "X Move To [1]", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:02:35 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" + } + ] + }, + { + "name": "Get End Game", + "event": [ + { + "listen": "test", + "script": { + "id": "97ad4eef-99b5-4a4d-896e-7e63d3bd14ab", + "exec": [ + "const responseJson = pm.response.json();", + "", + "var custom_script = eval(pm.globals.get(\"game_visualizer\"));", + "", + "const game = custom_script.BuildMoves(responseJson.moves);", + " ", + "pm.visualizer.set(custom_script.Template, {response: game});", + "", + "pm.test(\"Status code is 200\", () => {", + " pm.response.to.have.status(200);", + "});", + "", + "const game_id = pm.environment.get(\"happy_path_game_id\");", + "", + "pm.test(`The game id is ${game_id}`, () => {", + " pm.expect(game_id).to.eq(responseJson.id);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game", + "{{happy_path_game_id}}" + ] + } + }, + "response": [ + { + "name": "Get End Game", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game", + "{{happy_path_game_id}}" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Wed, 09 Oct 2019 17:16:51 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"id\": 59,\n \"board\": {\n \"squares\": [\n \"X\",\n \"X\",\n \"X\",\n \"O\",\n null,\n null,\n null,\n \"O\",\n null\n ],\n \"winner\": null\n },\n \"moves\": [\n {\n \"gameID\": 59,\n \"square\": 1,\n \"gameboardBefore\": \"[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"timestamp\": 1570641393,\n \"player\": 1\n },\n {\n \"gameID\": 59,\n \"square\": 3,\n \"gameboardBefore\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"timestamp\": 1570641399,\n \"player\": 2\n },\n {\n \"gameID\": 59,\n \"square\": 0,\n \"gameboardBefore\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ X ] [ X ] [ ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"timestamp\": 1570641403,\n \"player\": 1\n },\n {\n \"gameID\": 59,\n \"square\": 7,\n \"gameboardBefore\": \"[ X ] [ X ] [ ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ X ] [ X ] [ ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ O ] [ ]\",\n \"timestamp\": 1570641406,\n \"player\": 2\n },\n {\n \"gameID\": 59,\n \"square\": 2,\n \"gameboardBefore\": \"[ X ] [ X ] [ ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ O ] [ ]\",\n \"gameboardAfter\": \"[ X ] [ X ] [ X ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ O ] [ ]\",\n \"timestamp\": 1570641409,\n \"player\": 1\n }\n ],\n \"playerXName\": \"Bob\",\n \"playerXID\": \"20OvGQjFxnv0XxPBEfwZFPXL7\",\n \"playerOName\": \"Janel\",\n \"playerOID\": \"QXC91Qe4cJhZylRIBZN\",\n \"winner\": 1,\n \"gameState\": 2\n}" + }, + { + "name": "Game with one Move", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game", + "{{happy_path_game_id}}" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:28:40 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"id\": 46,\n \"board\": {\n \"squares\": [\n null,\n \"X\",\n null,\n null,\n null,\n null,\n null,\n null,\n null\n ],\n \"winner\": null\n },\n \"moves\": [\n {\n \"gameID\": 46,\n \"square\": 1,\n \"gameboardBefore\": \"[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"timestamp\": 1570386515,\n \"player\": 1\n }\n ],\n \"playerXName\": \"Bob\",\n \"playerXID\": \"SibDaxfPfIYRqmHF\",\n \"playerOName\": \"Janel\",\n \"playerOID\": \"ZRXH9TLbcc0ithGb\",\n \"winner\": 0,\n \"gameState\": 1\n}" + } + ] + } + ], + "description": "This folder contains requests that play an entire Tic Tac Toe game start to finish without errors.", + "protocolProfileBehavior": {} + }, + { + "name": "Runner", + "item": [ + { + "name": "Generate New Game", + "event": [ + { + "listen": "test", + "script": { + "id": "eb04b227-5d6b-4048-bf61-a286119f1b6c", + "exec": [ + "", + "const responseJson = pm.response.json();", + "", + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", + "});", + "", + "pm.environment.set(\"happy_path_game_id\", responseJson.id);", + "pm.environment.set(\"happy_path_playerx_id\", responseJson.playerXID);", + "pm.environment.set(\"happy_path_playero_id\", responseJson.playerOID);", + "pm.environment.set(\"happy_path_playerx_name\", responseJson.playerXName);", + "pm.environment.set(\"happy_path_playero_name\", responseJson.playerOName);", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "[\"{{$randomFirstName}}\", \"{{$randomFirstName}}\"]" + }, + "url": { + "raw": "{{baseurl}}/Game", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game" + ] + } + }, + "response": [ + { + "name": "Generate New Game", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "[\"Bob\", \"Janel\"]", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Game", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game" + ] + } + }, + "status": "Created", + "code": 201, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 17:37:03 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + }, + { + "key": "Location", + "value": "https://localhost:5001/api/Game/30" + } + ], + "cookie": [], + "body": "{\n \"id\": 30,\n \"board\": {\n \"squares\": [\n null,\n null,\n null,\n null,\n null,\n null,\n null,\n null,\n null\n ],\n \"winner\": null\n },\n \"moves\": [],\n \"playerXName\": \"Bob\",\n \"playerXID\": \"nyIC8fduHXIqywtE\",\n \"playerOName\": \"Janel\",\n \"playerOID\": \"8HeuRqMruw7OGDHyTPkYLhxmZp\",\n \"winner\": 0,\n \"gameState\": 1\n}" + } + ] + }, + { + "name": "X Move", + "event": [ + { + "listen": "test", + "script": { + "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "const responseJson = pm.response.json();", + "", + "pm.test(\"Move is valid\", () => {", + " pm.expect(responseJson.isValid).to.be.true;", + "});", + "", + "pm.test(\"Game is in progress\", () => {", + " pm.expect(responseJson.gameIsOver).to.be.false; ", + "});", + "", + "pm.test(\"Move is valid so reason is null\", () => {", + " pm.expect(responseJson.reason).to.be.null; ", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : {{move_one}},\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}" + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "response": [ + { + "name": "X Move To [1]", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:02:35 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" + } + ] + }, + { + "name": "Get Game By ID", + "event": [ + { + "listen": "test", + "script": { + "id": "97ad4eef-99b5-4a4d-896e-7e63d3bd14ab", + "exec": [ + "pm.test(\"Status code is 200\", () => {", + " pm.response.to.have.status(200);", + "});", + "", + "const responseJson = pm.response.json();", + "", + "const game_id = pm.environment.get(\"happy_path_game_id\");", + "", + "pm.test(`The game id is ${game_id}`, () => {", + " pm.expect(game_id).to.eq(responseJson.id);", + "});", + "", + "pm.test(\"Square 1 is null\", () => {", + " pm.expect(responseJson.board.squares[0]).to.be.null; ", + "});", + "", + "pm.test(\"Square 2 is an X\", () => {", + " pm.expect(\"X\").to.eq(responseJson.board.squares[1]); ", + "});", + "", + "for(let i = 2; i < 9; i++) {", + " pm.test(`Square ${i} is null`, () => {", + " pm.expect(responseJson.board.squares[i]).to.be.null; ", + " });", + "}", + "", + "pm.test(\"Board winner is null\", () => {", + " pm.expect(responseJson.board.winner).to.be.null; ", + "});", + "", + "pm.test(\"Game has only one move\", () => {", + " pm.expect(1).to.eq(responseJson.moves.length); ", + "});", + "", + "pm.test(`Move game id is ${game_id}`, () => {", + " pm.expect(game_id).to.eq(responseJson.moves[0].gameID);", + "});", + "", + "pm.test(\"Move used square 1\", () => {", + " pm.expect(1).to.eq(responseJson.moves[0].square);", + "});", + "", + "pm.test(\"Player was X\", () => {", + " pm.expect(1).to.eq(responseJson.moves[0].player);", + "});", + "", + "const playerxname = pm.environment.get(\"happy_path_playerx_name\");", + "pm.test(`Player X Name is ${playerxname}`, () => {", + " pm.expect(playerxname).to.eq(responseJson.playerXName); ", + "});", + "", + "const playeroname = pm.environment.get(\"happy_path_playero_name\");", + "pm.test(`Player O Name is ${playeroname}`, () => {", + " pm.expect(playeroname).to.eq(responseJson.playerOName); ", + "});", + "", + "const playerxid = pm.environment.get(\"happy_path_playerx_id\");", + "pm.test(`Player X id is ${playerxid}`, () => {", + " pm.expect(playerxid).to.eq(responseJson.playerXID);", + "});", + "", + "const playeroid = pm.environment.get(\"happy_path_playero_id\");", + "pm.test(`Player O id is ${playeroid}`, () => {", + " pm.expect(playeroid).to.eq(responseJson.playerOID);", + "});", + "", + "pm.test(\"Game winner is zero (None)\", () => {", + " pm.expect(0).to.eq(responseJson.winner); ", + "});", + "", + "pm.test(\"Game state is in progress\", () => {", + " pm.expect(1).to.eq(responseJson.gameState) ;", + "});", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game", + "{{happy_path_game_id}}" + ] + } + }, + "response": [ + { + "name": "Game with one Move", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game", + "{{happy_path_game_id}}" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:28:40 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"id\": 46,\n \"board\": {\n \"squares\": [\n null,\n \"X\",\n null,\n null,\n null,\n null,\n null,\n null,\n null\n ],\n \"winner\": null\n },\n \"moves\": [\n {\n \"gameID\": 46,\n \"square\": 1,\n \"gameboardBefore\": \"[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"timestamp\": 1570386515,\n \"player\": 1\n }\n ],\n \"playerXName\": \"Bob\",\n \"playerXID\": \"SibDaxfPfIYRqmHF\",\n \"playerOName\": \"Janel\",\n \"playerOID\": \"ZRXH9TLbcc0ithGb\",\n \"winner\": 0,\n \"gameState\": 1\n}" + } + ] + }, + { + "name": "O Move", + "event": [ + { + "listen": "test", + "script": { + "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "const responseJson = pm.response.json();", + "", + "pm.test(\"Move is valid\", () => {", + " pm.expect(responseJson.isValid).to.be.true;", + "});", + "", + "pm.test(\"Game is in progress\", () => {", + " pm.expect(responseJson.gameIsOver).to.be.false; ", + "});", + "", + "pm.test(\"Move is valid so reason is null\", () => {", + " pm.expect(responseJson.reason).to.be.null; ", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"O\",\n\t\"whichSquare\" : {{move_two}},\n\t\"playerID\" : \"{{happy_path_playero_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}" + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "response": [ + { + "name": "X Move To [1]", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:02:35 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" + }, + { + "name": "O moves to square occupied by X", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "plain", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 19:00:43 GMT" + }, + { + "key": "Content-Type", + "value": "text/plain; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "Illegal Move. Reason: The square is already occupied by X. Turn aborted, try again., Game Board:\r\n[ ] [ X ] [ ]\r\n\r\n[ ] [ ] [ ]\r\n\r\n[ ] [ ] [ ]" + } + ] + }, + { + "name": "X Move", + "event": [ + { + "listen": "test", + "script": { + "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "const responseJson = pm.response.json();", + "", + "pm.test(\"Move is valid\", () => {", + " pm.expect(responseJson.isValid).to.be.true;", + "});", + "", + "pm.test(\"Game is in progress\", () => {", + " pm.expect(responseJson.gameIsOver).to.be.false; ", + "});", + "", + "pm.test(\"Move is valid so reason is null\", () => {", + " pm.expect(responseJson.reason).to.be.null; ", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : {{move_three}},\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}" + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "response": [ + { + "name": "X Move To [1]", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:02:35 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" + } + ] + }, + { + "name": "O Move", + "event": [ + { + "listen": "test", + "script": { + "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "const responseJson = pm.response.json();", + "", + "pm.test(\"Move is valid\", () => {", + " pm.expect(responseJson.isValid).to.be.true;", + "});", + "", + "pm.test(\"Game is in progress\", () => {", + " pm.expect(responseJson.gameIsOver).to.be.false; ", + "});", + "", + "pm.test(\"Move is valid so reason is null\", () => {", + " pm.expect(responseJson.reason).to.be.null; ", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"O\",\n\t\"whichSquare\" : {{move_four}},\n\t\"playerID\" : \"{{happy_path_playero_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}" + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "response": [ + { + "name": "X Move To [1]", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:02:35 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" + } + ] + }, + { + "name": "X Move", + "event": [ + { + "listen": "test", + "script": { + "id": "38b2ade3-795f-47ca-9c30-707c5ef0a3b2", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "const responseJson = pm.response.json();", + "", + "pm.test(\"Move is valid\", () => {", + " pm.expect(responseJson.isValid).to.be.true;", + "});", + "", + "pm.test(\"Game is in progress\", () => {", + " pm.expect(responseJson.gameIsOver).to.be.true; ", + "});", + "", + "pm.test(\"Move is valid so reason is null\", () => {", + " pm.expect(responseJson.reason).to.eq(\"Game is Over. Congratulations to X\"); ", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : {{move_fiv}},\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}" + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "response": [ + { + "name": "X Move To [1]", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 1,\n\t\"playerID\" : \"{{happy_path_playerx_id}}\",\n\t\"gameId\" : {{happy_path_game_id}}\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:02:35 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"isValid\": true,\n \"gameIsOver\": false,\n \"reason\": null,\n \"gameBoard\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\"\n}" + } + ] + }, + { + "name": "Get End Game", + "event": [ + { + "listen": "test", + "script": { + "id": "97ad4eef-99b5-4a4d-896e-7e63d3bd14ab", + "exec": [ + "", + "const responseJson = pm.response.json();", + "", + "var custom_script = eval(pm.globals.get(\"game_visualizer\"));", + "", + "const game = custom_script.BuildMoves(responseJson.moves);", + " ", + "pm.visualizer.set(custom_script.Template, {response: game});", + "", + "", + "", + "pm.test(\"Status code is 200\", () => {", + " pm.response.to.have.status(200);", + "});", + "", + "const game_id = pm.environment.get(\"happy_path_game_id\");", + "", + "pm.test(`The game id is ${game_id}`, () => {", + " pm.expect(game_id).to.eq(responseJson.id);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game", + "{{happy_path_game_id}}" + ] + } + }, + "response": [ + { + "name": "Game with one Move", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game", + "{{happy_path_game_id}}" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Sun, 06 Oct 2019 18:28:40 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"id\": 46,\n \"board\": {\n \"squares\": [\n null,\n \"X\",\n null,\n null,\n null,\n null,\n null,\n null,\n null\n ],\n \"winner\": null\n },\n \"moves\": [\n {\n \"gameID\": 46,\n \"square\": 1,\n \"gameboardBefore\": \"[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"timestamp\": 1570386515,\n \"player\": 1\n }\n ],\n \"playerXName\": \"Bob\",\n \"playerXID\": \"SibDaxfPfIYRqmHF\",\n \"playerOName\": \"Janel\",\n \"playerOID\": \"ZRXH9TLbcc0ithGb\",\n \"winner\": 0,\n \"gameState\": 1\n}" + }, + { + "name": "Get End Game", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseurl}}/Game/{{happy_path_game_id}}", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game", + "{{happy_path_game_id}}" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Date", + "value": "Wed, 09 Oct 2019 17:16:51 GMT" + }, + { + "key": "Content-Type", + "value": "application/json; charset=utf-8" + }, + { + "key": "Server", + "value": "Kestrel" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"id\": 59,\n \"board\": {\n \"squares\": [\n \"X\",\n \"X\",\n \"X\",\n \"O\",\n null,\n null,\n null,\n \"O\",\n null\n ],\n \"winner\": null\n },\n \"moves\": [\n {\n \"gameID\": 59,\n \"square\": 1,\n \"gameboardBefore\": \"[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"timestamp\": 1570641393,\n \"player\": 1\n },\n {\n \"gameID\": 59,\n \"square\": 3,\n \"gameboardBefore\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"timestamp\": 1570641399,\n \"player\": 2\n },\n {\n \"gameID\": 59,\n \"square\": 0,\n \"gameboardBefore\": \"[ ] [ X ] [ ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ X ] [ X ] [ ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"timestamp\": 1570641403,\n \"player\": 1\n },\n {\n \"gameID\": 59,\n \"square\": 7,\n \"gameboardBefore\": \"[ X ] [ X ] [ ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ ] [ ]\",\n \"gameboardAfter\": \"[ X ] [ X ] [ ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ O ] [ ]\",\n \"timestamp\": 1570641406,\n \"player\": 2\n },\n {\n \"gameID\": 59,\n \"square\": 2,\n \"gameboardBefore\": \"[ X ] [ X ] [ ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ O ] [ ]\",\n \"gameboardAfter\": \"[ X ] [ X ] [ X ]\\r\\n\\r\\n[ O ] [ ] [ ]\\r\\n\\r\\n[ ] [ O ] [ ]\",\n \"timestamp\": 1570641409,\n \"player\": 1\n }\n ],\n \"playerXName\": \"Bob\",\n \"playerXID\": \"20OvGQjFxnv0XxPBEfwZFPXL7\",\n \"playerOName\": \"Janel\",\n \"playerOID\": \"QXC91Qe4cJhZylRIBZN\",\n \"winner\": 1,\n \"gameState\": 2\n}" + } + ] + } + ], + "description": "This folder contains requests that play an entire Tic Tac Toe game start to finish without errors.", + "protocolProfileBehavior": {} + }, + { + "name": "Individual Requests", + "item": [ + { + "name": "Get All Games", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseurl}}/Game", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game" + ] + }, + "description": "This request will retrieve all games ever played" + }, + "response": [] + }, + { + "name": "Get Game By ID", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseurl}}/Game/25", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game", + "25" + ] + } + }, + "response": [] + }, + { + "name": "Generate New Game", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "[\"Bob\", \"Janel\"]", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Game", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Game" + ] + } + }, + "response": [] + }, + { + "name": "X Move To [1]", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"xoro\" : \"X\",\n\t\"whichSquare\" : 11,\n\t\"playerID\" : \"20OvFKGSSWvNQEXpLTdbSr2Kb\",\n\t\"gameId\" : 26\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseurl}}/Move", + "host": [ + "{{baseurl}}" + ], + "path": [ + "Move" + ] + } + }, + "response": [] + } + ], + "protocolProfileBehavior": {} + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..346fd2e --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,56 @@ +# ASP.NET Core +# Build and test ASP.NET Core projects targeting .NET Core. +# Add steps that run tests, create a NuGet package, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core + +trigger: +- master + +pool: + vmImage: 'windows-latest' + +variables: + buildConfiguration: 'Release' + +steps: + +- task: DotNetCoreCLI@2 + displayName: 'donet publish' + inputs: + command: 'publish' + publishWebProjects: false + projects: '**\PostmanDelivers.API.csproj' + arguments: '--configuration Release' + +- task: CmdLine@2 + inputs: + script: | + cd $(Build.SourcesDirectory) + dir /s +- task: PublishBuildArtifacts@1 + displayName: 'Publish API' + inputs: + PathtoPublish: '$(Build.SourcesDirectory)\PostmanDelivers.API\bin\Release\netcoreapp2.2\publish.zip' + ArtifactName: 'drop' + publishLocation: 'Container' + +- task: PublishBuildArtifacts@1 + displayName: 'Publish postman globals' + inputs: + PathtoPublish: '$(Build.SourcesDirectory)\Postman Delivers.postman_globals.json' + ArtifactName: 'globals' + publishLocation: 'Container' + +- task: PublishBuildArtifacts@1 + displayName: 'Publish azure env' + inputs: + PathtoPublish: '$(Build.SourcesDirectory)\PostmandDelivers Azure.postman_environment.json' + ArtifactName: 'azure environment' + publishLocation: 'Container' + +- task: PublishBuildArtifacts@1 + displayName: 'Publish test collection' + inputs: + PathtoPublish: '$(Build.SourcesDirectory)\X Wins With Tests.postman_collection.json' + ArtifactName: 'test collection' + publishLocation: 'Container' \ No newline at end of file diff --git a/data.json b/data.json new file mode 100644 index 0000000..afeeba2 --- /dev/null +++ b/data.json @@ -0,0 +1,42 @@ +[ + { + "move_one": 1, + "move_two": 2, + "move_three": 3, + "move_four": 4, + "move_five": 5, + "move_six": 6 + }, + { + "move_one": 6, + "move_two": 7, + "move_three": 4, + "move_four": 3, + "move_five": 2, + "move_six": 1 + }, + { + "move_one": 1, + "move_two": 2, + "move_three": 7, + "move_four": 4, + "move_five": 5, + "move_six": 6 + }, + { + "move_one": 1, + "move_two": 2, + "move_three": 3, + "move_four": 8, + "move_five": 8, + "move_six": 6 + }, + { + "move_one": 1, + "move_two": 0, + "move_three": 10, + "move_four": 40, + "move_five": 50, + "move_six": 16 + } +] \ No newline at end of file diff --git a/newman_script.txt b/newman_script.txt new file mode 100644 index 0000000..777734d --- /dev/null +++ b/newman_script.txt @@ -0,0 +1 @@ +newman run "X Wins With Tests.postman_collection.json" -e "PostmandDelivers Local.postman_environment.json" --insecure \ No newline at end of file