0
私は認証擬似を実装しようとしていますが、私はMoqを使いたいと思います。しかし()
がAuthenticationManager.vbVBでMoqを使用した単体テストでの式
<TestMethod()> Public Sub Login()
' arrange
Dim _controller As AuthenticationManager = New AuthenticationManager
Dim httpContextBase As HttpContextBase = Mock <httpContextBase>()
' Identiy
Dim result As Boolean = _controller.Login(HttpContextBase, Identiy)
...
AuthenticationManager.Test.vb
Public Shared Sub Login(httpContextBase As HttpContextBase, identity As ClaimsIdentity)
Dim ctx = httpContextBase.Request.GetOwinContext()
Dim authenticationManager = ctx.Authentication
authenticationManager.SignIn(identity) ' Let's go Cookie!
End Sub
をExpression expected.
を示していますが、私は私を助けることができるのですか?あなたはモックをインスタンス化して、あなたがHttpContextBase
として変数を宣言しMock <HttpContextBase>
としてそれを初期化しようとしていたプラスあなたにNew
キーワードを残し、それ
<TestMethod()> Public Sub Login()
' arrange
Dim _controller As AuthenticationManager = New AuthenticationManager
Dim httpContextMock As Mock<HttpContextBase> = New Mock<HttpContextBase>()
Dim httpContextBase As HttpContextBase = httpContextMock.Object
...
から希望のオブジェクトを取得する必要があり
ありがとうございました。私は、owinの実装をテストしたいと思います。 4行目の ' =新しいモック()'は 'End of statement expected'と書いてあります。 –
コードをテストしましたか?何も起こっていない... –
私はテストすることは何もありません。いくつかの構文エラーを含むコードスニペットを提供しただけです。それが私の答えに基づいています。期待される行動が何であるかを説明していないときに何も起こらなかったと言っても、他人がそれを助けるための情報を本当に提供していないのですか?この回答は、元の投稿に記載されている問題を解決します。もともと表示されていたもの以外に修正が必要なものがある場合は、新しい質問をする必要があります。 – Nkosi