Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Fisher committed May 27, 2023
1 parent 8bfbc56 commit 165ab27
Show file tree
Hide file tree
Showing 6 changed files with 442 additions and 0 deletions.
247 changes: 247 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
*.swp
*.*~
project.lock.json
.DS_Store
*.pyc
nupkg/

# Visual Studio Code
.vscode

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
# build/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
msbuild.log
msbuild.err
msbuild.wrn

# Visual Studio 2015
.vs/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

# DNX
project.lock.json
artifacts/

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap

# 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

# 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
# but database connection strings (with potential passwords) will be unencrypted
*.publishproj

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config

# Microsoft Azure Build Output
csx/
*.build.csdef

# Microsoft Azure Emulator
ecf/
rcf/

# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config

# Windows Store app package directory
AppPackages/
BundleArtifacts/

# 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
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs

# 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

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# GhostDoc plugin setting file
*.GhostDoc.xml

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# 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

# FAKE - F# Make
.fake/

#VS config file
/.[Vv]s/*
/[Cc]onfig/*

.svn/
.vs/config/applicationhost.config
*.orig
*.VC.db
1 change: 1 addition & 0 deletions WaveApps.GraphQLBuilder.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Xunit;
30 changes: 30 additions & 0 deletions WaveApps.GraphQLBuilder.Tests/WaveApps.GraphQLBuilder.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.categories" Version="2.0.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\WaveApps.GraphQLBuilder\WaveApps.GraphQLBuilder.csproj" />
</ItemGroup>

</Project>
82 changes: 82 additions & 0 deletions WaveApps.GraphQLBuilder.Tests/WaveQueryBuilderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System.ComponentModel.DataAnnotations;
using FluentAssertions;
using Xunit.Categories;

namespace WaveApps.GraphQLBuilder.Tests
{
public class WaveQueryBuilderTests
{
[Fact]
[UnitTest]
public void ListBusinesses()
{
var query = new WaveQueryBuilder()
.WithBusinesses(
new BusinessConnectionQueryBuilder()
.WithEdges(new BusinessEdgeQueryBuilder()
.WithNode(new BusinessQueryBuilder()
.WithId()
.WithName())))
.Build();

query.Should().BeEquivalentTo("query{businesses{edges{node{id,name}}}}");
}

[Fact]
[UnitTest]
public void GetUser()
{
var query = new WaveQueryBuilder()
.WithUser(new UserQueryBuilder()
.WithId()
.WithFirstName()
.WithLastName()
.WithDefaultEmail()
.WithCreatedAt()
.WithCreatedAt()
.WithModifiedAt()
).Build();

query.Should().BeEquivalentTo("query{user{id,firstName,lastName,defaultEmail,createdAt,modifiedAt}}");
}

[Fact]
[UnitTest]
public void ListInvoicesByCustomer()
{
var businessIdParameter = new GraphQlQueryParameter<Guid?>("businessId", Guid.Parse("b534b077-5640-4fa1-b8e3-f50da66c8215"));
var sortParameter = new GraphQlQueryParameter<IEnumerable<InvoiceSort>>("sort", $"[{GraphQlTypes.InvoiceSort}!]!", new[] { InvoiceSort.StatusAsc });
var page = new GraphQlQueryParameter<int?>("page", 1);
var pageSize = new GraphQlQueryParameter<int?>("pageSize", 5);

var query = new WaveQueryBuilder()
.WithBusiness(new BusinessQueryBuilder()
.WithId()
.WithInvoices(new InvoiceConnectionQueryBuilder()
.WithPageInfo(new OffsetPageInfoQueryBuilder()
.WithAllFields())
.WithEdges(new InvoiceEdgeQueryBuilder()
.WithNode(new InvoiceQueryBuilder()
.WithId()
.WithInvoiceNumber()
.WithDueDate()
.WithAmountDue(new MoneyQueryBuilder()
.WithAllFields())
.WithTotal(new MoneyQueryBuilder()
.WithAllFields())
.WithStatus()
.WithCustomer(new CustomerQueryBuilder()
.WithEmail())
)),
sortParameter, page: page, pageSize: pageSize),
id: businessIdParameter)
.WithParameter(businessIdParameter)
.WithParameter(page)
.WithParameter(pageSize)
.WithParameter(sortParameter)
.Build();

query.Should().BeEquivalentTo("query($businessId:ID=\"b534b077-5640-4fa1-b8e3-f50da66c8215\",$page:Int=1,$pageSize:Int=5,$sort:[InvoiceSort!]!){business(id:$businessId){id,invoices(page:$page,pageSize:$pageSize,sort:$sort){pageInfo{currentPage,totalPages,totalCount},edges{node{id,invoiceNumber,dueDate,amountDue{minorUnitValue,value,currency{code,symbol,name,plural,exponent}},total{minorUnitValue,value,currency{code,symbol,name,plural,exponent}},status,customer{email}}}}}}");
}
}
}
31 changes: 31 additions & 0 deletions WaveApps.GraphQLBuilder.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WaveApps.GraphQLBuilder", "WaveApps.GraphQLBuilder\WaveApps.GraphQLBuilder.csproj", "{F89AC7BE-40AD-4106-B7E5-CBE09C284DCA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WaveApps.GraphQLBuilder.Tests", "WaveApps.GraphQLBuilder.Tests\WaveApps.GraphQLBuilder.Tests.csproj", "{0044985F-9DCE-4D07-9F58-F2B084A19896}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F89AC7BE-40AD-4106-B7E5-CBE09C284DCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F89AC7BE-40AD-4106-B7E5-CBE09C284DCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F89AC7BE-40AD-4106-B7E5-CBE09C284DCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F89AC7BE-40AD-4106-B7E5-CBE09C284DCA}.Release|Any CPU.Build.0 = Release|Any CPU
{0044985F-9DCE-4D07-9F58-F2B084A19896}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0044985F-9DCE-4D07-9F58-F2B084A19896}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0044985F-9DCE-4D07-9F58-F2B084A19896}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0044985F-9DCE-4D07-9F58-F2B084A19896}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E14BA90C-1C26-4508-BFBC-924C05808501}
EndGlobalSection
EndGlobal
Loading

0 comments on commit 165ab27

Please sign in to comment.