-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path23_AnnonymousTypes.cs
66 lines (56 loc) · 2.14 KB
/
23_AnnonymousTypes.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using Xunit;
namespace basic
{
public class AnnonymousTypes
{
[Fact]
public void should_define_data_type_without_class_definition()
{
var annonymousTypeInstance = new
{
FirstName = "Bill",
LastName = "Gates"
};
// please update the variable values for the following 2 lines to fix the test.
const string expectedFirstName = "Bill";
const string expectedLastName = "Gates";
Assert.Equal(expectedFirstName, annonymousTypeInstance.FirstName);
Assert.Equal(expectedLastName, annonymousTypeInstance.LastName);
}
[Fact]
public void should_resolve_property_name_by_variable_name()
{
const string firstName = "Bill";
var annonymousTypeInstance = new
{
firstName,
LastName = "Gates"
};
// please update the variable values for the following 2 lines to fix the test.
const string expectedFirstName = "Bill";
const string expectedLastName = "Gates";
Assert.Equal(expectedFirstName, annonymousTypeInstance.firstName);
Assert.Equal(expectedLastName, annonymousTypeInstance.LastName);
}
[Fact]
public void should_create_nested_anonymous_type()
{
var personalInformation = new
{
Name = new
{
FirstName = "Bill",
LastName = "Gates"
},
Age = 59
};
// please update the variable values for the following 3 lines to fix the test.
const string expectedFirstName = "Bill";
const string expectedLastName = "Gates";
const int expectedAge = 59;
Assert.Equal(expectedFirstName, personalInformation.Name.FirstName);
Assert.Equal(expectedLastName, personalInformation.Name.LastName);
Assert.Equal(expectedAge, personalInformation.Age);
}
}
}