コード例 #1
0
        public async Task GetReturnsSuccessResponse()
        {
            var expected = new OtpGetLinkResponse();
            var request  = new OtpLinkRequest();

            _mock.Mock <IOtpLinkRequestProvider>()
            .Setup(instance => instance.GetAsync())
            .ReturnsAsync(request);
            _mock.Mock <IOtpResponseProvider>()
            .Setup(instance => instance.Get(request))
            .Returns(expected);

            var controller = _mock.Create <AuthOtpController>();
            var actual     = await controller.Get();

            ContentAssert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void ReturnsOptLinkResponse()
        {
            var otpToken  = "otp token";
            var secretKey = "secret key";
            var optLink   = "opt link";
            var userId    = new Guid("{F9AF06A7-E9CB-437A-B6DB-165A322070F1}");
            var request   = new OtpLinkRequest
            {
                IssuerName = "issuer name",
                UserEmail  = "user name",
                UserId     = userId
            };

            _mock.Mock <IOtpTokenProvider>()
            .Setup(instance => instance.Get(userId, secretKey))
            .Returns(otpToken);

            _mock.Mock <IOtpSecretKeyProvider>()
            .Setup(options => options.Get())
            .Returns(secretKey);

            _mock.Mock <IOtpLinkProvider>()
            .Setup(options => options.Get(request, secretKey))
            .Returns(optLink);

            var provider = _mock.Create <OtpResponseProvider>();
            var actual   = provider.Get(request);

            var expected = new OtpGetLinkResponse
            {
                OtpLink   = optLink,
                OtpToken  = otpToken,
                SecretKey = secretKey
            };

            ContentAssert.AreEqual(expected, actual);
        }