質問編集履歴
7
title
CHANGED
File without changes
|
body
CHANGED
@@ -41,7 +41,7 @@
|
|
41
41
|
private TestsController _controller = null;
|
42
42
|
|
43
43
|
public TestsControllerTest() {
|
44
|
-
this._loggerMock = new Mock<ILogger<
|
44
|
+
this._loggerMock = new Mock<ILogger<TestsController>>();
|
45
45
|
this._userCheckServiceMock = new Mock<IUserCheckService>();
|
46
46
|
|
47
47
|
this._user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] {
|
@@ -55,7 +55,7 @@
|
|
55
55
|
// この方法だとうまくいかなかった
|
56
56
|
this._userCheckServiceMock.Setup(e => e.IsCheckedAsync(this._user, null)).ReturnsAsync(true);
|
57
57
|
|
58
|
-
this._controller = new
|
58
|
+
this._controller = new TestsController(
|
59
59
|
this._loggerMock.Object,
|
60
60
|
this._userCheckServiceMock.Object
|
61
61
|
);
|
6
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -12,6 +12,9 @@
|
|
12
12
|
|
13
13
|
①の作り方をした時のみ、現象が発生しています。
|
14
14
|
|
15
|
+
(追記)
|
16
|
+
開発環境: Windows10 Pro, Visual Studio Professional 2019, .NET 5
|
17
|
+
|
15
18
|
```C#
|
16
19
|
using ApplicationService;
|
17
20
|
using DomainModel;
|
5
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ユニットテストを作成しています。MoqのSetupで引数を2つ指定すると、正しくSetupをしてくれない場合があり、困っています。
|
1
|
+
C#、ASP.NET Core MVCでユニットテストを作成しています。MoqのSetupで引数を2つ指定すると、正しくSetupをしてくれない場合があり、困っています。
|
2
2
|
どなたかご教授お願いします。
|
3
3
|
|
4
4
|
わかっていることとしては、
|
4
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,6 +13,15 @@
|
|
13
13
|
①の作り方をした時のみ、現象が発生しています。
|
14
14
|
|
15
15
|
```C#
|
16
|
+
using ApplicationService;
|
17
|
+
using DomainModel;
|
18
|
+
using DomainService;
|
19
|
+
using Microsoft.AspNetCore.Http;
|
20
|
+
using Microsoft.AspNetCore.Mvc;
|
21
|
+
using Microsoft.Extensions.Logging;
|
22
|
+
using Moq;
|
23
|
+
using System;
|
24
|
+
using System.Collections.Generic;
|
16
25
|
using System.Linq;
|
17
26
|
using System.Security.Claims;
|
18
27
|
using System.Threading.Tasks;
|
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -26,7 +26,7 @@
|
|
26
26
|
private Mock<IUserCheckService> _userCheckServiceMock = null;
|
27
27
|
|
28
28
|
private ClaimsPrincipal _user = null;
|
29
|
-
private
|
29
|
+
private TestsController _controller = null;
|
30
30
|
|
31
31
|
public TestsControllerTest() {
|
32
32
|
this._loggerMock = new Mock<ILogger<PartsInformationsController>>();
|
2
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -82,7 +82,7 @@
|
|
82
82
|
|
83
83
|
namespace UserInterface.Controllers {
|
84
84
|
public class TestsController : Controller {
|
85
|
-
private readonly ILogger<
|
85
|
+
private readonly ILogger<TestsController> _logger;
|
86
86
|
private readonly IUserCheckService _userCheckService;
|
87
87
|
|
88
88
|
public TestsController(ILogger<TestsController> logger, IUserCheckService userCheckService) {
|
1
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,6 +10,8 @@
|
|
10
10
|
②Contollerの引数を単一データで渡す時
|
11
11
|
this._userCheckService.IsCheckedAsyncの引数が2つでも、問題なくtrueになりました。
|
12
12
|
|
13
|
+
①の作り方をした時のみ、現象が発生しています。
|
14
|
+
|
13
15
|
```C#
|
14
16
|
using System.Linq;
|
15
17
|
using System.Security.Claims;
|