Skip to content

Commit a0ec1aa

Browse files
committed
fix failing unit tests because serilization setup is ran before usage initialized
1 parent 8b71b98 commit a0ec1aa

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Tests/Framework/ApiTestBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected virtual void OnAfterCall(IElasticClient client) { }
4545
protected abstract string UrlPath { get; }
4646
protected abstract HttpMethod HttpMethod { get; }
4747

48-
protected ApiTestBase(IIntegrationCluster cluster, EndpointUsage usage)
48+
protected ApiTestBase(IIntegrationCluster cluster, EndpointUsage usage) : base(cluster)
4949
{
5050
this._usage = usage;
5151
this.Cluster = cluster;
@@ -83,9 +83,9 @@ Func<IElasticClient, TInitializer, Task<TResponse>> requestAsync
8383
if (TestClient.Configuration.RunIntegrationTests)
8484
{
8585
this.IntegrationSetup(client, _uniqueValues);
86+
this._usage.CalledSetup = true;
8687
}
8788

88-
this._usage.CalledSetup = true;
8989

9090
var dict = new Dictionary<ClientMethod, IResponse>();
9191
_uniqueValues.CurrentView = ClientMethod.Fluent;

src/Tests/Framework/SerializationTestBase.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using FluentAssertions;
77
using Nest;
88
using Newtonsoft.Json.Linq;
9+
using Tests.Framework.Integration;
910

1011
namespace Tests.Framework
1112
{
@@ -24,6 +25,11 @@ protected SerializationTestBase()
2425
SetupSerialization();
2526
}
2627

28+
protected SerializationTestBase(IIntegrationCluster cluster)
29+
{
30+
}
31+
32+
2733
protected void SetupSerialization()
2834
{
2935
var o = this.ExpectJson;
@@ -125,10 +131,10 @@ protected T AssertSerializesAndRoundTrips<T>(T o)
125131
//first serialize to string and assert it looks like this.ExpectedJson
126132
string serialized;
127133
if (!this.SerializesAndMatches(o, iteration, out serialized)) return default(T);
128-
134+
129135
if (!this.SupportsDeserialization) return default(T);
130136

131-
//deserialize serialized json back again
137+
//deserialize serialized json back again
132138
var oAgain = this.Deserialize<T>(serialized);
133139
//now use deserialized `o` and serialize again making sure
134140
//it still looks like this.ExpectedJson

0 commit comments

Comments
 (0)