InitialAuthDeviceRegistration_GivenResultIsSuccessful_ExpectCredentialCreateOptionsWithOptionsSet()
        {
            var mediator = new Mock <IMediator>();

            mediator
            .Setup(x => x.Send(
                       It.IsAny <InitiateAuthenticatorDeviceEnrollmentCommand>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(
                Result.Ok <InitiateAuthenticatorDeviceEnrollmentCommandResult, ErrorData>(
                    new InitiateAuthenticatorDeviceEnrollmentCommandResult(new CredentialCreateOptions()
            {
                Status = "ok",
            })));
            var authenticationService = new Mock <IAuthenticationService>();

            var controller         = new AuthDeviceApiController(mediator.Object, authenticationService.Object);
            var tempDataDictionary = new Mock <ITempDataDictionary>();

            controller.TempData = tempDataDictionary.Object;

            var response = await controller.InitialAuthDeviceRegistration(new InitialAuthDeviceRegistrationRequest());

            var result  = Assert.IsType <JsonResult>(response);
            var options = Assert.IsType <CredentialCreateOptions>(result.Value);

            Assert.Equal("ok", options.Status);
        }
        public async Task RevokeDevice_GivenCommandExecutes_ExpectSuccessfulJsonResult()
        {
            var mediator = new Mock <IMediator>();

            mediator
            .Setup(x => x.Send(
                       It.IsAny <RevokeAuthenticatorDeviceCommand>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(
                ResultWithError.Ok <ErrorData>());
            var authenticationService = new Mock <IAuthenticationService>();

            var controller = new AuthDeviceApiController(mediator.Object, authenticationService.Object);

            var response = await controller.RevokeDevice(new RevokeDeviceRequest());

            var result  = Assert.IsType <JsonResult>(response);
            var options = Assert.IsType <RevokeDeviceResponse>(result.Value);

            Assert.True(options.IsSuccess);
        }