diff --git a/Archipelago.MultiClient.Net.Tests/Archipelago.MultiClient.Net.Tests.csproj b/Archipelago.MultiClient.Net.Tests/Archipelago.MultiClient.Net.Tests.csproj
index 60a00dd..1f1f85a 100644
--- a/Archipelago.MultiClient.Net.Tests/Archipelago.MultiClient.Net.Tests.csproj
+++ b/Archipelago.MultiClient.Net.Tests/Archipelago.MultiClient.Net.Tests.csproj
@@ -36,7 +36,7 @@
- ..\DLLs\net35\Newtonsoft.Json.dll
+ ..\DLLs\net40\Newtonsoft.Json.dll
@@ -52,7 +52,7 @@
- ..\DLLs\net35\Newtonsoft.Json.dll
+ ..\DLLs\net45\Newtonsoft.Json.dll
diff --git a/Archipelago.MultiClient.Net.Tests/ArchipelagoSessionFixture.cs b/Archipelago.MultiClient.Net.Tests/ArchipelagoSessionFixture.cs
index fe86a10..54edfdf 100644
--- a/Archipelago.MultiClient.Net.Tests/ArchipelagoSessionFixture.cs
+++ b/Archipelago.MultiClient.Net.Tests/ArchipelagoSessionFixture.cs
@@ -1,4 +1,4 @@
-using Archipelago.MultiClient.Net.Cache;
+using Archipelago.MultiClient.Net.DataPackage;
using Archipelago.MultiClient.Net.Enums;
using Archipelago.MultiClient.Net.Helpers;
using Archipelago.MultiClient.Net.Models;
@@ -65,7 +65,7 @@ public void Should_send_connect_after_retrieving_data_package()
var session = CreateTestSession(socket, fileSystemDataPackageProvider);
- SetupRoomInfoPacket(socket, new RoomInfoPacket { Games = Array.Empty() });
+ SetupRoomInfoPacket(socket, new RoomInfoPacket { Games = new []{ "Game1" } });
SetupLoginResultPacket(socket, new ConnectionRefusedPacket());
var result = session.TryConnectAndLogin("", "", ItemsHandlingFlags.NoItems);
@@ -142,17 +142,57 @@ public void Should_add_correct_properties_to_login_successful()
Assert.That(successful.Team, Is.EqualTo(3));
}
+ [Test]
+ public void Should_say_text()
+ {
+ var socket = Substitute.For();
+ var fileSystemDataPackageProvider = Substitute.For();
+
+ var session = CreateTestSession(socket, fileSystemDataPackageProvider);
+
+ session.Say("!message for server");
+
+ socket.Received().SendPacket(Arg.Is(p => p.Text == "!message for server"));
+ }
+
+ [Test]
+ public void Should_update_client_status()
+ {
+ var socket = Substitute.For();
+ var fileSystemDataPackageProvider = Substitute.For();
+
+ var session = CreateTestSession(socket, fileSystemDataPackageProvider);
+
+ session.SetClientState(ArchipelagoClientState.ClientReady);
+
+ socket.Received().SendPacket(Arg.Is(p => p.Status == ArchipelagoClientState.ClientReady));
+ }
+
+ [Test]
+ public void Should_update_client_goal()
+ {
+ var socket = Substitute.For();
+ var fileSystemDataPackageProvider = Substitute.For();
+
+ var session = CreateTestSession(socket, fileSystemDataPackageProvider);
+
+ session.SetGoalAchieved();
+
+ socket.Received().SendPacket(Arg.Is(p => p.Status == ArchipelagoClientState.ClientGoal));
+ }
+
static ArchipelagoSession CreateTestSession(IArchipelagoSocketHelper socket,
IFileSystemDataPackageProvider fileSystemDataPackageProvider)
{
var dataPackageCache = new DataPackageCache(socket, fileSystemDataPackageProvider);
- var locations = new LocationCheckHelper(socket, dataPackageCache);
- var items = new ReceivedItemsHelper(socket, locations, dataPackageCache);
var connectionInfo = new ConnectionInfoHelper(socket);
+ var itemInfoResolver = new ItemInfoResolver(dataPackageCache, connectionInfo);
var players = new PlayerHelper(socket, connectionInfo);
+ var locations = new LocationCheckHelper(socket, itemInfoResolver, connectionInfo, players);
+ var items = new ReceivedItemsHelper(socket, locations, itemInfoResolver, connectionInfo, players);
var roomState = new RoomStateHelper(socket, locations);
var dataStorage = new DataStorageHelper(socket, connectionInfo);
- var messageLog = new MessageLogHelper(socket, items, locations, players, connectionInfo);
+ var messageLog = new MessageLogHelper(socket, itemInfoResolver, players, connectionInfo);
return new ArchipelagoSession(socket, items, locations, players, roomState, connectionInfo, dataStorage, messageLog);
}
diff --git a/Archipelago.MultiClient.Net.Tests/DataPackageFileSystemCacheFixture.cs b/Archipelago.MultiClient.Net.Tests/DataPackageFileSystemCacheFixture.cs
index 9c62519..9c9bbb8 100644
--- a/Archipelago.MultiClient.Net.Tests/DataPackageFileSystemCacheFixture.cs
+++ b/Archipelago.MultiClient.Net.Tests/DataPackageFileSystemCacheFixture.cs
@@ -1,4 +1,4 @@
-using Archipelago.MultiClient.Net.Cache;
+using Archipelago.MultiClient.Net.DataPackage;
using Archipelago.MultiClient.Net.Helpers;
using Archipelago.MultiClient.Net.Models;
using Archipelago.MultiClient.Net.Packets;
@@ -11,8 +11,7 @@ namespace Archipelago.MultiClient.Net.Tests
{
//use Directory C:\Users\\AppData\Local\Archipelago\Cache\\.json
//retention 1 month since last modified, update File.SetLastWriteTime(file, modifiedTime) in use
-
-
+
[TestFixture]
public class DataPackageFileSystemCacheFixture
{
@@ -58,7 +57,7 @@ public void Should_request_data_package_when_no_local_cache_is_available()
[Test]
public void Should_not_request_data_when_local_contains_a_file_with_same_checksum()
{
- var localDataPackage = new DataPackage {
+ var localDataPackage = new Models.DataPackage {
Games = new Dictionary {
{ "One", new TestGameData("3") },
{ "Two", new TestGameData("4") },
@@ -94,7 +93,7 @@ public void Should_not_request_data_when_local_contains_a_file_with_same_checksu
[Test]
public void Should_only_request_data_for_games_that_a_have_different_checksum_then_cached()
{
- var localDataPackage = new DataPackage
+ var localDataPackage = new Models.DataPackage
{
Games = new Dictionary {
{ "One", new TestGameData("3") },
@@ -137,7 +136,7 @@ public void Should_only_request_data_for_games_that_a_have_different_checksum_th
public void Should_save_received_datapackage_contents()
{
var serverDataPackage = new DataPackagePacket {
- DataPackage = new DataPackage {
+ DataPackage = new Models.DataPackage {
Games = new Dictionary {
{
"One", new GameData {
@@ -175,7 +174,7 @@ public void Should_save_received_datapackage_contents()
[Test]
public void Should_merge_received_datapackage_with_cached_version()
{
- var localDataPackage = new DataPackage
+ var localDataPackage = new Models.DataPackage
{
Games = new Dictionary {
{ "One", new TestGameData("1") },
@@ -197,7 +196,7 @@ public void Should_merge_received_datapackage_with_cached_version()
var serverDataPackage = new DataPackagePacket
{
- DataPackage = new DataPackage
+ DataPackage = new Models.DataPackage
{
Games = new Dictionary {
{ "Two", new TestGameData("6") }
@@ -220,16 +219,16 @@ public void Should_merge_received_datapackage_with_cached_version()
sut.TryGetDataPackageFromCache(out var inMemoryDataPackage);
- Assert.IsTrue(inMemoryDataPackage.Games.Count == 3
- && inMemoryDataPackage.Games["One"].Checksum == "1"
- && inMemoryDataPackage.Games["Two"].Checksum == "6"
- && inMemoryDataPackage.Games["Archipelago"].Checksum == "3");
+ Assert.IsTrue(inMemoryDataPackage.Count == 3
+ && inMemoryDataPackage["One"].Checksum == "1"
+ && inMemoryDataPackage["Two"].Checksum == "6"
+ && inMemoryDataPackage["Archipelago"].Checksum == "3");
}
[Test]
public void Should_request_data_package_for_games_the_server_fails_to_send_the_version_for()
{
- var localDataPackage = new DataPackage
+ var localDataPackage = new Models.DataPackage
{
Games = new Dictionary {
{ "One", new TestGameData("1") },
@@ -263,7 +262,89 @@ public void Should_request_data_package_for_games_the_server_fails_to_send_the_v
));
}
- class TestGameData : GameData
+
+ [Test]
+ public void Should_allow_overlapping_ids()
+ {
+ var localDataPackage = new Models.DataPackage
+ {
+ Games = new Dictionary {
+ { "One", new TestGameData("1") },
+ { "Two", new TestGameData("3") },
+ { "Archipelago", new TestGameData("3") },
+ }
+ };
+
+ var roomInfo = new RoomInfoPacket
+ {
+ Version = new NetworkVersion(0, 4, 0),
+ Games = new[] { "One", "Two", "Archipelago" },
+ DataPackageChecksums = new Dictionary {
+ { "One", "2" },
+ { "Two", "1" },
+ { "Archipelago", "3" }
+ }
+ };
+
+ var serverDataPackage = new DataPackagePacket
+ {
+ DataPackage = new Models.DataPackage
+ {
+ Games = new Dictionary {
+ { "One", new TestGameData("2") {
+ ItemLookup = new Dictionary {
+ { "GameOneItem", 20 },
+ { "DuplicatedName", 15 }
+ },
+ LocationLookup = new Dictionary {
+ { "GameOneLocation", 20 },
+ { "DuplicatedName", 15 }
+ }
+ }},
+ { "Two", new TestGameData("1") {
+ ItemLookup = new Dictionary {
+ { "GameTwoItem", 20 },
+ { "DuplicatedName", 30 }
+ },
+ LocationLookup = new Dictionary {
+ { "GameTwoLocation", 20 },
+ { "DuplicatedName", 15 }
+ }
+ }}
+ }
+ }
+ };
+
+ var socket = Substitute.For();
+ var fileSystemDataPackageProvider = Substitute.For();
+ fileSystemDataPackageProvider.TryGetDataPackage("", "", out _)
+ .ReturnsForAnyArgs(x => {
+ x[2] = localDataPackage.Games[x.ArgAt(0)];
+ return true;
+ });
+
+ var sut = new DataPackageCache(socket, fileSystemDataPackageProvider);
+
+ socket.PacketReceived += Raise.Event(roomInfo);
+ socket.PacketReceived += Raise.Event(serverDataPackage);
+
+ sut.TryGetDataPackageFromCache(out var inMemoryDataPackage);
+
+ Assert.IsTrue(inMemoryDataPackage.Count == 3
+ && inMemoryDataPackage["One"].Checksum == "2"
+ && inMemoryDataPackage["One"].Items["GameOneItem"] == 20
+ && inMemoryDataPackage["One"].Items["DuplicatedName"] == 15
+ && inMemoryDataPackage["One"].Locations["GameOneLocation"] == 20
+ && inMemoryDataPackage["One"].Locations["DuplicatedName"] == 15
+ && inMemoryDataPackage["Two"].Checksum == "1"
+ && inMemoryDataPackage["Two"].Items["GameTwoItem"] == 20
+ && inMemoryDataPackage["Two"].Items["DuplicatedName"] == 30
+ && inMemoryDataPackage["Two"].Locations["GameTwoLocation"] == 20
+ && inMemoryDataPackage["Two"].Locations["DuplicatedName"] == 15
+ && inMemoryDataPackage["Archipelago"].Checksum == "3");
+ }
+
+ class TestGameData : GameData
{
public TestGameData(string checksum)
{
diff --git a/Archipelago.MultiClient.Net.Tests/DataPackageFileSystemCacheFixture_version_based.cs b/Archipelago.MultiClient.Net.Tests/DataPackageFileSystemCacheFixture_version_based.cs
deleted file mode 100644
index cb0e45f..0000000
--- a/Archipelago.MultiClient.Net.Tests/DataPackageFileSystemCacheFixture_version_based.cs
+++ /dev/null
@@ -1,378 +0,0 @@
-using Archipelago.MultiClient.Net.Cache;
-using Archipelago.MultiClient.Net.Helpers;
-using Archipelago.MultiClient.Net.Models;
-using Archipelago.MultiClient.Net.Packets;
-using NSubstitute;
-using NUnit.Framework;
-using System;
-using System.Collections.Generic;
-
-namespace Archipelago.MultiClient.Net.Tests
-{
- //use Directory C:\Users\current_user\AppData\Local\Archipelago\Cache
- //retention 1 month since last moddified, update File.SetLastWriteTime(file, modifiedTime) in use
-
-
- [TestFixture]
- public class DataPackageFileSystemCacheFixture_version_based
- {
- [Test]
- public void Should_use_version_based_file_system_provider()
- {
- var socket = Substitute.For();
-
- var sut = new DataPackageCache(socket);
-
- socket.PacketReceived += Raise.Event(new RoomInfoPacket
- {
- Version = new NetworkVersion(0, 3, 7),
- Games = Array.Empty()
- });
-
- Assert.That(sut.FileSystemDataPackageProvider, Is.InstanceOf());
- }
-
-
- [Test]
- public void Should_request_data_package_when_no_local_cache_is_available()
- {
- var socket = Substitute.For();
- var fileSystemDataPackageProvider = Substitute.For();
- fileSystemDataPackageProvider.TryGetDataPackage(Arg.Any(), "", out _)
- .Returns(x =>
- {
- x[2] = null;
- return false;
- });
-
- _ = new DataPackageCache(socket, fileSystemDataPackageProvider);
-
- socket.PacketReceived += Raise.Event(new RoomInfoPacket {
- Version = new NetworkVersion(0, 3, 7),
- Games = new []{ "One" }
- });
-
- socket.Received().SendPacket(Arg.Is(p =>
- p.Games.Length == 2 && p.Games[0] == "One" && p.Games[1] == "Archipelago"
- ));
- }
-
- [Test]
- public void Should_request_updates_for_archipelago_even_if_its_being_played()
- {
- var localDataPackage = new DataPackage
- {
- Games = new Dictionary {
- { "One", new TestGameData(1) },
- { "Archipelago", new TestGameData(1) }
- }
- };
-
- var roomInfo = new RoomInfoPacket
- {
- Version = new NetworkVersion(0, 3, 7),
- Games = new[] { "One" },
- DataPackageVersions = new Dictionary {
- { "One", 1 },
- { "Archipelago", 2 }
- }
- };
-
- var socket = Substitute.For();
- var fileSystemDataPackageProvider = Substitute.For();
- fileSystemDataPackageProvider.TryGetDataPackage(Arg.Any(), "", out _)
- .Returns(x => {
- x[2] = localDataPackage.Games[x.ArgAt(0)];
- return true;
- });
-
- _ = new DataPackageCache(socket, fileSystemDataPackageProvider);
-
- socket.PacketReceived += Raise.Event(roomInfo);
-
- socket.Received().SendPacket(Arg.Is(p =>
- p.Games.Length == 1 && p.Games[0] == "Archipelago"
- ));
- }
-
- [Test]
- public void Should_not_request_data_when_local_version_is_same_as_server_version()
- {
- var localDataPackage = new DataPackage {
- Games = new Dictionary {
- { "One", new TestGameData(3) },
- { "Two", new TestGameData(4) },
- { "Archipelago", new TestGameData(1) }
- }
- };
-
- var roomInfo = new RoomInfoPacket {
- Version = new NetworkVersion(0, 3, 7),
- Games = new []{ "One", "Two" },
- DataPackageVersions = new Dictionary {
- { "One", 3 },
- { "Two", 4 },
- { "Five", 7 },
- { "Archipelago", 1 }
- }
- };
-
- var socket = Substitute.For();
- var fileSystemDataPackageProvider = Substitute.For();
- fileSystemDataPackageProvider.TryGetDataPackage(Arg.Any(), "", out _)
- .Returns(x => {
- x[2] = localDataPackage.Games[x.ArgAt(0)];
- return true;
- });
-
- _ = new DataPackageCache(socket, fileSystemDataPackageProvider);
-
- socket.PacketReceived += Raise.Event(roomInfo);
-
- socket.DidNotReceive().SendPacket(Arg.Any());
- }
-
- [Test]
- public void Should_only_request_data_for_games_that_a_have_different_version_then_cached()
- {
- var localDataPackage = new DataPackage
- {
- Games = new Dictionary {
- { "One", new TestGameData(3) },
- { "Two", new TestGameData(7) },
- { "Three", new TestGameData(5) },
- { "Archipelago", new TestGameData(1) }
- }
- };
-
- var roomInfo = new RoomInfoPacket
- {
- Version = new NetworkVersion(0, 3, 7),
- Games = new[] { "One", "Two", "Three" },
- DataPackageVersions = new Dictionary {
- { "One", 3 },
- { "Two", 6 },
- { "Three", 6 },
- { "Archipelago", 1 }
- }
- };
-
- var socket = Substitute.For();
- var fileSystemDataPackageProvider = Substitute.For();
- fileSystemDataPackageProvider.TryGetDataPackage(Arg.Any(), "", out _)
- .Returns(x => {
- x[2] = localDataPackage.Games[x.ArgAt(0)];
- return true;
- });
-
- _ = new DataPackageCache(socket, fileSystemDataPackageProvider);
-
- socket.PacketReceived += Raise.Event(roomInfo);
-
- socket.Received().SendPacket(Arg.Is(p =>
- p.Games.Length == 2 && p.Games[0] == "Two" && p.Games[1] == "Three"
- ));
- }
-
- [Test]
- public void Should_save_received_datapackage_contents()
- {
- var serverDataPackage = new DataPackagePacket {
- DataPackage = new DataPackage {
- Games = new Dictionary {
- {
- "One", new GameData {
- Version = 2,
- ItemLookup = new Dictionary {
- { "ItemOne", 101 }
- },
- LocationLookup = new Dictionary {
- { "LocationOne", 201 },
- { "LocationTwo", 202 }
- }
- }
- }
- }
- }
- };
-
- var socket = Substitute.For();
- var fileSystemDataPackageProvider = Substitute.For();
-
- _ = new DataPackageCache(socket, fileSystemDataPackageProvider);
-
- socket.PacketReceived += Raise.Event(serverDataPackage);
-
- fileSystemDataPackageProvider.Received().SaveDataPackageToFile("One", Arg.Is(d =>
- d.Version == 2
- && d.ItemLookup.Count == 1
- && d.ItemLookup["ItemOne"] == 101
- && d.LocationLookup.Count == 2
- && d.LocationLookup["LocationOne"] == 201
- && d.LocationLookup["LocationTwo"] == 202
- ));
- }
-
- [Test]
- public void Should_merge_received_datapackage_with_cached_version()
- {
- var localDataPackage = new DataPackage
- {
- Games = new Dictionary {
- { "One", new TestGameData(1) },
- { "Two", new TestGameData(3) },
- { "Archipelago", new TestGameData(3) },
- }
- };
-
- var roomInfo = new RoomInfoPacket
- {
- Version = new NetworkVersion(0, 3, 7),
- Games = new[] { "One", "Two" },
- DataPackageVersions = new Dictionary {
- { "One", 1 },
- { "Two", 6 },
- { "Archipelago", 3 }
- }
- };
-
- var serverDataPackage = new DataPackagePacket
- {
- DataPackage = new DataPackage
- {
- Games = new Dictionary {
- { "One", new TestGameData(2) }
- }
- }
- };
-
- var socket = Substitute.For();
- var fileSystemDataPackageProvider = Substitute.For();
- fileSystemDataPackageProvider.TryGetDataPackage(Arg.Any(), "", out _)
- .Returns(x => {
- x[2] = localDataPackage.Games[x.ArgAt(0)];
- return true;
- });
-
- var sut = new DataPackageCache(socket, fileSystemDataPackageProvider);
-
- socket.PacketReceived += Raise.Event(roomInfo);
- socket.PacketReceived += Raise.Event(serverDataPackage);
-
- sut.TryGetDataPackageFromCache(out var inMemoryDataPackage);
-
- Assert.IsTrue(inMemoryDataPackage.Games.Count == 3
- && inMemoryDataPackage.Games["One"].Version == 2
- && inMemoryDataPackage.Games["Two"].Version == 3
- && inMemoryDataPackage.Games["Archipelago"].Version == 3);
- }
-
- [Test]
- public void Should_not_save_game_when_version_is_0_but_still_keep_it_in_memory()
- {
- var localDataPackage = new DataPackage
- {
- Games = new Dictionary {
- { "One", new TestGameData(2) }
- }
- };
-
- var serverDataPackage = new DataPackagePacket
- {
- DataPackage = new DataPackage
- {
- Games = new Dictionary {
- { "One", new TestGameData(3) },
- { "Two", new TestGameData(0) }
- }
- }
- };
-
- var socket = Substitute.For();
- var fileSystemDataPackageProvider = Substitute.For();
- fileSystemDataPackageProvider.TryGetDataPackage(Arg.Any(), "", out _)
- .Returns(x => {
- x[2] = localDataPackage.Games[x.ArgAt(0)];
- return true;
- });
-
- var sut = new DataPackageCache(socket, fileSystemDataPackageProvider);
-
- socket.PacketReceived += Raise.Event(serverDataPackage);
-
- fileSystemDataPackageProvider.Received().SaveDataPackageToFile("One", Arg.Is(d => d.Version == 3));
- fileSystemDataPackageProvider.DidNotReceive().SaveDataPackageToFile("Two", Arg.Any());
-
- sut.TryGetGameDataFromCache("One", out var gameDataGameOne);
- sut.TryGetGameDataFromCache("Two", out var gameDataGameTwo);
-
- Assert.That(gameDataGameOne.Version, Is.EqualTo(3));
- Assert.That(gameDataGameTwo.Version, Is.EqualTo(0));
- }
-
- [Test]
- public void Should_request_data_package_for_all_games_when_versions_are_not_provided_on_the_roominfo()
- {
- var roomInfo = new RoomInfoPacket
- {
- Version = new NetworkVersion(0, 3, 7),
- Games = new[] { "One", "Two" },
- DataPackageVersions = null
- };
-
- var socket = Substitute.For();
- var fileSystemDataPackageProvider = Substitute.For();
- fileSystemDataPackageProvider.TryGetDataPackage(Arg.Any(), "", out _)
- .Returns(x => {
- x[2] = new GameData();
- return true;
- });
-
- _ = new DataPackageCache(socket, fileSystemDataPackageProvider);
-
- socket.PacketReceived += Raise.Event(roomInfo);
-
- socket.Received().SendPacket(Arg.Is(p =>
- p.Games.Length == 3 && p.Games[0] == "One" && p.Games[1] == "Two" && p.Games[2] == "Archipelago"
- ));
- }
-
- [Test]
- public void Should_request_data_package_for_games_the_server_fails_to_send_the_version_for()
- {
- var roomInfo = new RoomInfoPacket
- {
- Version = new NetworkVersion(0, 3, 7),
- Games = new[] { "One", "Two" },
- DataPackageVersions = new Dictionary {
- { "One", 0 }
- }
- };
-
- var socket = Substitute.For();
- var fileSystemDataPackageProvider = Substitute.For();
- fileSystemDataPackageProvider.TryGetDataPackage(Arg.Any(), "", out _)
- .Returns(x => {
- x[2] = new GameData();
- return true;
- });
-
- _ = new DataPackageCache(socket, fileSystemDataPackageProvider);
-
- socket.PacketReceived += Raise.Event(roomInfo);
-
- socket.Received().SendPacket(Arg.Is(p =>
- p.Games.Length == 2 && p.Games[0] == "Two" && p.Games[1] == "Archipelago"
- ));
- }
- class TestGameData : GameData
- {
- public TestGameData(int version)
- {
- Version = version;
- LocationLookup = new Dictionary(0);
- ItemLookup = new Dictionary(0);
- }
- }
- }
-}
diff --git a/Archipelago.MultiClient.Net.Tests/DataStorageHelperFixture.cs b/Archipelago.MultiClient.Net.Tests/DataStorageHelperFixture.cs
index 03e0b92..415fbff 100644
--- a/Archipelago.MultiClient.Net.Tests/DataStorageHelperFixture.cs
+++ b/Archipelago.MultiClient.Net.Tests/DataStorageHelperFixture.cs
@@ -12,6 +12,10 @@
using System.Threading.Tasks;
using Callback = Archipelago.MultiClient.Net.Models.Callback;
+#if !NET471
+using System.Numerics;
+#endif
+
// ReSharper disable All
// ReSharper disable UnusedVariable
namespace Archipelago.MultiClient.Net.Tests
@@ -72,43 +76,43 @@ public void Should_get_value_correctly(Func get
public static TestCaseData[] CompoundAssignmentTests =>
new TestCaseData[] {
new CompoundAssignmentTest("Assignment", true, (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (bool)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Boolean && (bool)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", true, (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (bool)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Boolean && (bool)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", null, (sut, key, value) => sut[key] = value,
(p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Null && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", 30, (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (int)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Integer && (int)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", 30, (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (int)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Integer && (int)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", null, (sut, key, value) => sut[key] = value,
(p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Null && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", 300L, (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (long)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Integer && (long)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", 300L, (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (long)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Integer && (long)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", null, (sut, key, value) => sut[key] = value,
(p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Null && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", 3.003m, (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (decimal)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Float && (decimal)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", 3.003m, (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (decimal)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Float && (decimal)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", null, (sut, key, value) => sut[key] = value,
(p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Null && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", 3.03d, (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (double)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Float && (double)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", 3.03d, (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (double)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Float && (double)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", null, (sut, key, value) => sut[key] = value,
(p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Null && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", 3f, (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (float)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Float && (float)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", 3f, (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (float)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Float && (float)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", null, (sut, key, value) => sut[key] = value,
(p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.Null && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", "test", (sut, key, value) => sut[key] = value,
- (p, key, value) => p.Key == key && (string)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
+ (p, key, value) => p.Key == key && p.Operations[0].Value.Type == JTokenType.String && (string)p.Operations[0].Value == value && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", null, (sut, key, value) => sut[key] = value,
(p, key, value) =>p.Key == key && p.Operations[0].Value.Type == JTokenType.Null && p.Operations[0].OperationType == OperationType.Replace),
new CompoundAssignmentTest("Assignment", new []{ true, false }, (sut, key, value) => sut[key] = value,
@@ -146,17 +150,17 @@ public void Should_get_value_correctly(Func get
new CompoundAssignmentTest>("Assignment", new List