summaryrefslogtreecommitdiff
path: root/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock')
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetFieldBase.cs16
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetInt.cs6
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetRef.cs6
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs18
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs6
5 files changed, 52 insertions, 0 deletions
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetFieldBase.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetFieldBase.cs
new file mode 100644
index 00000000..1684229a
--- /dev/null
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetFieldBase.cs
@@ -0,0 +1,16 @@
+// ReSharper disable CheckNamespace -- matches Stardew Valley's code
+namespace Netcode
+{
+ /// <summary>A simplified version of Stardew Valley's <c>Netcode.NetFieldBase</c> for unit testing.</summary>
+ /// <typeparam name="T">The type of the synchronised value.</typeparam>
+ /// <typeparam name="TSelf">The type of the current instance.</typeparam>
+ public class NetFieldBase<T, TSelf> where TSelf : NetFieldBase<T, TSelf>
+ {
+ /// <summary>The synchronised value.</summary>
+ public T Value { get; set; }
+
+ /// <summary>Implicitly convert a net field to the its type.</summary>
+ /// <param name="field">The field to convert.</param>
+ public static implicit operator T(NetFieldBase<T, TSelf> field) => field.Value;
+ }
+}
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetInt.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetInt.cs
new file mode 100644
index 00000000..b3abc467
--- /dev/null
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetInt.cs
@@ -0,0 +1,6 @@
+// ReSharper disable CheckNamespace -- matches Stardew Valley's code
+namespace Netcode
+{
+ /// <summary>A simplified version of Stardew Valley's <c>Netcode.NetInt</c> for unit testing.</summary>
+ public class NetInt : NetFieldBase<int, NetInt> { }
+}
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetRef.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetRef.cs
new file mode 100644
index 00000000..714c4a8d
--- /dev/null
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetRef.cs
@@ -0,0 +1,6 @@
+// ReSharper disable CheckNamespace -- matches Stardew Valley's code
+namespace Netcode
+{
+ /// <summary>A simplified version of Stardew Valley's <c>Netcode.NetRef</c> for unit testing.</summary>
+ public class NetRef : NetFieldBase<object, NetRef> { }
+}
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs
new file mode 100644
index 00000000..88723a56
--- /dev/null
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs
@@ -0,0 +1,18 @@
+// ReSharper disable CheckNamespace, InconsistentNaming -- matches Stardew Valley's code
+using Netcode;
+
+namespace StardewValley
+{
+ /// <summary>A simplified version of Stardew Valley's <c>StardewValley.Item</c> class for unit testing.</summary>
+ public class Item
+ {
+ /// <summary>A net int field with an equivalent non-net <c>Category</c> property.</summary>
+ public NetInt category { get; } = new NetInt { Value = 42 };
+
+ /// <summary>A net int field with no equivalent non-net property.</summary>
+ public NetInt type { get; } = new NetInt { Value = 42 };
+
+ /// <summary>A net reference field.</summary>
+ public NetRef refField { get; } = null;
+ }
+}
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs
new file mode 100644
index 00000000..498c38c1
--- /dev/null
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs
@@ -0,0 +1,6 @@
+// ReSharper disable CheckNamespace -- matches Stardew Valley's code
+namespace StardewValley
+{
+ /// <summary>A simplified version of Stardew Valley's <c>StardewValley.Object</c> class for unit testing.</summary>
+ public class Object : Item { }
+}