示例#1
0
        public async Task ForgotControllerCodeTestTooMany()
        {
            var data  = new ForgotDataHandler();
            var logic = new CoreApiLogicHandler();

            data.ResultConfig = new UserConfig()
            {
                ForgotCounter = 11
            };

            var start = ForgotData.GetStart();

            data.Result.Setup(m => m.Execute(It.IsAny <UserByEmail>())).Returns(StandardUser);

            var controller = new ForgotController(data, Cloud, logic);
            var result     = await controller.Code(start) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();

            logic.HasExecuted.Should().BeFalse();

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <UserByEmail>()), Times.Once);
        }
示例#2
0
        public async Task ForgotControllerCodeTest()
        {
            var data  = new ForgotDataHandler();
            var logic = new CoreApiLogicHandler();

            data.ResultConfig = new UserConfig();

            var confirm = ModelConfirm <UserConfig> .CreateSuccess(data.ResultConfig);

            var start = ForgotData.GetStart();

            data.Result.Setup(m => m.Execute(It.IsAny <UserByEmail>())).Returns(StandardUser);
            data.Result.Setup(m => m.Execute(It.IsAny <Persist <UserConfig> >())).Returns(confirm);
            logic.Result.Setup(m => m.Execute(It.IsAny <SimpleNotify>())).Returns(ActionConfirm.CreateSuccess("ok"));

            var controller = new ForgotController(data, Cloud, logic);
            var result     = await controller.Code(start) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();

            logic.HasExecuted.Should().BeTrue();
            logic.Result.Verify(s => s.Execute(It.IsAny <SimpleNotify>()), Times.Once);

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <UserByEmail>()), Times.Once);
        }
示例#3
0
        public async Task ForgotControllerReplyTestWrongCode()
        {
            var data  = new ForgotDataHandler();
            var logic = new CoreApiLogicHandler();

            data.ResultConfig = new UserConfig()
            {
                ForgotCode = "Nonsense", ResetAuth = "Nonsense"
            };

            var reply = ForgotData.GetReply();

            data.Result.Setup(m => m.Execute(It.IsAny <UserByEmail>())).Returns(StandardUser);

            var controller = new ForgotController(data, Cloud, logic);
            var result     = await controller.Reply(reply) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();

            logic.HasExecuted.Should().BeFalse();

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <UserByEmail>()), Times.Once);
        }
示例#4
0
        public async Task ForgotControllerResetTestNoUser()
        {
            var data  = new ForgotDataHandler();
            var logic = new CoreApiLogicHandler();

            var reset = ForgotData.GetReset();

            data.Result.Setup(m => m.Execute(It.IsAny <UserByEmail>())).Returns(null);

            var controller = new ForgotController(data, Cloud, logic);
            var result     = await controller.Reset(reset) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();

            logic.HasExecuted.Should().BeFalse();

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <UserByEmail>()), Times.Once);
        }
示例#5
0
        public async Task ForgotControllerResetTest()
        {
            var data  = new ForgotDataHandler();
            var logic = new CoreApiLogicHandler();

            data.ResultUser   = StandardUser;
            data.ResultConfig = new UserConfig()
            {
                ForgotCode = ForgotData.GetReset().Code, ResetCode = ForgotData.GetReset().ResetCode
            };

            var confirmUser = ModelConfirm <User> .CreateSuccess(StandardUser);

            var confirmConfig = ModelConfirm <UserConfig> .CreateSuccess(data.ResultConfig);

            var reset = ForgotData.GetReset();
            var auth  = LoginData.GetAuth();

            data.Result.Setup(m => m.Execute(It.IsAny <UserByEmail>())).Returns(StandardUser);
            data.Result.Setup(m => m.Execute(It.IsAny <Persist <User> >())).Returns(confirmUser);
            data.Result.Setup(m => m.Execute(It.IsAny <Persist <UserConfig> >())).Returns(confirmConfig);
            logic.Result.Setup(m => m.Execute(It.IsAny <SigninAuth>())).Returns(auth);

            var controller = new ForgotController(data, Cloud, logic);
            var result     = await controller.Reset(reset) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();

            logic.HasExecuted.Should().BeTrue();
            logic.Result.Verify(s => s.Execute(It.IsAny <SigninAuth>()), Times.Once);

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <UserByEmail>()), Times.Once);
        }