fix: Optimizes TextDefinition to eliminate allocations. Removes TextDefinition ctor. (#1221)
### BREAKING CHANGE ### The constructor for `TextDefinition` has been removed. Instead use `TextDefinition.Of()` or cast the integer/string to TextDefinition.
This commit is contained in:
parent
213b7025af
commit
910e06767b
50 changed files with 790 additions and 722 deletions
30
Projects/Server.Tests/Tests/Text/TextDefinitionTests.cs
Normal file
30
Projects/Server.Tests/Tests/Text/TextDefinitionTests.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace Server.Tests;
|
||||
|
||||
public class TextDefinitionTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(10345, "", "#10345")]
|
||||
[InlineData(0, "Hello", "Hello")]
|
||||
[InlineData(10345, "Hello", "#10345")]
|
||||
public void TestTextDefinitionToString(int a1, string a2, string expected)
|
||||
{
|
||||
Assert.Equal(expected, TextDefinition.Of(a1, a2).ToString());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(10345, "", 10345, "", true)]
|
||||
[InlineData(10345, "", 0, "Hello", false)]
|
||||
[InlineData(0, "Hello", 0, "Hello", true)]
|
||||
[InlineData(0, "Hello", 0, "hello", false)]
|
||||
[InlineData(10345, "Hello", 10345, "Goodbye", true)]
|
||||
[InlineData(10345, "Hello", 10510, "Hello", false)]
|
||||
public void TestTextDefinitionIsEqual(int a1, string a2, int b1, string b2, bool isEqual)
|
||||
{
|
||||
var a = TextDefinition.Of(a1, a2);
|
||||
var b = TextDefinition.Of(b1, b2);
|
||||
Assert.Equal(isEqual, a.Equals(b));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue