mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
35 lines
921 B
C#
35 lines
921 B
C#
using BusinessLogic;
|
|
using Common;
|
|
|
|
namespace Tests;
|
|
|
|
public class EntityServiceTests
|
|
{
|
|
public static bool TestCreateEntity()
|
|
{
|
|
var service = new EntityService();
|
|
var result = service.CreateEntity("Test");
|
|
return result.Success && result.Data!.Name == "Test";
|
|
}
|
|
|
|
public static bool TestGetMissing()
|
|
{
|
|
var service = new EntityService();
|
|
var result = service.GetEntity(999);
|
|
return !result.Success;
|
|
}
|
|
|
|
public static bool TestTruncation()
|
|
{
|
|
var longName = new string('x', 200);
|
|
return longName.Truncate(10) == "xxxxxxxxxx...";
|
|
}
|
|
|
|
public static void Main()
|
|
{
|
|
Console.WriteLine($"CreateEntity: {(TestCreateEntity() ? "PASS" : "FAIL")}");
|
|
Console.WriteLine($"GetMissing: {(TestGetMissing() ? "PASS" : "FAIL")}");
|
|
Console.WriteLine($"Truncation: {(TestTruncation() ? "PASS" : "FAIL")}");
|
|
}
|
|
}
|