-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDataBinderTests.cs
46 lines (37 loc) · 964 Bytes
/
DataBinderTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Havit.Tests;
[TestClass]
public class DataBinderTests
{
[TestMethod]
public void DataBinderExt_SetValue_PublicProperty()
{
// arrange
var obj = new MyClass();
// act
DataBinderExt.SetValue(obj, "MyPublicProperty", 1);
// assert
Assert.AreEqual(1, obj.MyPublicProperty);
}
[TestMethod]
[ExpectedException(typeof(InvalidOperationException))]
public void DataBinderExt_SetValue_ProtectedSetterProperty()
{
// arrange
var obj = new MyClass();
// act
DataBinderExt.SetValue(obj, "MyPropertyWithProtectedSetter", 1);
// assert
Assert.AreEqual(1, obj.MyPropertyWithProtectedSetter);
}
private class MyClass
{
public int MyPublicProperty { get; set; }
public int MyPropertyWithProtectedSetter { get; protected set; }
}
}