Skip to content

Commit de00d64

Browse files
committed
[ECO-5624] Removed fluentassertions dependency from tests
- Updated test assertions to support native NUnit asserts - Updated PlayMode.asmdef to exclude WebGL
1 parent 3b2765c commit de00d64

File tree

14 files changed

+232
-244
lines changed

14 files changed

+232
-244
lines changed

cake-build/tasks/build.cake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ Task("_Build_Ably_Unity_Dll")
147147
var unityOutputPath = paths.Root.Combine("unity/Assets/Ably/Plugins");
148148
var outputDll = unityOutputPath.CombineWithFilePath("IO.Ably.dll");
149149

150+
// Delete existing output DLL if it exists
151+
if (FileExists(outputDll))
152+
{
153+
DeleteFile(outputDll);
154+
Information($"Deleted existing DLL: {outputDll}");
155+
}
156+
150157
// Merge all dependencies into primary DLL in one go
151158
ilRepackHelper.MergeDLLs(primaryDll, dllsToMerge, outputDll);
152159

0 Bytes
Binary file not shown.

unity/Assets/Tests/EditMode/AblyInterfaceSpecs.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Threading;
99
using Assets.Tests.AblySandbox;
1010
using Cysharp.Threading.Tasks;
11-
using FluentAssertions;
1211
using IO.Ably;
1312
using IO.Ably.Realtime;
1413
using NUnit.Framework;
@@ -222,11 +221,11 @@ public IEnumerator TestHttpUnityAgentHeader([ValueSource(nameof(_protocols))] Pr
222221

223222
await client.Execute(new AblyRequest("/test", HttpMethod.Get));
224223
string[] values = handler.LastRequest.Headers.GetValues("Ably-Agent").ToArray();
225-
values.Should().HaveCount(1);
224+
Assert.AreEqual(1, values.Length);
226225
string[] agentValues = values[0].Split(' ');
227226

228-
Agent.OsIdentifier().Should().StartWith("unity-");
229-
Agent.UnityPlayerIdentifier().Should().StartWith("unity/");
227+
Assert.IsTrue(Agent.OsIdentifier().StartsWith("unity-"));
228+
Assert.IsTrue(Agent.UnityPlayerIdentifier().StartsWith("unity/"));
230229

231230
var keys = new List<string>()
232231
{
@@ -236,14 +235,14 @@ public IEnumerator TestHttpUnityAgentHeader([ValueSource(nameof(_protocols))] Pr
236235
Agent.OsIdentifier()
237236
};
238237

239-
Agent.DotnetRuntimeIdentifier().Split('/').Length.Should().Be(2);
238+
Assert.AreEqual(2, Agent.DotnetRuntimeIdentifier().Split('/').Length);
240239

241240
keys.RemoveAll(s => s.IsEmpty());
242241

243-
agentValues.Should().HaveCount(keys.Count);
242+
Assert.AreEqual(keys.Count, agentValues.Length);
244243
for (var i = 0; i < keys.Count; ++i)
245244
{
246-
agentValues[i].StartsWith(keys[i]).Should().BeTrue($"'{agentValues[i]}' should start with '{keys[i]}'");
245+
Assert.IsTrue(agentValues[i].StartsWith(keys[i]), $"'{agentValues[i]}' should start with '{keys[i]}'");
247246
}
248247
});
249248
}

unity/Assets/Tests/EditMode/AuthSandboxSpecs.cs

Lines changed: 83 additions & 84 deletions
Large diffs are not rendered by default.

unity/Assets/Tests/EditMode/EditMode.asmdef

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"references": [
55
"UnityEngine.TestRunner",
66
"UnityEditor.TestRunner",
7-
"BoundfoxStudios.FluentAssertions",
87
"UniTask",
98
"Unity.Assets.Tests.AblySandbox"
109
],

