-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
RemoteNet
committed
Nov 22, 2024
1 parent
503f1ad
commit 3cfbf99
Showing
3 changed files
with
77 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,93 @@ | ||
using RemoteNET; | ||
using System.Globalization; | ||
|
||
[TestFixture] | ||
public class DynamicRemoteCharStarTests | ||
|
||
namespace RemoteNET.Tests | ||
{ | ||
[Test] | ||
public void TestPropertyAccess() | ||
|
||
[TestFixture] | ||
public class DynamicRemoteCharStarTests | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
[Test] | ||
public void TestPropertyAccess() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
|
||
// Test property access using dynamic proxy | ||
Assert.AreEqual(13, proxy.Length); | ||
Assert.AreEqual("Hello", proxy.Substring(0, 5)); | ||
} | ||
// Test property access using dynamic proxy | ||
Assert.That(proxy.Length, Is.EqualTo(13)); | ||
Assert.That(proxy.Substring(0, 5), Is.EqualTo("Hello")); | ||
} | ||
|
||
[Test] | ||
public void TestPropertyModification() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
[Test] | ||
public void TestPropertyModification() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
|
||
// Modify property using dynamic proxy | ||
proxy = proxy.Replace("world", "C#"); | ||
Assert.AreEqual("Hello, C#!", proxy); | ||
} | ||
// Modify property using dynamic proxy | ||
proxy = proxy.Replace("world", "C#"); | ||
Assert.That(proxy, Is.EqualTo("Hello, C#!")); | ||
} | ||
|
||
[Test] | ||
public void TestMethodInvocation() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
[Test] | ||
public void TestMethodInvocation() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
|
||
// Invoke method using dynamic proxy | ||
proxy = proxy.ToUpper(); | ||
Assert.AreEqual("HELLO, WORLD!", proxy); | ||
} | ||
// Invoke method using dynamic proxy | ||
proxy = proxy.ToUpper(); | ||
Assert.That(proxy, Is.EqualTo("HELLO, WORLD!")); | ||
} | ||
|
||
[Test] | ||
public void TestSubclassParameter() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
[Test] | ||
public void TestSubclassParameter() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
|
||
// Invoke ToString method with a string parameter | ||
string formattedString = proxy.ToString(CultureInfo.InvariantCulture); | ||
Assert.AreEqual("Hello, world!", formattedString); | ||
// Invoke ToString method with a string parameter | ||
string formattedString = proxy.ToString(CultureInfo.InvariantCulture); | ||
Assert.That(formattedString, Is.EqualTo("Hello, world!")); | ||
|
||
// Invoke ToString method with an IFormatProvider (a subclass of object) as a parameter | ||
IFormatProvider formatProvider = CultureInfo.InvariantCulture; | ||
string formattedStringWithProvider = proxy.ToString(formatProvider); | ||
Assert.AreEqual("Hello, world!", formattedStringWithProvider); | ||
} | ||
// Invoke ToString method with an IFormatProvider (a subclass of object) as a parameter | ||
IFormatProvider formatProvider = CultureInfo.InvariantCulture; | ||
string formattedStringWithProvider = proxy.ToString(formatProvider); | ||
Assert.That(formattedStringWithProvider, Is.EqualTo("Hello, world!")); | ||
} | ||
|
||
[Test] | ||
public void TestImplicitConversion() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
[Test] | ||
public void TestImplicitConversion() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
|
||
// Implicit conversion from DynamicRemoteCharStar to string | ||
string convertedString = proxy; | ||
Assert.AreEqual("Hello, world!", convertedString); | ||
} | ||
// Implicit conversion from DynamicRemoteCharStar to string | ||
string convertedString = proxy; | ||
Assert.That(convertedString, Is.EqualTo("Hello, world!")); | ||
} | ||
|
||
[Test] | ||
public void TestExplicitConversion() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
[Test] | ||
public void TestExplicitConversion() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
|
||
// Explicit conversion from DynamicRemoteCharStar to string | ||
string convertedString = (string)proxy; | ||
Assert.AreEqual("Hello, world!", convertedString); | ||
} | ||
// Explicit conversion from DynamicRemoteCharStar to string | ||
string convertedString = (string)proxy; | ||
Assert.That(convertedString, Is.EqualTo("Hello, world!")); | ||
} | ||
|
||
[Test] | ||
public void TestToStringConversion() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
[Test] | ||
public void TestToStringConversion() | ||
{ | ||
string initialString = "Hello, world!"; | ||
dynamic proxy = new DynamicRemoteCharStar(null, 0x100, initialString); | ||
|
||
// Explicit conversion from DynamicRemoteCharStar to string | ||
string convertedString = proxy.ToString(); | ||
Assert.AreEqual("Hello, world!", convertedString); | ||
// Explicit conversion from DynamicRemoteCharStar to string | ||
string convertedString = proxy.ToString(); | ||
Assert.That(convertedString, Is.EqualTo("Hello, world!")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters