This repository has been archived by the owner on Jul 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Started to refine Types * ... * ... * Input non nullable * move add field game * cleanup usings * Introduce Schema Builder * schema test * sonar * ... * ... * remove VsCode folder * Update SchemaBuilder.cs
- Loading branch information
Showing
28 changed files
with
316 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
using System; | ||
|
||
namespace UltimateTicTacToe.Abstractions | ||
{ | ||
public class Move | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<AssemblyName>UltimateTicTacToe.Api.Tests</AssemblyName> | ||
<RootNamespace>UltimateTicTacToe.Api.Tests</RootNamespace> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<DebugType>Portable</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<DebugType>none</DebugType> | ||
<DebugSymbols>false</DebugSymbols> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="5.6.0" /> | ||
<PackageReference Include="Snapshooter.Xunit" Version="0.4.5" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> | ||
<PackageReference Include="Moq" Version="4.10.1" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" /> | ||
<PackageReference Include="coverlet.msbuild" Version="2.5.1" /> | ||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.4.0-beta.1.build3958" /> | ||
</ItemGroup> | ||
|
||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Api\Api.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Xunit; | ||
using Snapshooter.Xunit; | ||
using HotChocolate.Types; | ||
using UltimateTicTacToe.Api.Types; | ||
|
||
namespace UltimateTicTacToe.Api.Tests | ||
{ | ||
public class SchemaBuilderTests | ||
{ | ||
[Fact] | ||
public void Ensure_Schema_IsCorrect() | ||
{ | ||
// arrange | ||
var schema = SchemaBuilder.BuildSchema(); | ||
|
||
// act | ||
string schemaSDL = schema.ToString(); | ||
|
||
// assert | ||
Snapshot.Match(schemaSDL); | ||
} | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
src/Api.Tests/__snapshots__/SchemaBuilderTests.Ensure_Schema_IsCorrect.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
schema { | ||
query: Query | ||
mutation: Mutation | ||
} | ||
|
||
type Game { | ||
id: ID! | ||
moves: [Move!]! | ||
winner: Winner | ||
finishedAt: Date | ||
} | ||
|
||
type Move { | ||
id: ID! | ||
boardPosition: Position! | ||
tilePosition: Position! | ||
player: Player! | ||
moveNumber: Int! | ||
game: Game! | ||
} | ||
|
||
type MoveResult { | ||
isValid: Boolean! | ||
move: Move! | ||
invalidReason: String! | ||
moveFinishedBoard: Boolean! | ||
moveFinishedGame: Boolean! | ||
} | ||
|
||
type Mutation { | ||
createGame: Game! | ||
move(input: MoveInput!): MoveResult! | ||
} | ||
|
||
type Position { | ||
x: Int! | ||
y: Int! | ||
equals: Boolean! | ||
} | ||
|
||
type Query { | ||
game(id: ID!): Game | ||
} | ||
|
||
input MoveInput { | ||
gameId: ID! | ||
player: Player! | ||
boardPosition: PositionInput! | ||
tilePosition: PositionInput! | ||
} | ||
|
||
input PositionInput { | ||
x: Int! | ||
y: Int! | ||
} | ||
|
||
enum Player { | ||
CROSS | ||
CIRCLE | ||
} | ||
|
||
enum Winner { | ||
CROSS | ||
CIRCLE | ||
NONE | ||
DRAW | ||
} | ||
|
||
"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text." | ||
scalar String | ||
|
||
"The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID." | ||
scalar ID | ||
|
||
"The `Boolean` scalar type represents `true` or `false`." | ||
scalar Boolean | ||
|
||
"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1." | ||
scalar Int | ||
|
||
"The `Date` scalar represents an ISO-8601 compliant date type." | ||
scalar Date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using HotChocolate; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using HotChocolate.Types; | ||
using UltimateTicTacToe.Abstractions; | ||
using UltimateTicTacToe.Api.Input; | ||
|
||
namespace UltimateTicTacToe.Api.Types | ||
{ | ||
public class MoveInputType : InputObjectType<MoveInput> | ||
{ | ||
protected override void Configure(IInputObjectTypeDescriptor<MoveInput> descriptor) | ||
{ | ||
descriptor | ||
.Field(m => m.GameId) | ||
.Type<NonNullType<IdType>>(); | ||
|
||
descriptor | ||
.Field(m => m.Player) | ||
.Type<NonNullType<EnumType<Player>>>(); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using HotChocolate.Types; | ||
using UltimateTicTacToe.Domain.Abstractions; | ||
|
||
namespace UltimateTicTacToe.Api.Types | ||
{ | ||
public class MoveResultType : ObjectType<MoveResult> | ||
{ | ||
protected override void Configure( | ||
IObjectTypeDescriptor<MoveResult> descriptor) | ||
{ | ||
descriptor | ||
.Field(m => m.IsValid) | ||
.Type<NonNullType<BooleanType>>(); | ||
|
||
descriptor | ||
.Field(m => m.Move) | ||
.Type<NonNullType<MoveType>>(); | ||
|
||
descriptor | ||
.Field(m => m.InvalidReason) | ||
.Type<NonNullType<StringType>>(); | ||
|
||
descriptor | ||
.Field(m => m.MoveFinishedBoard) | ||
.Type<NonNullType<BooleanType>>(); | ||
|
||
descriptor | ||
.Field(m => m.MoveFinishedGame) | ||
.Type<NonNullType<BooleanType>>(); | ||
} | ||
} | ||
} |
Oops, something went wrong.