unity/Assets/Tests/EditMode/StatsSandBoxSpecs.cs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Threading.Tasks;
66
using Assets.Tests.AblySandbox;
77
using Cysharp.Threading.Tasks;
8-
using FluentAssertions;
98
using IO.Ably;
109
using NUnit.Framework;
1110
using UnityEngine.TestTools;
@@ -68,28 +67,28 @@ async Task GetAndValidateStats()
6867
{
6968
var allStats = await GetStats(protocol);
7069
var stats = allStats.First();
71-
stats.All.Messages.Count.Should().Be(40 + 70);
72-
stats.All.Messages.Data.Should().Be(4000 + 7000);
73-
stats.Inbound.Realtime.All.Count.Should().Be(70);
74-
stats.Inbound.Realtime.All.Data.Should().Be(7000);
75-
stats.Inbound.Realtime.Messages.Count.Should().Be(70);
76-
stats.Inbound.Realtime.Messages.Data.Should().Be(7000);
77-
stats.Outbound.Realtime.All.Count.Should().Be(40);
78-
stats.Outbound.Realtime.All.Data.Should().Be(4000);
79-
stats.Persisted.Presence.Count.Should().Be(20);
80-
stats.Persisted.Presence.Data.Should().Be(2000);
81-
stats.Connections.Tls.Peak.Should().Be(20);
82-
stats.Connections.Tls.Opened.Should().Be(10);
83-
stats.Channels.Peak.Should().Be(50);
84-
stats.Channels.Opened.Should().Be(30);
85-
stats.ApiRequests.Succeeded.Should().Be(50);
86-
stats.ApiRequests.Failed.Should().Be(10);
87-
stats.TokenRequests.Succeeded.Should().Be(60);
88-
stats.TokenRequests.Failed.Should().Be(20);
70+
Assert.AreEqual(40 + 70, stats.All.Messages.Count);
71+
Assert.AreEqual(4000 + 7000, stats.All.Messages.Data);
72+
Assert.AreEqual(70, stats.Inbound.Realtime.All.Count);
73+
Assert.AreEqual(7000, stats.Inbound.Realtime.All.Data);
74+
Assert.AreEqual(70, stats.Inbound.Realtime.Messages.Count);
75+
Assert.AreEqual(7000, stats.Inbound.Realtime.Messages.Data);
76+
Assert.AreEqual(40, stats.Outbound.Realtime.All.Count);
77+
Assert.AreEqual(4000, stats.Outbound.Realtime.All.Data);
78+
Assert.AreEqual(20, stats.Persisted.Presence.Count);
79+
Assert.AreEqual(2000, stats.Persisted.Presence.Data);
80+
Assert.AreEqual(20, stats.Connections.Tls.Peak);
81+
Assert.AreEqual(10, stats.Connections.Tls.Opened);
82+
Assert.AreEqual(50, stats.Channels.Peak);
83+
Assert.AreEqual(30, stats.Channels.Opened);
84+
Assert.AreEqual(50, stats.ApiRequests.Succeeded);
85+
Assert.AreEqual(10, stats.ApiRequests.Failed);
86+
Assert.AreEqual(60, stats.TokenRequests.Succeeded);
87+
Assert.AreEqual(20, stats.TokenRequests.Failed);
8988
}
9089

9190
await AblySandbox.AssertWithRetries(GetAndValidateStats, 5, TimeSpan.FromSeconds(5));
9291
});
9392
}
9493
}
95-
}
94+
}

unity/Assets/Tests/PlayMode/AblyInterfaceSpecs.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Net;
66
using Assets.Tests.AblySandbox;
77
using Cysharp.Threading.Tasks;
8-
using FluentAssertions;
98
using IO.Ably;
109
using IO.Ably.Realtime;
1110
using NUnit.Framework;
@@ -219,11 +218,11 @@ public IEnumerator TestHttpUnityAgentHeader([ValueSource(nameof(_protocols))] Pr
219218

220219
await client.Execute(new AblyRequest("/test", HttpMethod.Get));
221220
string[] values = handler.LastRequest.Headers.GetValues("Ably-Agent").ToArray();
222-
values.Should().HaveCount(1);
221+
Assert.AreEqual(1, values.Length);
223222
string[] agentValues = values[0].Split(' ');
224223

225-
Agent.OsIdentifier().Should().StartWith("unity-");
226-
Agent.UnityPlayerIdentifier().Should().StartWith("unity/");
224+
Assert.IsTrue(Agent.OsIdentifier().StartsWith("unity-"));
225+
Assert.IsTrue(Agent.UnityPlayerIdentifier().StartsWith("unity/"));
227226

228227
var keys = new List<string>()
229228
{
@@ -233,14 +232,14 @@ public IEnumerator TestHttpUnityAgentHeader([ValueSource(nameof(_protocols))] Pr
233232
Agent.OsIdentifier()
234233
};
235234

236-
Agent.DotnetRuntimeIdentifier().Split('/').Length.Should().Be(2);
235+
Assert.AreEqual(2, Agent.DotnetRuntimeIdentifier().Split('/').Length);
237236

238237
keys.RemoveAll(s => s.IsEmpty());
239238

240-
agentValues.Should().HaveCount(keys.Count);
239+
Assert.AreEqual(keys.Count, agentValues.Length);
241240
for (var i = 0; i < keys.Count; ++i)
242241
{
243-
agentValues[i].StartsWith(keys[i]).Should().BeTrue($"'{agentValues[i]}' should start with '{keys[i]}'");
242+
Assert.IsTrue(agentValues[i].StartsWith(keys[i]), $"'{agentValues[i]}' should start with '{keys[i]}'");
244243
}
245244
});
246245
}
@@ -252,4 +251,4 @@ private static void AssertResultOk(Result result)
252251
Assert.Null(result.Error);
253252
}
254253
}
255-
}
254+
}

0 commit comments

Comments
 (0)