Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit defe1cd

Browse files
committed
Add stub of accessor test
1 parent ff65926 commit defe1cd

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/ServiceStack.Text/Reflection/StaticAccessors.cs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#endif
1818
namespace ServiceStack.Text.Reflection
1919
{
20+
//Also exists in ServiceStack.Common in ServiceStack.Reflection namespace
2021
public static class StaticAccessors
2122
{
2223
public static Func<object, object> GetValueGetter(this PropertyInfo propertyInfo, Type type)

tests/ServiceStack.Text.Tests/ServiceStack.Text.Tests.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
</Reference>
177177
</ItemGroup>
178178
<ItemGroup>
179+
<Compile Include="StaticAccessorTests.cs" />
179180
<Compile Include="AdhocModelTests.cs" />
180181
<Compile Include="AnonymousTypes.cs" />
181182
<Compile Include="AotTests.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using NUnit.Framework;
2+
using ServiceStack.Text.Reflection;
3+
4+
namespace ServiceStack.Text.Tests
5+
{
6+
public class AccessorBase
7+
{
8+
public string Base { get; set; }
9+
}
10+
11+
public class Accessor
12+
{
13+
public string Declared { get; set; }
14+
}
15+
16+
[TestFixture]
17+
public class StaticAccessorTests
18+
{
19+
[Test]
20+
public void Can_get_accessor_in_declared_and_base_class()
21+
{
22+
var baseProperty = typeof(AccessorBase).GetProperty("Base");
23+
var declaredProperty = typeof(Accessor).GetProperty("Declared");
24+
25+
var baseSetter = baseProperty.GetValueSetter<AccessorBase>();
26+
Assert.That(baseSetter, Is.Not.Null);
27+
28+
var declaredSetter = declaredProperty.GetValueSetter<Accessor>();
29+
Assert.That(declaredSetter, Is.Not.Null);
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)