Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
pekkah committed Mar 8, 2019
1 parent 249e4e1 commit 2f2119a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion tests/graphql.tests/EventsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ public ISourceBlock<object> Subscribe(CancellationToken unsubscribe)

public class Success
{
public Success(int id)
public Success(int id, Event ev)
{
Id = id;
Event = ev;
}

public int Id { get; set; }
public Event Event { get; }
}

public class Failure
Expand Down
16 changes: 13 additions & 3 deletions tests/graphql.tests/ExecutorFacts.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
Expand All @@ -22,6 +23,7 @@ enum EventType {
type Success {
id: ID!
event: Event
}
type Failure {
Expand Down Expand Up @@ -68,7 +70,8 @@ public ExecutorFacts()
{
"Success", new FieldResolverMap
{
{"id", Resolve.PropertyOf<EventsModel.Success>(m => m.Id)}
{"id", Resolve.PropertyOf<EventsModel.Success>(m => m.Id)},
{"event", Resolve.PropertyOf<EventsModel.Success>(m => m.Event)}
}
},
{
Expand Down Expand Up @@ -112,10 +115,11 @@ public ExecutorFacts()
new EventsModel.Failure("Payload should be given"));
var id = await Model.AddAsync(newEvent);
var ev = Model.Events.Single(e => e.Id == id);
return Resolve.As(
context.Schema.GetNamedType<ObjectType>("Success"),
new EventsModel.Success(id));
new EventsModel.Success(id, ev));
}
}
}
Expand Down Expand Up @@ -175,6 +179,9 @@ public async Task Mutation1()
__typename
...on Success {
id
event {
payload
}
}
...on Failure {
Expand All @@ -200,7 +207,10 @@ ...on Failure {
""data"": {
""create"": {
""__typename"": ""Success"",
""id"": ""1""
""id"": ""1"",
""event"": {
""payload"": ""payload""
}
}
}
}");
Expand Down

0 comments on commit 2f2119a

Please sign in to comment.