add version 0.0.1
This commit is contained in:
@@ -11,13 +11,18 @@ public class ResxFileTests
|
||||
<root>
|
||||
<data name='Test1'>
|
||||
<value>Value1</value>
|
||||
<comment>This is a greeting message.</comment>
|
||||
</data>
|
||||
<data name='Test2' type='{typeof(int).FullName}'>
|
||||
<value>Value2</value>
|
||||
<data name='Test2' type='{typeof(string).FullName}'>
|
||||
<value>{{2}}Value2{{0}}{{{{1}}}}</value>
|
||||
<comment>2 = prefix</comment>
|
||||
</data>
|
||||
<data name='Test3' type='{typeof(byte[]).FullName}'>
|
||||
<value>0xDEADBEEF</value>
|
||||
</data>
|
||||
</root>";
|
||||
|
||||
private const string expectedClass = @"
|
||||
private const string expectedClass = @"
|
||||
using ResourceString.Net.Contract;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
@@ -34,7 +39,7 @@ namespace TestNameSpace
|
||||
private static readonly Type _Type = typeof(ResourceManager);
|
||||
|
||||
private static readonly Lazy<ResourceManager> _ResourceManager = new Lazy<ResourceManager>(
|
||||
() => new ResourceManager(_Type.FullName, _Type.Assembly),
|
||||
() => new ResourceManager(_Type.FullName ?? string.Empty, _Type.Assembly),
|
||||
LazyThreadSafetyMode.PublicationOnly
|
||||
);
|
||||
|
||||
@@ -54,16 +59,22 @@ namespace TestNameSpace
|
||||
|
||||
#endregion // Test1
|
||||
|
||||
#region Test2
|
||||
internal static class Test2
|
||||
{
|
||||
private static readonly Lazy<IResourceString> LazyFormat = new Lazy<IResourceString>(
|
||||
() => new ResourceManagerString(""Test2"", ResourceManager, CultureInfo.CurrentCulture),
|
||||
LazyThreadSafetyMode.PublicationOnly
|
||||
);
|
||||
|
||||
private static readonly Lazy<IResourceString> LazyTest2 = new Lazy<IResourceString>(
|
||||
() => new ResourceManagerString(""Test2"", ResourceManager, CultureInfo.CurrentCulture),
|
||||
LazyThreadSafetyMode.PublicationOnly
|
||||
);
|
||||
|
||||
public static IResourceString Test2 => LazyTest2.Value;
|
||||
|
||||
#endregion // Test2
|
||||
public static IResourceString Format => LazyFormat.Value;
|
||||
|
||||
public static IResourceString From(IResourceString prefix, IResourceString p1) => new FormattedResourceString(
|
||||
Format,
|
||||
prefix,
|
||||
p1
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}";
|
||||
@@ -77,8 +88,9 @@ namespace TestNameSpace
|
||||
{
|
||||
// Arrange
|
||||
var expectedData = new[] {
|
||||
("Test1", "Value1", string.Empty),
|
||||
("Test2", "Value2", typeof(int).FullName)
|
||||
("Test1", "Value1", string.Empty, "This is a greeting message."),
|
||||
("Test2", "{2}Value2{0}{{1}}", typeof(string).FullName, "2 = prefix"),
|
||||
("Test3", "0xDEADBEEF", typeof(byte[]).FullName, string.Empty)
|
||||
};
|
||||
|
||||
// Act
|
||||
@@ -89,8 +101,13 @@ namespace TestNameSpace
|
||||
|
||||
// Assert
|
||||
CollectionAssert.AreEqual(
|
||||
expectedData,
|
||||
result.Select(i => (i.Name, i.Value, i.Type.IfNone(string.Empty))).ToList()
|
||||
expectedData,
|
||||
result.Select(i => (
|
||||
i.Name,
|
||||
i.Value,
|
||||
i.Type.IfNone(string.Empty),
|
||||
i.Comment.IfNone(string.Empty)
|
||||
)).ToList()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -128,7 +145,7 @@ namespace TestNameSpace
|
||||
|
||||
[TestMethod]
|
||||
public void Test_ToMemberString()
|
||||
{
|
||||
{
|
||||
// Act
|
||||
var result = Parser.TryParse(validXml).Match(
|
||||
Some: v => CodeSnippetFactory.CreateMemberCodeSnippets(v.Resources),
|
||||
@@ -144,8 +161,8 @@ namespace TestNameSpace
|
||||
);
|
||||
|
||||
Assert.AreEqual(
|
||||
"#region Test2",
|
||||
result.Select(i => i.Value.Substring(0, 25).Trim()).ToList()[1]
|
||||
"internal static class Test2",
|
||||
result.Select(i => i.Value.Substring(0, 45).Trim()).ToList()[1]
|
||||
);
|
||||
|
||||
}
|
||||
@@ -160,7 +177,7 @@ namespace TestNameSpace
|
||||
"TestResourceClass",
|
||||
CodeSnippetFactory.CreateResourceMangerMemberCodeSnippet("ResourceManager"),
|
||||
v.Resources
|
||||
),
|
||||
),
|
||||
None: () => throw new InvalidOperationException()
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user