json-2-c-sharp-code-generator/Json2CSharpCodeGenerator.Tests/Test_10_SETTINGS_IMMUTABLE_CLASSES_PHARES.cs

38 lines
1.7 KiB
C#

using Json2CSharpCodeGenerator.Lib;
using Json2CSharpCodeGenerator.Lib.CodeWriters;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Json2CSharpCodeGenerator.Tests;
[TestClass]
public class Test_10_SETTINGS_IMMUTABLE_CLASSES_PHARES
{
[TestMethod]
public void Run()
{
string path = Path.Combine(AppContext.BaseDirectory, "Test_10_SETTINGS_IMMUTABLE_CLASSES_PHARES_INPUT.txt");
string resultPath = Path.Combine(AppContext.BaseDirectory, "Test_10_SETTINGS_IMMUTABLE_CLASSES_PHARES_OUTPUT.txt");
string input = File.ReadAllText(path);
JsonClassGenerator jsonClassGenerator = new()
{
AttributeLibrary = JsonLibrary.SystemTextJson,
AttributeUsage = JsonPropertyAttributeUsage.OnlyWhenNecessary,
CodeWriter = new CSharpCodeWriter(),
CollectionType = OutputCollectionType.MutableList,
OutputType = OutputTypes.ImmutableClass,
UsePascalCase = true,
UseThisKeyWord = false,
};
string returnVal = jsonClassGenerator.GenerateClasses(input, errorMessage: out _).ToString();
string resultsCompare = File.ReadAllText(resultPath);
string expected = resultsCompare.NormalizeOutput();
string actual = returnVal.NormalizeOutput();
if (expected != actual)
{
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "Test_10_SETTINGS_IMMUTABLE_CLASSES_PHARES_OUTPUT.actual.txt"), returnVal);
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "Test_10_SETTINGS_IMMUTABLE_CLASSES_PHARES_OUTPUT.expected.txt"), resultsCompare);
}
Assert.AreEqual(expected, actual);
}
}