質問編集履歴
6
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,11 +11,7 @@
|
|
11
11
|
Visual Studio のバージョン Microsoft Visual Studio Community 2019 Version16.11.3
|
12
12
|
.NET Framework 4.8
|
13
13
|
|
14
|
-
O/Rマッパー
|
15
|
-
Dapper
|
16
14
|
|
17
|
-
DIコンテナ
|
18
|
-
Autofac
|
19
15
|
### 発生している問題・エラーメッセージ
|
20
16
|
CS1061
|
21
17
|
```
|
5
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,6 +14,8 @@
|
|
14
14
|
O/Rマッパー
|
15
15
|
Dapper
|
16
16
|
|
17
|
+
DIコンテナ
|
18
|
+
Autofac
|
17
19
|
### 発生している問題・エラーメッセージ
|
18
20
|
CS1061
|
19
21
|
```
|
4
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,6 +11,9 @@
|
|
11
11
|
Visual Studio のバージョン Microsoft Visual Studio Community 2019 Version16.11.3
|
12
12
|
.NET Framework 4.8
|
13
13
|
|
14
|
+
O/Rマッパー
|
15
|
+
Dapper
|
16
|
+
|
14
17
|
### 発生している問題・エラーメッセージ
|
15
18
|
CS1061
|
16
19
|
```
|
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -80,10 +80,10 @@
|
|
80
80
|
|
81
81
|
LargeViewModel
|
82
82
|
```C#
|
83
|
-
public class
|
83
|
+
public class LargeViewModel
|
84
84
|
{
|
85
85
|
|
86
|
-
public
|
86
|
+
public LargeViewModel()
|
87
87
|
{
|
88
88
|
|
89
89
|
}
|
2
Model定義、開発環境情報追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,6 +4,13 @@
|
|
4
4
|
単体テスト時にLargeViewModelの中のIEnumerable型のUserViewModelにアクセスしたいのですが、「Objectに定義
|
5
5
|
が含まれていない」といわれます。
|
6
6
|
ご教授ねがいます!!
|
7
|
+
|
8
|
+
環境
|
9
|
+
ASP.NET MVC
|
10
|
+
OS Windows10
|
11
|
+
Visual Studio のバージョン Microsoft Visual Studio Community 2019 Version16.11.3
|
12
|
+
.NET Framework 4.8
|
13
|
+
|
7
14
|
### 発生している問題・エラーメッセージ
|
8
15
|
CS1061
|
9
16
|
```
|
@@ -64,13 +71,74 @@
|
|
64
71
|
{
|
65
72
|
return new UserViewModel[]
|
66
73
|
{
|
67
|
-
new UserViewModel() { UserId = 0, UserName = "あ",
|
74
|
+
new UserViewModel() { UserId = 0, UserName = "あ", TestFlg = 1},
|
68
|
-
new UserViewModel() { UserId = 100, UserName = "い",
|
75
|
+
new UserViewModel() { UserId = 100, UserName = "い", TestFlg = 2 },
|
69
|
-
new UserViewModel() { UserId = 200, UserName = "う",
|
76
|
+
new UserViewModel() { UserId = 200, UserName = "う", TestFlg = 3 },
|
70
77
|
}
|
71
78
|
}
|
72
79
|
```
|
73
80
|
|
81
|
+
LargeViewModel
|
82
|
+
```C#
|
83
|
+
public class KanrihyouViewModel
|
84
|
+
{
|
85
|
+
|
86
|
+
public KanrihyouViewModel()
|
87
|
+
{
|
88
|
+
|
89
|
+
}
|
90
|
+
public IEnumerable<SelectListItem> AList { get; set; }
|
91
|
+
|
92
|
+
public IEnumerable<SelectListItem> BList { get; set; }
|
93
|
+
|
94
|
+
public IEnumerable<SelectListItem> CList { get; set; }
|
95
|
+
|
96
|
+
public IEnumerable<UserViewModel> IchiranTable { get; set; }
|
97
|
+
|
98
|
+
public string a { get; set; }
|
99
|
+
|
100
|
+
public string b { get; set; }
|
101
|
+
|
102
|
+
public string c { get; set; }
|
103
|
+
}
|
104
|
+
```
|
105
|
+
|
106
|
+
UserViewModel
|
107
|
+
```C#
|
108
|
+
public class UserViewModel
|
109
|
+
{
|
110
|
+
public UserViewModel()
|
111
|
+
{
|
112
|
+
|
113
|
+
}
|
114
|
+
public UserViewModel(UserViewModel x)
|
115
|
+
{
|
116
|
+
UserId = x.UserId;
|
117
|
+
UserName = x.UserName;
|
118
|
+
TestFlg = x.TestFlg;
|
119
|
+
IsInstalled = (x.TestFlg == (int)TestType.Installed);
|
120
|
+
}
|
121
|
+
public int UserId { get; set; }
|
122
|
+
|
123
|
+
public string UserName { get; set; }
|
124
|
+
|
125
|
+
public int TestFlg { get; set; }
|
126
|
+
|
127
|
+
public bool IsInstalled { get; set; }
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
public enum TestType
|
132
|
+
{
|
133
|
+
Test = 9,
|
134
|
+
Test1 = 1,
|
135
|
+
Test2 = 2,
|
136
|
+
Installed = 3,
|
137
|
+
Test3 = 4,
|
138
|
+
Test4 = 0
|
139
|
+
}
|
140
|
+
```
|
141
|
+
|
74
142
|
### 試したこと
|
75
143
|
|
76
144
|
|
1
テスト用のDB
title
CHANGED
File without changes
|
body
CHANGED
@@ -39,7 +39,7 @@
|
|
39
39
|
[TestMethod]
|
40
40
|
public void Index()
|
41
41
|
{
|
42
|
-
LargeController controller = new LargeController(new
|
42
|
+
LargeController controller = new LargeController(new DBTest());
|
43
43
|
|
44
44
|
ViewResult result = controller.Index() as ViewResult;
|
45
45
|
|
@@ -58,6 +58,19 @@
|
|
58
58
|
}
|
59
59
|
```
|
60
60
|
|
61
|
+
DBTest
|
62
|
+
```C#
|
63
|
+
public IEnumerable<UserViewModel> GetAllClients(string Param1, string Param2, string Param3, MySqlConnection conn)
|
64
|
+
{
|
65
|
+
return new UserViewModel[]
|
66
|
+
{
|
67
|
+
new UserViewModel() { UserId = 0, UserName = "あ", Count = 10},
|
68
|
+
new UserViewModel() { UserId = 100, UserName = "い", Count = 20 },
|
69
|
+
new UserViewModel() { UserId = 200, UserName = "う", Count = 30 },
|
70
|
+
}
|
71
|
+
}
|
72
|
+
```
|
73
|
+
|
61
74
|
### 試したこと
|
62
75
|
|
63
76
|
|