Exemple #1
0
        public void ValidateTokenValueStep(string tokenName, string rule, string value)
        {
            var context = new ValidateTokenAction.ValidateTokenActionContext(tokenName, rule, value);

            this.actionPipelineService
            .PerformAction <ValidateTokenAction>(null, context)
            .CheckResult();
        }
Exemple #2
0
        public void ValidateTokenValueStep(string tokenName, string rule, string value)
        {
            var context = new ValidateTokenAction.ValidateTokenActionContext(tokenName, rule, value);

            this.actionPipelineService
                .PerformAction<ValidateTokenAction>(null, context)
                .CheckResult();
        }
        public void TestExecuteWhenTokenReturnsValidValueReturnsSuccess()
        {
            var tokenManager = new Mock<ITokenManager>(MockBehavior.Strict);
            tokenManager.Setup(p => p.GetTokenByKey("token1")).Returns("my value");

            var validateItemAction = new ValidateTokenAction(tokenManager.Object);

            var context = new ValidateTokenAction.ValidateTokenActionContext("token1", "equals", "my value");
            context.ValidationTable.Process();

            var result = validateItemAction.Execute(context);

            Assert.AreEqual(true, result.Success);

            tokenManager.VerifyAll();
        }
        public void TestExecuteWhenTokenReturnsValidValueReturnsSuccess()
        {
            var tokenManager = new Mock <ITokenManager>(MockBehavior.Strict);

            tokenManager.Setup(p => p.GetTokenByKey("token1")).Returns("my value");

            var validateItemAction = new ValidateTokenAction(tokenManager.Object);

            var context = new ValidateTokenAction.ValidateTokenActionContext("token1", "equals", "my value");

            context.ValidationTable.Process();

            var result = validateItemAction.Execute(context);

            Assert.AreEqual(true, result.Success);

            tokenManager.VerifyAll();
        }
        public void TestExecuteWhenTokenReturnsNullReturnsFailure()
        {
            var tokenManager = new Mock<ITokenManager>(MockBehavior.Strict);
            tokenManager.Setup(p => p.GetTokenByKey("doesnotexist")).Returns((string)null);

            var validateItemAction = new ValidateTokenAction(tokenManager.Object);

            var context = new ValidateTokenAction.ValidateTokenActionContext("doesnotexist", "equals", "my value");
            context.ValidationTable.Process();

            var result = validateItemAction.Execute(context);

            Assert.AreEqual(false, result.Success);

            Assert.IsNotNull(result.Exception);
            StringAssert.Contains(result.Exception.Message, "doesnotexist");

            tokenManager.VerifyAll();
        }
        public void TestExecuteWhenTokenReturnsNullReturnsFailure()
        {
            var tokenManager = new Mock <ITokenManager>(MockBehavior.Strict);

            tokenManager.Setup(p => p.GetTokenByKey("doesnotexist")).Returns((string)null);

            var validateItemAction = new ValidateTokenAction(tokenManager.Object);

            var context = new ValidateTokenAction.ValidateTokenActionContext("doesnotexist", "equals", "my value");

            context.ValidationTable.Process();

            var result = validateItemAction.Execute(context);

            Assert.AreEqual(false, result.Success);

            Assert.IsNotNull(result.Exception);
            StringAssert.Contains(result.Exception.Message, "doesnotexist");

            tokenManager.VerifyAll();
        }