Skip to content

Commit 5c03f99

Browse files
committed
DynamicOptionsBaseのDeserializeのテストを作成
1 parent bd2be7d commit 5c03f99

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

CommonTests/CommonTests.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<Reference Include="System.Xml" />
4343
</ItemGroup>
4444
<ItemGroup>
45+
<Compile Include="DynamicOptionsBaseTests.cs" />
4546
<Compile Include="Properties\AssemblyInfo.cs" />
4647
<Compile Include="SQLiteUserStoreTests.cs" />
4748
</ItemGroup>
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Common;
2+
using NUnit.Framework;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace CommonTests
10+
{
11+
[TestFixture]
12+
class DynamicOptionsBaseTests
13+
{
14+
class TestOptions : DynamicOptionsBase
15+
{
16+
public string Prop1 { get => GetValue(); set => SetValue(value); }
17+
public string Prop2 { get => GetValue(); set => SetValue(value); }
18+
19+
protected override void Init()
20+
{
21+
Dict.Add(nameof(Prop1), new Item { DefaultValue = "1", Predicate = c => true, Serializer = c => c, Deserializer = s => s });
22+
Dict.Add(nameof(Prop2), new Item { DefaultValue = "2", Predicate = c => true, Serializer = c => c, Deserializer = s => s });
23+
}
24+
}
25+
[Test]
26+
public void DeserializeTest()
27+
{
28+
var s = "Prop1=8\r\nProp3=10";
29+
var options = new TestOptions();
30+
options.Deserialize(s);
31+
Assert.AreEqual("8", options.Prop1);
32+
Assert.AreEqual("2", options.Prop2);
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)