From 249a66c69bc82d1ca4215141fedd708ec03bc72e Mon Sep 17 00:00:00 2001 From: tacosontitan Date: Tue, 12 Mar 2024 00:02:10 -0500 Subject: [PATCH] Added core test project. --- Pasper.sln | 7 ++++ test/Pasper.Tests/IgnoreTests.cs | 14 -------- test/Pasper.Tests/Mocking/MockProvider.cs | 27 -------------- test/Pasper.Tests/Mocking/Models/Group.cs | 15 -------- test/Pasper.Tests/Mocking/Models/Person.cs | 17 --------- test/Pasper.Tests/Pasper.Tests.csproj | 41 ++++++++++------------ test/Pasper.Tests/Usings.cs | 2 -- 7 files changed, 25 insertions(+), 98 deletions(-) delete mode 100644 test/Pasper.Tests/IgnoreTests.cs delete mode 100644 test/Pasper.Tests/Mocking/MockProvider.cs delete mode 100644 test/Pasper.Tests/Mocking/Models/Group.cs delete mode 100644 test/Pasper.Tests/Mocking/Models/Person.cs delete mode 100644 test/Pasper.Tests/Usings.cs diff --git a/Pasper.sln b/Pasper.sln index 21b5a07..954d863 100644 --- a/Pasper.sln +++ b/Pasper.sln @@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pasper.Toml", "src\Pasper.T EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pasper.Toml.Tests", "test\Pasper.Toml.Tests\Pasper.Toml.Tests.csproj", "{AD32F58A-C91A-40F6-BC4B-BA771B00F35F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pasper.Tests", "test\Pasper.Tests\Pasper.Tests.csproj", "{B9BB71EE-0B0F-4D96-A330-EF000B65D0DB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -67,6 +69,10 @@ Global {AD32F58A-C91A-40F6-BC4B-BA771B00F35F}.Debug|Any CPU.Build.0 = Debug|Any CPU {AD32F58A-C91A-40F6-BC4B-BA771B00F35F}.Release|Any CPU.ActiveCfg = Release|Any CPU {AD32F58A-C91A-40F6-BC4B-BA771B00F35F}.Release|Any CPU.Build.0 = Release|Any CPU + {B9BB71EE-0B0F-4D96-A330-EF000B65D0DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9BB71EE-0B0F-4D96-A330-EF000B65D0DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9BB71EE-0B0F-4D96-A330-EF000B65D0DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9BB71EE-0B0F-4D96-A330-EF000B65D0DB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -81,6 +87,7 @@ Global {4F0A9CE8-936F-431D-AF98-C427CD70CF99} = {7366F508-1DDD-46DB-82C0-978C5F0D1F92} {F7A3BE69-4C91-4164-AABF-E228C44AEED7} = {7366F508-1DDD-46DB-82C0-978C5F0D1F92} {AD32F58A-C91A-40F6-BC4B-BA771B00F35F} = {371DEE60-97EB-4754-9083-B0928ABE7695} + {B9BB71EE-0B0F-4D96-A330-EF000B65D0DB} = {371DEE60-97EB-4754-9083-B0928ABE7695} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {98BD2AB3-7CF7-4E57-A9C7-B8E50657904F} diff --git a/test/Pasper.Tests/IgnoreTests.cs b/test/Pasper.Tests/IgnoreTests.cs deleted file mode 100644 index 4b92a48..0000000 --- a/test/Pasper.Tests/IgnoreTests.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Pasper.Tests; - -public class IgnoreTests -{ - [Fact] - public void NoAttributesFound() - { - var provider = new Mocking.MockProvider(); - var input = new { Name = "John", Age = 42 }; - var serialized = provider.Serialize(input); - - // TO BE CONTINUED... - } -} \ No newline at end of file diff --git a/test/Pasper.Tests/Mocking/MockProvider.cs b/test/Pasper.Tests/Mocking/MockProvider.cs deleted file mode 100644 index a407a3f..0000000 --- a/test/Pasper.Tests/Mocking/MockProvider.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Text; -using Pasper.Reflection; - -namespace Pasper.Tests.Mocking; - -internal sealed class MockProvider : ISerializationProvider -{ - public string Serialize(T input) - { - var properties = typeof(T).GetProperties(); - var serializedInput = new StringBuilder(); - foreach (var property in properties) - { - if (property.IsIgnored()) - continue; - - if (!property.IsSerialized(out string key)) - continue; - - serializedInput.AppendFormat("{0}: {1}\n", key, property.GetValue(input)); - } - - return serializedInput.ToString(); - } - - public T Deserialize(string input) => default; -} diff --git a/test/Pasper.Tests/Mocking/Models/Group.cs b/test/Pasper.Tests/Mocking/Models/Group.cs deleted file mode 100644 index 22739bf..0000000 --- a/test/Pasper.Tests/Mocking/Models/Group.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Pasper; - -namespace Pasper.Tests.Mocking.Models; - -internal sealed class Group -{ - [Ignored] - public Guid Id { get; set; } - - [Serialized] - public string Name { get; set; } - - [Serialized] - public IEnumerable Members { get; set; } -} \ No newline at end of file diff --git a/test/Pasper.Tests/Mocking/Models/Person.cs b/test/Pasper.Tests/Mocking/Models/Person.cs deleted file mode 100644 index 682d651..0000000 --- a/test/Pasper.Tests/Mocking/Models/Person.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Pasper.Tests.Mocking.Models; - -internal sealed class Person -{ - [Ignored] // Most serializers will ignore readonly properties by default. - // We explicitly mark it for testing purposes. - public string DisplayName => $"{FirstName} {LastName}"; - - [Serialized("first_name")] - public string FirstName { get; set; } - - [Serialized("last_name")] - public string LastName { get; set; } - - [Serialized("age")] - public int Age { get; set; } -} diff --git a/test/Pasper.Tests/Pasper.Tests.csproj b/test/Pasper.Tests/Pasper.Tests.csproj index b2f3c16..7bd5201 100644 --- a/test/Pasper.Tests/Pasper.Tests.csproj +++ b/test/Pasper.Tests/Pasper.Tests.csproj @@ -1,29 +1,24 @@ - - net7.0 - enable - enable + + false + true + 1.0.0.0 + - false - true - + + + - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - + + + + + + - - - + + + - + \ No newline at end of file diff --git a/test/Pasper.Tests/Usings.cs b/test/Pasper.Tests/Usings.cs deleted file mode 100644 index 4e285ee..0000000 --- a/test/Pasper.Tests/Usings.cs +++ /dev/null @@ -1,2 +0,0 @@ -global using Xunit; -global using Pasper; \ No newline at end of file