public void WhenResolutionSucceeds_ReturnsSuccessfulIdentifierResult_WithResolvedMeansId() { var cmdMock = new Mock <IResolveAuthenticationMeans>(MockBehavior.Strict); cmdMock.SetupGet(cmd => cmd.Method).Returns("MethodName"); cmdMock.SetupGet(cmd => cmd.Value).Returns("MeansValue"); var authMeans = new AuthenticationMeansDto { Id = TestIds.A }; var qResultMock = new Mock <IPagedResult <AuthenticationMeansDto> >(MockBehavior.Strict); qResultMock.SetupGet(r => r.TotalResults).Returns(1).Verifiable(); qResultMock.SetupGet(r => r.Items).Returns(new[] { authMeans }); var dispatcherMock = new Mock <IDispatcher>(MockBehavior.Strict); dispatcherMock.Setup(d => d.QueryAsync(It.Is <BrowseAuthenticationMeans>(q => q.Value == cmdMock.Object.Value && q.Method == cmdMock.Object.Method && q.ResultsPerPage == 1))) .ReturnsAsync(qResultMock.Object) .Verifiable(); var handler = new ResolveAuthenticationMeansHandler(dispatcherMock.Object); var result = handler.HandleAsync(cmdMock.Object, new Mock <ICorrelationContext>().Object).GetAwaiter().GetResult(); Assert.IsTrue(result.Successful); Assert.IsTrue(result.Id.HasValue); Assert.AreEqual(authMeans.Id, result.Id.Value); qResultMock.Verify(); dispatcherMock.Verify(); }
public void GetAuthenticationMeans_ConstructsQuery_ReturnsResultOfDispatch() { var meansId = TestIds.A; var result = new AuthenticationMeansDto(); _dispatcherMock.Setup(d => d.QueryAsync(It.Is <GetAuthenticationMeans>(q => q.Id == meansId))).ReturnsAsync(result).Verifiable(); var actionResult = _controller.GetAuthenticationMeans(meansId).GetAwaiter().GetResult(); Assert.AreEqual(actionResult.Value, result); _dispatcherMock.Verify(); }
public async Task <ActionResult> UpdateAuthenticationMeans(Guid id, AuthenticationMeansDto meansDto) => await SendAndHandleOperationCommand(new UpdateAuthenticationMeans(id, meansDto.Label, meansDto.Type, meansDto.ValidSince, meansDto.ValidUntil));