diff --git a/examples/DgraphExample/DgraphExample.csproj b/examples/DgraphExample/DgraphExample.csproj
index c704950..30e5ed3 100644
--- a/examples/DgraphExample/DgraphExample.csproj
+++ b/examples/DgraphExample/DgraphExample.csproj
@@ -4,13 +4,12 @@
Exe
net7.0
enable
- enable
-
+
-
+
diff --git a/examples/DgraphExample/ExecuteDQLQuery.cs b/examples/DgraphExample/ExecuteDQLQuery.cs
index 9538dda..06d737d 100644
--- a/examples/DgraphExample/ExecuteDQLQuery.cs
+++ b/examples/DgraphExample/ExecuteDQLQuery.cs
@@ -5,7 +5,7 @@ namespace DgraphExample
{
class ExecuteDQL
{
- public static async Task Query(DgraphClient Client, string query)
+ public static async Task Query(IDgraphClient Client, string query)
{
using (ITransaction transaction = Client.NewTransaction())
{
diff --git a/examples/DgraphExample/Program.cs b/examples/DgraphExample/Program.cs
index c96821b..203b32b 100644
--- a/examples/DgraphExample/Program.cs
+++ b/examples/DgraphExample/Program.cs
@@ -9,7 +9,7 @@ static async Task Main(string[] args)
// Connect to Dgraph Cloud.
var cloudUrl = "https://green-bird.grpc.us-east-1.aws.cloud.dgraph.io/graphql";
var APIKEY = "xxx=";
- using var client = new DgraphClient(DgraphCloudChannel.Create(cloudUrl, APIKEY));
+ using var client = DgraphClient.Create(DgraphCloudChannel.Create(cloudUrl, APIKEY));
var version = await client.CheckVersion();
@@ -26,6 +26,5 @@ static async Task Main(string[] args)
Console.WriteLine(result);
}
-
}
}
diff --git a/source/Dgraph.tests.e2e/Dgraph.tests.e2e.csproj b/source/Dgraph.tests.e2e/Dgraph.tests.e2e.csproj
index cdf743e..90e67e3 100644
--- a/source/Dgraph.tests.e2e/Dgraph.tests.e2e.csproj
+++ b/source/Dgraph.tests.e2e/Dgraph.tests.e2e.csproj
@@ -4,7 +4,6 @@
Exe
net7.0
enable
- enable
Dgraph.tests.e2e
false
latest
@@ -12,30 +11,31 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
Always
-
+
diff --git a/source/Dgraph.tests.e2e/Errors/DgraphDotNetTestFailure.cs b/source/Dgraph.tests.e2e/Errors/DgraphDotNetTestFailure.cs
index 1ffd45f..9010450 100644
--- a/source/Dgraph.tests.e2e/Errors/DgraphDotNetTestFailure.cs
+++ b/source/Dgraph.tests.e2e/Errors/DgraphDotNetTestFailure.cs
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-using System;
using FluentResults;
namespace Dgraph.tests.e2e.Errors
@@ -30,4 +29,4 @@ public DgraphDotNetTestFailure(string message, ResultBase failureReason) : base(
FailureReason = failureReason;
}
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests.e2e/Orchestration/DgraphClientFactory.cs b/source/Dgraph.tests.e2e/Orchestration/DgraphClientFactory.cs
index b9d97d7..0378899 100644
--- a/source/Dgraph.tests.e2e/Orchestration/DgraphClientFactory.cs
+++ b/source/Dgraph.tests.e2e/Orchestration/DgraphClientFactory.cs
@@ -13,10 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-using System;
-using System.Threading.Tasks;
-using Grpc.Core;
+
using Grpc.Net.Client;
using Serilog;
@@ -24,18 +21,16 @@ namespace Dgraph.tests.e2e.Orchestration
{
public class DgraphClientFactory
{
-
private bool printed;
public async Task GetDgraphClient()
{
-
// FIXME: This is not what you'd want to do in a real app. Normally, there
// would be tls to the server. TO ADD - tests of running over https, and
// with a Dgraph tls client certificate, and in enterprise mode.
AppContext.SetSwitch(
"System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
- var client = new DgraphClient(GrpcChannel.ForAddress("http://127.0.0.1:9080"));
+ var client = DgraphClient.Create(GrpcChannel.ForAddress("http://127.0.0.1:9080"));
if (!printed)
{
@@ -53,6 +48,5 @@ public async Task GetDgraphClient()
return client;
}
-
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests.e2e/Orchestration/TestExecutor.cs b/source/Dgraph.tests.e2e/Orchestration/TestExecutor.cs
index e2a2a16..e72239e 100644
--- a/source/Dgraph.tests.e2e/Orchestration/TestExecutor.cs
+++ b/source/Dgraph.tests.e2e/Orchestration/TestExecutor.cs
@@ -13,10 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
namespace Dgraph.tests.e2e.Orchestration
{
diff --git a/source/Dgraph.tests.e2e/Orchestration/TestFinder.cs b/source/Dgraph.tests.e2e/Orchestration/TestFinder.cs
index 8cd0495..a114be1 100644
--- a/source/Dgraph.tests.e2e/Orchestration/TestFinder.cs
+++ b/source/Dgraph.tests.e2e/Orchestration/TestFinder.cs
@@ -13,10 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
+
using Dgraph.tests.e2e.Tests;
using Microsoft.Extensions.DependencyInjection;
@@ -68,4 +65,4 @@ public DgraphDotNetE2ETest FindTestByName(string name)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests.e2e/Program.cs b/source/Dgraph.tests.e2e/Program.cs
index c53b7c5..23f1ea1 100644
--- a/source/Dgraph.tests.e2e/Program.cs
+++ b/source/Dgraph.tests.e2e/Program.cs
@@ -13,12 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
+
using Dgraph.tests.e2e.Errors;
using Dgraph.tests.e2e.Orchestration;
using Dgraph.tests.e2e.Tests;
@@ -29,7 +24,6 @@
namespace Dgraph.tests.e2e
{
-
[Command(Name = "Dgraph.net E2E test runner")]
[HelpOption("--help")]
class Program
@@ -163,4 +157,4 @@ private async Task Execute(IEnumerable tests)
private void EnsureAllTestsRegistered() =>
TestFinder.FindTests(TestFinder.FindTestNames());
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests.e2e/Tests/Approved/SchemaTest.AlterSchemAsExpected.approved.txt b/source/Dgraph.tests.e2e/Tests/Approved/SchemaTest.AlterSchemAsExpected.approved.txt
index 39cdc1c..20438ee 100644
--- a/source/Dgraph.tests.e2e/Tests/Approved/SchemaTest.AlterSchemAsExpected.approved.txt
+++ b/source/Dgraph.tests.e2e/Tests/Approved/SchemaTest.AlterSchemAsExpected.approved.txt
@@ -1,5 +1,8 @@
abool: bool .
+dgraph.drop.op: string .
+dgraph.graphql.p_query: string @index(sha256) .
dgraph.graphql.schema: string .
+dgraph.graphql.xid: string @index(exact) @upsert .
dgraph.type: [string] @index(exact) .
dob: datetime @index(year) .
friends: [uid] @reverse @count .
@@ -17,4 +20,9 @@ type Person {
type dgraph.graphql {
dgraph.graphql.schema
+ dgraph.graphql.xid
+}
+
+type dgraph.graphql.persisted_query {
+ dgraph.graphql.p_query
}
diff --git a/source/Dgraph.tests.e2e/Tests/Approved/SchemaTest.AlterSchemaAgainAsExpected.approved.txt b/source/Dgraph.tests.e2e/Tests/Approved/SchemaTest.AlterSchemaAgainAsExpected.approved.txt
index 3c1c512..a318af7 100644
--- a/source/Dgraph.tests.e2e/Tests/Approved/SchemaTest.AlterSchemaAgainAsExpected.approved.txt
+++ b/source/Dgraph.tests.e2e/Tests/Approved/SchemaTest.AlterSchemaAgainAsExpected.approved.txt
@@ -1,7 +1,10 @@
abool: bool .
car: uid @count .
carMake: string @index(hash) .
+dgraph.drop.op: string .
+dgraph.graphql.p_query: string @index(sha256) .
dgraph.graphql.schema: string .
+dgraph.graphql.xid: string @index(exact) @upsert .
dgraph.type: [string] @index(exact) .
dob: datetime @index(day) .
friends: [uid] @reverse @count .
@@ -19,4 +22,9 @@ type Person {
type dgraph.graphql {
dgraph.graphql.schema
+ dgraph.graphql.xid
+}
+
+type dgraph.graphql.persisted_query {
+ dgraph.graphql.p_query
}
diff --git a/source/Dgraph.tests.e2e/Tests/Approved/SchemaTest.InitialSchemaIsAsExpected.approved.txt b/source/Dgraph.tests.e2e/Tests/Approved/SchemaTest.InitialSchemaIsAsExpected.approved.txt
index 23fc8d7..6889e3a 100644
--- a/source/Dgraph.tests.e2e/Tests/Approved/SchemaTest.InitialSchemaIsAsExpected.approved.txt
+++ b/source/Dgraph.tests.e2e/Tests/Approved/SchemaTest.InitialSchemaIsAsExpected.approved.txt
@@ -1,5 +1,13 @@
+dgraph.drop.op: string .
+dgraph.graphql.p_query: string @index(sha256) .
dgraph.graphql.schema: string .
+dgraph.graphql.xid: string @index(exact) @upsert .
dgraph.type: [string] @index(exact) .
type dgraph.graphql {
dgraph.graphql.schema
+ dgraph.graphql.xid
+}
+
+type dgraph.graphql.persisted_query {
+ dgraph.graphql.p_query
}
diff --git a/source/Dgraph.tests.e2e/Tests/DgraphDotNetE2ETest.cs b/source/Dgraph.tests.e2e/Tests/DgraphDotNetE2ETest.cs
index 5062866..e1b8a73 100644
--- a/source/Dgraph.tests.e2e/Tests/DgraphDotNetE2ETest.cs
+++ b/source/Dgraph.tests.e2e/Tests/DgraphDotNetE2ETest.cs
@@ -14,15 +14,14 @@
* limitations under the License.
*/
-using System.IO;
using System.Reflection;
using System.Text;
-using System.Threading.Tasks;
using Assent.Namers;
using Dgraph.tests.e2e.Errors;
using Dgraph.tests.e2e.Orchestration;
using FluentResults;
using Microsoft.Extensions.FileProviders;
+using Serilog;
namespace Dgraph.tests.e2e.Tests
{
@@ -39,7 +38,13 @@ public DgraphDotNetE2ETest(DgraphClientFactory clientFactory)
ClientFactory = clientFactory;
AssentConfiguration = new Assent.Configuration()
- .UsingNamer(new SubdirectoryNamer("Approved"));
+ .UsingNamer(new SubdirectoryNamer("Approved"))
+ .UsingReporter((received, approved) =>
+ {
+ received = System.IO.File.ReadAllText(received);
+ approved = System.IO.File.ReadAllText(approved);
+ Log.Warning("Expected:\n{approved}\nReceived:\n{received}\n", approved, received);
+ });
// FIXME: .UsingSanitiser(...) might want to add this to remove versions etc
// FIXME: when I add this to a build pipeline it needs this turned off when running on the build server
// .SetInteractive(...);
@@ -95,4 +100,4 @@ protected void AssertResultIsSuccess(ResultBase result, string msg = null)
}
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests.e2e/Tests/MutateQueryTest.cs b/source/Dgraph.tests.e2e/Tests/MutateQueryTest.cs
index ea21938..efec4e3 100644
--- a/source/Dgraph.tests.e2e/Tests/MutateQueryTest.cs
+++ b/source/Dgraph.tests.e2e/Tests/MutateQueryTest.cs
@@ -13,17 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
+
using Dgraph.tests.e2e.Orchestration;
using Dgraph.tests.e2e.Tests.TestClasses;
using FluentAssertions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
-using Api;
-using Dgraph.Transactions;
namespace Dgraph.tests.e2e.Tests
{
@@ -40,7 +35,7 @@ public async override Task Setup()
var alterSchemaResult = await
(await ClientFactory.GetDgraphClient()).Alter(
- new Operation { Schema = ReadEmbeddedFile("test.schema") });
+ new Api.Operation { Schema = ReadEmbeddedFile("test.schema") });
AssertResultIsSuccess(alterSchemaResult);
Person1 = new Person()
@@ -74,66 +69,62 @@ public async override Task Setup()
public async override Task Test()
{
- using (var client = await ClientFactory.GetDgraphClient())
- {
- await AddThreePeople(client);
- await QueryAllThreePeople(client);
- await AlterAPerson(client);
- await QueryWithVars(client);
- await DeleteAPerson(client);
- }
+ using var client = await ClientFactory.GetDgraphClient();
+
+ await AddThreePeople(client);
+ await QueryAllThreePeople(client);
+ await AlterAPerson(client);
+ await QueryWithVars(client);
+ await DeleteAPerson(client);
}
private async Task AddThreePeople(IDgraphClient client)
{
+ using var transaction = client.NewTransaction();
- using (var transaction = client.NewTransaction())
- {
+ // Serialize the objects to json in whatever way works best for you.
+ //
+ // The CamelCaseNamingStrategy attribute on the type means these
+ // get serialised with initial lower case.
+ var personList = new List { Person1, Person2, Person3 };
+ var json = JsonConvert.SerializeObject(personList);
- // Serialize the objects to json in whatever way works best for you.
- //
- // The CamelCaseNamingStrategy attribute on the type means these
- // get serialised with initial lower case.
- var personList = new List { Person1, Person2, Person3 };
- var json = JsonConvert.SerializeObject(personList);
+ // There's two mutation options. For just one mutation, use this version
+ var result = await transaction.Mutate(new MutationBuilder().SetJson(json));
- // There's two mutation options. For just one mutation, use this version
- var result = await transaction.Mutate(setJson: json);
+ // For more complicated multi-mutation requests or upsert mutations
+ // see the upsert test.
- // For more complicated multi-mutation requests or upsert mutations
- // see the upsert test.
+ AssertResultIsSuccess(result, "Mutation failed");
- AssertResultIsSuccess(result, "Mutation failed");
+ // The payload of the result contains a node->uid map of newly
+ // allocated nodes. If the nodes don't have uid names in the
+ // mutation, then the map is like
+ //
+ // {{ "blank-0": "0xa", "blank-1": "0xb", "blank-2": "0xc", ... }}
+ //
+ // If the
+ // mutation has '{ "uid": "_:Person1" ... }' etc, then the blank
+ // node map is like
+ //
+ // {{ "Person3": "0xe", "Person1": "0xf", "Person2": "0xd", ... }}
- // The payload of the result contains a node->uid map of newly
- // allocated nodes. If the nodes don't have uid names in the
- // mutation, then the map is like
- //
- // {{ "blank-0": "0xa", "blank-1": "0xb", "blank-2": "0xc", ... }}
- //
- // If the
- // mutation has '{ "uid": "_:Person1" ... }' etc, then the blank
- // node map is like
- //
- // {{ "Person3": "0xe", "Person1": "0xf", "Person2": "0xd", ... }}
+ result.Value.Uids.Count.Should().Be(3);
- result.Value.Uids.Count.Should().Be(3);
+ // It's no required to save the uid's like this, but can work
+ // nicely ... and makes these tests easier to keep track of.
- // It's no required to save the uid's like this, but can work
- // nicely ... and makes these tests easier to keep track of.
+ Person1.Uid = result.Value.Uids[Person1.Uid.Substring(2)];
+ Person2.Uid = result.Value.Uids[Person2.Uid.Substring(2)];
+ Person3.Uid = result.Value.Uids[Person3.Uid.Substring(2)];
- Person1.Uid = result.Value.Uids[Person1.Uid.Substring(2)];
- Person2.Uid = result.Value.Uids[Person2.Uid.Substring(2)];
- Person3.Uid = result.Value.Uids[Person3.Uid.Substring(2)];
+ var transactionResult = await transaction.Commit();
+ AssertResultIsSuccess(transactionResult);
- var transactionResult = await transaction.Commit();
- AssertResultIsSuccess(transactionResult);
- }
}
private async Task QueryAllThreePeople(IDgraphClient client)
{
-
var people = new List { Person1, Person2, Person3 };
foreach (var person in people)
@@ -149,24 +140,23 @@ private async Task QueryAllThreePeople(IDgraphClient client)
private async Task AlterAPerson(IDgraphClient client)
{
- using (var transaction = client.NewTransaction())
- {
- Person3.Friends.Add(Person2);
+ using var transaction = client.NewTransaction();
- // This will serialize the whole object. You might not want to
- // do that, and maybe only add in the bits that have changed
- // instead.
- var json = JsonConvert.SerializeObject(Person3);
+ Person3.Friends.Add(Person2);
- var result = await transaction.Mutate(setJson: json);
- AssertResultIsSuccess(result, "Mutation failed");
+ // This will serialize the whole object. You might not want to
+ // do that, and maybe only add in the bits that have changed
+ // instead.
+ var json = JsonConvert.SerializeObject(Person3);
- // no nodes were allocated
- result.Value.Uids.Count.Should().Be(0);
+ var result = await transaction.Mutate(new MutationBuilder().SetJson(json));
+ AssertResultIsSuccess(result, "Mutation failed");
- var transactionResult = await transaction.Commit();
- AssertResultIsSuccess(transactionResult);
- }
+ // no nodes were allocated
+ result.Value.Uids.Count.Should().Be(0);
+
+ var transactionResult = await transaction.Commit();
+ AssertResultIsSuccess(transactionResult);
var queryPerson = await client.NewReadOnlyTransaction().
Query(FriendQueries.QueryByUid(Person3.Uid));
@@ -188,17 +178,16 @@ private async Task QueryWithVars(IDgraphClient client)
private async Task DeleteAPerson(IDgraphClient client)
{
- using (var transaction = client.NewTransaction())
- {
+ using var transaction = client.NewTransaction();
- // delete a node by passing JSON like this to delete
- var deleteResult = await transaction.Mutate(
- deleteJson: $"{{\"uid\": \"{Person1.Uid}\"}}");
- AssertResultIsSuccess(deleteResult, "Delete failed");
+ // delete a node by passing JSON like this to delete
+ var deleteResult = await transaction.Mutate(
+ new MutationBuilder().DeleteJson($"{{\"uid\": \"{Person1.Uid}\"}}")
+ );
+ AssertResultIsSuccess(deleteResult, "Delete failed");
- var transactionResult = await transaction.Commit();
- AssertResultIsSuccess(transactionResult);
- }
+ var transactionResult = await transaction.Commit();
+ AssertResultIsSuccess(transactionResult);
// that person should be gone...
var queryPerson1 = await client.NewReadOnlyTransaction().
@@ -226,6 +215,5 @@ private async Task DeleteAPerson(IDgraphClient client)
person3.Friends.Count.Should().Be(2);
}
-
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests.e2e/Tests/SchemaTest.cs b/source/Dgraph.tests.e2e/Tests/SchemaTest.cs
index c321624..3571a36 100644
--- a/source/Dgraph.tests.e2e/Tests/SchemaTest.cs
+++ b/source/Dgraph.tests.e2e/Tests/SchemaTest.cs
@@ -14,15 +14,11 @@
* limitations under the License.
*/
-using System.Threading.Tasks;
using Assent;
using Dgraph.tests.e2e.Orchestration;
using FluentAssertions;
using Newtonsoft.Json;
using Dgraph.Schema;
-using Api;
-using System;
-using System.Threading;
namespace Dgraph.tests.e2e.Tests
{
@@ -32,15 +28,14 @@ public SchemaTest(DgraphClientFactory clientFactory) : base(clientFactory) { }
public async override Task Test()
{
- using (var client = await ClientFactory.GetDgraphClient())
- {
- await InitialSchemaIsAsExpected(client);
- await AlterSchemAsExpected(client);
- await AlterSchemaAgainAsExpected(client);
- await SchemaQueryWithRestrictions(client);
-
- await ErrorsResultInFailedQuery(client);
- }
+ using var client = await ClientFactory.GetDgraphClient();
+
+ await InitialSchemaIsAsExpected(client);
+ await AlterSchemAsExpected(client);
+ await AlterSchemaAgainAsExpected(client);
+ await SchemaQueryWithRestrictions(client);
+
+ await ErrorsResultInFailedQuery(client);
}
private async Task InitialSchemaIsAsExpected(IDgraphClient client)
@@ -55,7 +50,7 @@ private async Task InitialSchemaIsAsExpected(IDgraphClient client)
private async Task AlterSchemAsExpected(IDgraphClient client)
{
var alterSchemaResult = await client.Alter(
- new Operation { Schema = ReadEmbeddedFile("test.schema") });
+ new Api.Operation { Schema = ReadEmbeddedFile("test.schema") });
AssertResultIsSuccess(alterSchemaResult);
// After an Alter, Dgraph computes indexes in the background.
@@ -75,7 +70,7 @@ private async Task AlterSchemAsExpected(IDgraphClient client)
private async Task AlterSchemaAgainAsExpected(IDgraphClient client)
{
var alterSchemaResult = await client.Alter(
- new Operation { Schema = ReadEmbeddedFile("altered.schema") });
+ new Api.Operation { Schema = ReadEmbeddedFile("altered.schema") });
AssertResultIsSuccess(alterSchemaResult);
Thread.Sleep(TimeSpan.FromSeconds(5));
@@ -105,4 +100,4 @@ private async Task ErrorsResultInFailedQuery(IDgraphClient client)
q1result.IsSuccess.Should().BeFalse();
}
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests.e2e/Tests/TestClasses/FriendQueries.cs b/source/Dgraph.tests.e2e/Tests/TestClasses/FriendQueries.cs
index fd3e52d..a29251b 100644
--- a/source/Dgraph.tests.e2e/Tests/TestClasses/FriendQueries.cs
+++ b/source/Dgraph.tests.e2e/Tests/TestClasses/FriendQueries.cs
@@ -13,17 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-using System.Collections.Generic;
+
using FluentAssertions;
using Newtonsoft.Json.Linq;
namespace Dgraph.tests.e2e.Tests.TestClasses
{
-
public class FriendQueries
{
-
public static string QueryByUid(string uid) =>
"{ "
+ $" q(func: uid({uid})) "
@@ -69,4 +66,4 @@ public static void AssertStringIsPerson(string json, Person person)
}
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests.e2e/Tests/TestClasses/Person.cs b/source/Dgraph.tests.e2e/Tests/TestClasses/Person.cs
index ab13518..ae3f4c9 100644
--- a/source/Dgraph.tests.e2e/Tests/TestClasses/Person.cs
+++ b/source/Dgraph.tests.e2e/Tests/TestClasses/Person.cs
@@ -13,15 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-using System;
-using System.Collections.Generic;
+
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Dgraph.tests.e2e.Tests.TestClasses
{
-
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class Person
{
@@ -34,5 +31,4 @@ public class Person
public double Height { get; set; }
public List Scores { get; } = new List();
}
-
}
diff --git a/source/Dgraph.tests.e2e/Tests/TransactionTest.cs b/source/Dgraph.tests.e2e/Tests/TransactionTest.cs
index 5ab40df..cffba85 100644
--- a/source/Dgraph.tests.e2e/Tests/TransactionTest.cs
+++ b/source/Dgraph.tests.e2e/Tests/TransactionTest.cs
@@ -13,16 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
+
using Dgraph.tests.e2e.Orchestration;
using Dgraph.tests.e2e.Tests.TestClasses;
using Dgraph.Transactions;
using FluentAssertions;
using Newtonsoft.Json;
-using Api;
// This is not a test of Dgraph's transactional behavior. However,
// there's some client-side transaction state and handling, so this tests that
@@ -31,10 +27,8 @@
namespace Dgraph.tests.e2e.Tests
{
-
public class TransactionTest : DgraphDotNetE2ETest
{
-
public TransactionTest(DgraphClientFactory clientFactory) : base(clientFactory) { }
public async override Task Setup()
@@ -42,40 +36,36 @@ public async override Task Setup()
await base.Setup();
var alterSchemaResult = await
(await ClientFactory.GetDgraphClient()).Alter(
- new Operation { Schema = ReadEmbeddedFile("test.schema") });
+ new Api.Operation { Schema = ReadEmbeddedFile("test.schema") });
AssertResultIsSuccess(alterSchemaResult);
}
public async override Task Test()
{
- using (var client = await ClientFactory.GetDgraphClient())
- {
+ using var client = await ClientFactory.GetDgraphClient();
- // mutate & query interleaving
- await NoDirtyReads(client);
- await TransactionsAreSerlializable(client);
- await DiscardedTransactionsHaveNoEffect(client);
+ // mutate & query interleaving
+ await NoDirtyReads(client);
+ await TransactionsAreSerlializable(client);
+ await DiscardedTransactionsHaveNoEffect(client);
+
+ // mutate & mutate interleaving
+ await UnrelatedTransactionsDoNotConflict(client);
+ await ConflictingTransactionsDontBothSucceed(client);
- // mutate & mutate interleaving
- await UnrelatedTransactionsDoNotConflict(client);
- await ConflictingTransactionsDontBothSucceed(client);
- }
}
#region mutate-query
private async Task NoDirtyReads(IDgraphClient client)
{
-
- var txn1 = client.NewTransaction();
+ using var txn1 = client.NewTransaction();
var person = MintAPerson(nameof(NoDirtyReads));
var json = JsonConvert.SerializeObject(person);
- var transactionResult = await txn1.Mutate(new RequestBuilder().
- WithMutations(new MutationBuilder
- {
- SetJson = json
- }));
+ var transactionResult = await txn1.Do(
+ new RequestBuilder().WithMutations(new MutationBuilder().SetJson(json))
+ );
AssertResultIsSuccess(transactionResult, "Mutation failed");
person.Uid = transactionResult.Value.Uids[person.Uid.Substring(2)];
@@ -106,17 +96,14 @@ private async Task NoDirtyReads(IDgraphClient client)
private async Task TransactionsAreSerlializable(IDgraphClient client)
{
-
- var txn1 = client.NewTransaction();
- var txn2 = client.NewTransaction();
+ using var txn1 = client.NewTransaction();
+ using var txn2 = client.NewTransaction();
var person = MintAPerson(nameof(TransactionsAreSerlializable));
var json = JsonConvert.SerializeObject(person);
- var transactionResult = await txn1.Mutate(new RequestBuilder().
- WithMutations(new MutationBuilder
- {
- SetJson = json
- }));
+ var transactionResult = await txn1.Do(
+ new RequestBuilder().WithMutations(new MutationBuilder().SetJson(json))
+ );
AssertResultIsSuccess(transactionResult);
person.Uid = transactionResult.Value.Uids[person.Uid.Substring(2)];
@@ -135,22 +122,17 @@ private async Task TransactionsAreSerlializable(IDgraphClient client)
new Dictionary { { "$name", person.Name } });
AssertResultIsSuccess(queryByName);
queryByName.Value.Json.Should().Be("{\"q\":[]}");
-
- await txn2.Discard();
}
private async Task DiscardedTransactionsHaveNoEffect(IDgraphClient client)
{
-
var txn1 = client.NewTransaction();
var person = MintAPerson(nameof(DiscardedTransactionsHaveNoEffect));
var json = JsonConvert.SerializeObject(person);
- var transactionResult = await txn1.Mutate(new RequestBuilder().
- WithMutations(new MutationBuilder
- {
- SetJson = json
- }));
+ var transactionResult = await txn1.Do(
+ new RequestBuilder().WithMutations(new MutationBuilder().SetJson(json))
+ );
AssertResultIsSuccess(transactionResult);
person.Uid = transactionResult.Value.Uids[person.Uid.Substring(2)];
@@ -177,27 +159,22 @@ private async Task DiscardedTransactionsHaveNoEffect(IDgraphClient client)
private async Task UnrelatedTransactionsDoNotConflict(IDgraphClient client)
{
-
- var txn1 = client.NewTransaction();
- var txn2 = client.NewTransaction();
+ using var txn1 = client.NewTransaction();
+ using var txn2 = client.NewTransaction();
var personTxn1 = MintAPerson("Alfred Name");
var personTxn2 = MintAPerson("Fank Person");
// Name has term and exact indexes, so these shouldn't clash
- var transactionResultTxn1 = await txn1.Mutate(new RequestBuilder().
- WithMutations(new MutationBuilder
- {
- SetJson = JsonConvert.SerializeObject(personTxn1)
- }));
+ var transactionResultTxn1 = await txn1.Mutate(
+ new MutationBuilder().SetJson(JsonConvert.SerializeObject(personTxn1))
+ );
AssertResultIsSuccess(transactionResultTxn1);
personTxn1.Uid = transactionResultTxn1.Value.Uids[personTxn1.Uid.Substring(2)];
- var transactionResultTxn2 = await txn2.Mutate(new RequestBuilder().
- WithMutations(new MutationBuilder
- {
- SetJson = JsonConvert.SerializeObject(personTxn2)
- }));
+ var transactionResultTxn2 = await txn2.Mutate(
+ new MutationBuilder().SetJson(JsonConvert.SerializeObject(personTxn2))
+ );
AssertResultIsSuccess(transactionResultTxn2);
personTxn2.Uid = transactionResultTxn2.Value.Uids[personTxn2.Uid.Substring(2)];
@@ -235,19 +212,15 @@ private async Task ConflictingTransactionsDontBothSucceed(IDgraphClient client)
var personTxn1 = MintAPerson("Bill Person");
var personTxn2 = MintAPerson("Jane Person");
- var transactionResultTxn1 = await txn1.Mutate(new RequestBuilder().
- WithMutations(new MutationBuilder
- {
- SetJson = JsonConvert.SerializeObject(personTxn1)
- }));
+ var transactionResultTxn1 = await txn1.Mutate(
+ new MutationBuilder().SetJson(JsonConvert.SerializeObject(personTxn1))
+ );
AssertResultIsSuccess(transactionResultTxn1);
personTxn1.Uid = transactionResultTxn1.Value.Uids[personTxn1.Uid.Substring(2)];
- var transactionResultTxn2 = await txn2.Mutate(new RequestBuilder().
- WithMutations(new MutationBuilder
- {
- SetJson = JsonConvert.SerializeObject(personTxn2)
- }));
+ var transactionResultTxn2 = await txn2.Mutate(
+ new MutationBuilder().SetJson(JsonConvert.SerializeObject(personTxn2))
+ );
AssertResultIsSuccess(transactionResultTxn2);
// Name has term and exact indexes, so these clash on 'Person' term
@@ -288,4 +261,4 @@ private Person MintAPerson(string name)
}
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests/Dgraph.tests.csproj b/source/Dgraph.tests/Dgraph.tests.csproj
index 759ecd3..65cbf04 100644
--- a/source/Dgraph.tests/Dgraph.tests.csproj
+++ b/source/Dgraph.tests/Dgraph.tests.csproj
@@ -9,13 +9,13 @@
-
-
+
+
-
-
-
-
+
+
+
+
diff --git a/source/Dgraph.tests/Transactions/BuilderFixture.cs b/source/Dgraph.tests/Transactions/BuilderFixture.cs
index 67f28b0..9edc294 100644
--- a/source/Dgraph.tests/Transactions/BuilderFixture.cs
+++ b/source/Dgraph.tests/Transactions/BuilderFixture.cs
@@ -13,8 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-using Dgraph.Transactions;
+
using FluentAssertions;
using Google.Protobuf;
using NUnit.Framework;
@@ -23,7 +22,6 @@ namespace Dgraph.tests.Transactions
{
public class BuilderFixture
{
-
[TestCase(null, null, null)]
[TestCase("query", null, null)]
[TestCase(null, true, null)]
@@ -35,11 +33,11 @@ public void MutationRequestsAreNeverReadonly(string query, bool? commit, bool wi
if (query != null)
{
- builder.Query = query;
+ builder.WithQuery(query);
}
if (commit != null)
{
- builder.CommitNow = commit.Value;
+ builder.CommitNow(commit.Value);
}
if (withMutation)
{
@@ -63,14 +61,14 @@ public void MutationRequestsPreservesArgs(string query, bool? commit, bool withM
if (query != null)
{
- builder.Query = query;
+ builder.WithQuery(query);
}
if (commit != null)
{
- builder.CommitNow = commit.Value;
+ builder.CommitNow(commit.Value);
}
- var mb = new MutationBuilder() { SetJson = "json" };
+ var mb = new MutationBuilder().SetJson("json");
if (withMutation)
{
builder.WithMutations(mb);
@@ -108,14 +106,12 @@ string cond
)
{
- var mb = new MutationBuilder
- {
- SetJson = setJson,
- SetNquads = setNQ,
- DeleteJson = deleteJson,
- DelNquads = deleteNQ,
- Cond = cond
- };
+ var mb = new MutationBuilder()
+ .SetJson(setJson)
+ .SetNquads(setNQ)
+ .DeleteJson(deleteJson)
+ .DelNquads(deleteNQ)
+ .Cond(cond);
mb.Mutation.Should().Be(
new Api.Mutation
@@ -129,4 +125,4 @@ string cond
);
}
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests/Transactions/ClientFixture.cs b/source/Dgraph.tests/Transactions/ClientFixture.cs
index 3394192..17bde60 100644
--- a/source/Dgraph.tests/Transactions/ClientFixture.cs
+++ b/source/Dgraph.tests/Transactions/ClientFixture.cs
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
namespace Dgraph.tests.Transactions
{
public class ClientFixture
@@ -31,4 +31,4 @@ public class ClientFixture
// }
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests/Transactions/CommitFixture.cs b/source/Dgraph.tests/Transactions/CommitFixture.cs
index 45b2497..0e10bc8 100644
--- a/source/Dgraph.tests/Transactions/CommitFixture.cs
+++ b/source/Dgraph.tests/Transactions/CommitFixture.cs
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
using System;
using System.Linq;
using System.Threading.Tasks;
@@ -33,7 +33,7 @@ public class CommitFixture : TransactionFixtureBase
public async Task Commit_SetsTransactionStateToCommitted()
{
var client = Substitute.For();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
await txn.Commit();
txn.TransactionState.Should().Be(TransactionState.Committed);
@@ -43,7 +43,7 @@ public async Task Commit_SetsTransactionStateToCommitted()
public async Task Commit_ClientNotReceiveCommitIfNoMutation()
{
var client = Substitute.For();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
await txn.Commit();
await client.DidNotReceive().DgraphExecute(
@@ -56,11 +56,11 @@ public async Task Commit_ClientReceivedCommitIfMutation()
{
(var client, _) = MinimalClient();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
var req = new RequestBuilder().
- WithMutations(new MutationBuilder { SetJson = "json" });
- await txn.Mutate(req);
+ WithMutations(new MutationBuilder().SetJson("json"));
+ await txn.Do(req);
await txn.Commit();
// FIXME: can't really test what the Dgraph got without
@@ -75,16 +75,16 @@ public async Task Commit_FailsOnException()
{
(var client, _) = MinimalClient();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
var req = new RequestBuilder().
- WithMutations(new MutationBuilder { SetJson = "json" });
- await txn.Mutate(req);
+ WithMutations(new MutationBuilder().SetJson("json"));
+ await txn.Do(req);
client.DgraphExecute(
Arg.Any>>(),
Arg.Any>()).Returns(
- Results.Fail(new ExceptionalError(
+ Result.Fail(new ExceptionalError(
new RpcException(new Status(), "Something failed"))));
var result = await txn.Commit();
@@ -95,4 +95,4 @@ public async Task Commit_FailsOnException()
}
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests/Transactions/DiscardFixture.cs b/source/Dgraph.tests/Transactions/DiscardFixture.cs
index 9cca1b6..da34af9 100644
--- a/source/Dgraph.tests/Transactions/DiscardFixture.cs
+++ b/source/Dgraph.tests/Transactions/DiscardFixture.cs
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
using System;
using System.Linq;
using System.Threading.Tasks;
@@ -26,7 +26,6 @@
namespace Dgraph.tests.Transactions
{
-
public class DiscardFixture : TransactionFixtureBase
{
@@ -34,7 +33,7 @@ public class DiscardFixture : TransactionFixtureBase
public async Task Discard_SetsTransactionStateToAborted()
{
var client = Substitute.For();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
await txn.Discard();
txn.TransactionState.Should().Be(TransactionState.Aborted);
@@ -44,7 +43,7 @@ public async Task Discard_SetsTransactionStateToAborted()
public async Task Discard_ClientNotReceiveDiscardIfNoMutation()
{
var client = Substitute.For();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
await txn.Discard();
await client.DidNotReceive().DgraphExecute(
@@ -57,11 +56,11 @@ public async Task Discard_ClientReceivedDiscardIfMutation()
{
(var client, _) = MinimalClient();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
var req = new RequestBuilder().
- WithMutations(new MutationBuilder { SetJson = "json" });
- await txn.Mutate(req);
+ WithMutations(new MutationBuilder().SetJson("json"));
+ await txn.Do(req);
await txn.Discard();
await client.Received().DgraphExecute(
@@ -74,16 +73,16 @@ public async Task Discard_FailsOnException()
{
(var client, _) = MinimalClient();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
var req = new RequestBuilder().
- WithMutations(new MutationBuilder { SetJson = "json" });
- await txn.Mutate(req);
+ WithMutations(new MutationBuilder().SetJson("json"));
+ await txn.Do(req);
client.DgraphExecute(
Arg.Any>>(),
Arg.Any>()).Returns(
- Results.Fail(new ExceptionalError(new RpcException(new Status(), "Something failed"))));
+ Result.Fail(new ExceptionalError(new RpcException(new Status(), "Something failed"))));
var result = await txn.Discard();
result.IsFailed.Should().BeTrue();
@@ -93,4 +92,4 @@ public async Task Discard_FailsOnException()
}
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests/Transactions/IQueryFixture.cs b/source/Dgraph.tests/Transactions/IQueryFixture.cs
index 22dc333..ccfa0a3 100644
--- a/source/Dgraph.tests/Transactions/IQueryFixture.cs
+++ b/source/Dgraph.tests/Transactions/IQueryFixture.cs
@@ -45,7 +45,7 @@ public class IQueryFixture : TransactionFixtureBase
public async Task Query_PassesBackResult()
{
(var client, var response) = MinimalClient();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
response.DgraphResponse.Json = ByteString.CopyFromUtf8("json");
// ??ByteString.CopyFrom(Encoding.UTF8.GetBytes(json));
@@ -53,7 +53,7 @@ public async Task Query_PassesBackResult()
client.DgraphExecute(
Arg.Any>>>(),
Arg.Any>>()).Returns(
- Results.Ok(response));
+ Result.Ok(response));
var result = await txn.QueryWithVars(
"query",
@@ -70,9 +70,10 @@ public async Task Query_FailsIfError()
client.DgraphExecute(
Arg.Any>>>(),
Arg.Any>>()).Returns(
- Results.Fail(new ExceptionalError(new RpcException(new Status(), "Something failed"))));
+ Result.Fail(new ExceptionalError(new RpcException(new Status(), "Something failed"))));
- var result = await (new Transaction(client)).Query("throw");
+ ITransaction txn = new Transaction(client);
+ var result = await txn.Query("throw");
result.IsFailed.Should().Be(true);
result.Errors.First().Should().BeOfType();
@@ -86,9 +87,9 @@ public async Task Query_FailDoesntChangeTransactionOKState()
client.DgraphExecute(
Arg.Any>>>(),
Arg.Any>>()).Returns(
- Results.Fail(new ExceptionalError(new RpcException(new Status(), "Something failed"))));
+ Result.Fail(new ExceptionalError(new RpcException(new Status(), "Something failed"))));
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
var result = await txn.Query("throw");
txn.TransactionState.Should().Be(TransactionState.OK);
@@ -98,7 +99,7 @@ public async Task Query_FailDoesntChangeTransactionOKState()
public async Task Query_SuccessDoesntChangeTransactionOKState()
{
(var client, var response) = MinimalClient();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
await txn.QueryWithVars(
"query",
@@ -108,4 +109,4 @@ await txn.QueryWithVars(
}
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests/Transactions/MutateFixture.cs b/source/Dgraph.tests/Transactions/MutateFixture.cs
index 9632244..b73398a 100644
--- a/source/Dgraph.tests/Transactions/MutateFixture.cs
+++ b/source/Dgraph.tests/Transactions/MutateFixture.cs
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
using System;
using System.Collections.Generic;
using System.Linq;
@@ -28,18 +28,16 @@
namespace Dgraph.tests.Transactions
{
-
public class MutateFixture : TransactionFixtureBase
{
-
[Test]
public async Task Mutate_EmptyMutationDoesNothing()
{
(var client, _) = MinimalClient();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
var req = new RequestBuilder();
- await txn.Mutate(req);
+ await txn.Do(req);
await client.DidNotReceive().DgraphExecute(
Arg.Any>>>(),
@@ -51,13 +49,10 @@ await client.DidNotReceive().DgraphExecute(
public async Task Mutate_CommitNowChangesStateToCommitted()
{
(var client, _) = MinimalClient();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
- var req = new RequestBuilder()
- {
- CommitNow = true
- }.WithMutations(new MutationBuilder { SetJson = "json" });
- await txn.Mutate(req);
+ var mu = new MutationBuilder().CommitNow().SetJson("json");
+ await txn.Mutate(mu);
txn.TransactionState.Should().Be(TransactionState.Committed);
}
@@ -73,18 +68,18 @@ public async Task Mutate_FailsOnException()
{
(var client, _) = MinimalClient();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
var req = new RequestBuilder().
- WithMutations(new MutationBuilder { SetJson = "json" });
- await txn.Mutate(req);
+ WithMutations(new MutationBuilder().SetJson("json"));
+ await txn.Do(req);
client.DgraphExecute(
Arg.Any>>>(),
Arg.Any>>()).Returns(
- Results.Fail(new ExceptionalError(new RpcException(new Status(), "Something failed"))));
+ Result.Fail(new ExceptionalError(new RpcException(new Status(), "Something failed"))));
- var result = await txn.Mutate(req);
+ var result = await txn.Do(req);
result.IsFailed.Should().Be(true);
result.Errors.First().Should().BeOfType();
@@ -95,7 +90,7 @@ public async Task Mutate_FailsOnException()
public async Task Mutate_PassesBackResult()
{
(var client, var assigned) = MinimalClient();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
var response = new Api.Response() { Json = ByteString.CopyFromUtf8("json") };
response.Uids.Add(new Dictionary { { "node1", "0x1" } });
@@ -103,16 +98,16 @@ public async Task Mutate_PassesBackResult()
client.DgraphExecute(
Arg.Any>>>(),
Arg.Any>>()).Returns(
- Results.Ok(new Response(response)));
+ Result.Ok(new Response(response)));
var req = new RequestBuilder().
- WithMutations(new MutationBuilder { SetJson = "json" });
- await txn.Mutate(req);
- var result = await txn.Mutate(req);
+ WithMutations(new MutationBuilder().SetJson("json"));
+ await txn.Do(req);
+ var result = await txn.Do(req);
result.IsSuccess.Should().BeTrue();
result.Value.DgraphResponse.Should().BeEquivalentTo(response);
}
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests/Transactions/TransactionFixture.cs b/source/Dgraph.tests/Transactions/TransactionFixture.cs
index bd990c5..cddba61 100644
--- a/source/Dgraph.tests/Transactions/TransactionFixture.cs
+++ b/source/Dgraph.tests/Transactions/TransactionFixture.cs
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
using System;
using System.Threading.Tasks;
using Dgraph.Transactions;
@@ -32,7 +32,7 @@ public class TransactionFixture : TransactionFixtureBase
public async Task All_FailIfAlreadyCommitted()
{
var client = Substitute.For();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
await txn.Commit();
var tests = GetAllTestFunctions(txn);
@@ -48,7 +48,7 @@ public async Task All_FailIfAlreadyCommitted()
public async Task All_FailIfDiscarded()
{
var client = Substitute.For();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
await txn.Discard();
var tests = GetAllTestFunctions(txn);
@@ -61,17 +61,17 @@ public async Task All_FailIfDiscarded()
}
[Test]
- public void All_ExceptionIfDisposed()
+ public async Task All_ExceptionIfDisposed()
{
var client = Substitute.For();
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
txn.Dispose();
var tests = GetAllTestFunctions(txn);
foreach (var test in tests)
{
- test.Should().Throw();
+ await test.Should().ThrowAsync();
}
}
@@ -83,13 +83,13 @@ public async Task All_FailIfTransactionError()
client.DgraphExecute(
Arg.Any>>>(),
Arg.Any>>()).Returns(
- Results.Fail(new ExceptionalError(
+ Result.Fail(new ExceptionalError(
new RpcException(new Status(), "Something failed"))));
- var txn = new Transaction(client);
+ ITransaction txn = new Transaction(client);
var req = new RequestBuilder().
- WithMutations(new MutationBuilder { SetJson = "json" });
- await txn.Mutate(req);
+ WithMutations(new MutationBuilder().SetJson("json"));
+ await txn.Do(req);
var tests = GetAllTestFunctions(txn);
@@ -101,4 +101,4 @@ public async Task All_FailIfTransactionError()
}
}
-}
\ No newline at end of file
+}
diff --git a/source/Dgraph.tests/Transactions/TransactionFixtureBase.cs b/source/Dgraph.tests/Transactions/TransactionFixtureBase.cs
index 20d2da9..50e62b7 100644
--- a/source/Dgraph.tests/Transactions/TransactionFixtureBase.cs
+++ b/source/Dgraph.tests/Transactions/TransactionFixtureBase.cs
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -26,7 +26,6 @@ namespace Dgraph.tests.Transactions
{
public class TransactionFixtureBase
{
-
internal (IDgraphClientInternal, Response) MinimalClient()
{
var client = Substitute.For();
@@ -36,18 +35,18 @@ public class TransactionFixtureBase
var response = new Response(dgResp);
client.DgraphExecute(
Arg.Any>>>(),
- Arg.Any>>()).Returns(Results.Ok(response));
+ Arg.Any>>()).Returns(Result.Ok(response));
return (client, response);
}
protected List>> GetAllTestFunctions(ITransaction txn) =>
new List>> {
- async () => await txn.Mutate(new RequestBuilder().
- WithMutations(new MutationBuilder{ SetJson = "json" })),
+ async () => await txn.Do(new RequestBuilder().
+ WithMutations(new MutationBuilder().SetJson("json"))),
async () => await txn.Query("query"),
async () => await txn.QueryWithVars("query", null),
async () => await txn.Commit()
};
}
-}
\ No newline at end of file
+}