Exemple #1
0
        public void NewErrorParamEmpty(string pRaw)
        {
            FabStepFault f = TestUtil.Throws <FabStepFault>(() => new TravPathItem(123, pRaw));

            Assert.AreEqual(FabFault.Code.InvalidParamSyntax, f.ErrCode, "Incorrect ErrCode.");
            Assert.AreNotEqual(-1, f.Message.IndexOf("empty"), "Incorrect message.");
        }
Exemple #2
0
        public void ErrorCountParamRange(int pCount, bool pLow)
        {
            MockItem.Setup(x => x.GetParamAt <int>(0)).Returns(pCount);
            var f = new FabStepFault(FabFault.Code.IncorrectParamValue, 0, "", "", 0);

            SetupFault(f, (pLow ? "less" : "greater") + " than");
            CheckConsumePathThrows(f);
        }
Exemple #3
0
        public void ErrorOperationParamAccepted()
        {
            MockItem.Setup(x => x.GetParamAt <string>(0)).Returns("fake");
            var f = new FabStepFault(FabFault.Code.IncorrectParamValue, 0, "", "", 0);

            SetupFault(f, "Accepted values");
            CheckConsumePathThrows(f);
        }
Exemple #4
0
        /*--------------------------------------------------------------------------------------------*/
        protected void CheckConsumePathThrows(FabStepFault pFault)
        {
            FabStepFault faultResult = TestUtil.Throws <FabStepFault>(
                () => GetStep().ConsumePath(MockPath.Object, GetToType()));

            Assert.AreEqual(pFault, faultResult, "Incorrect fault result.");
            CheckSuccess(false);
        }
Exemple #5
0
 /*--------------------------------------------------------------------------------------------*/
 protected void SetupFault(FabStepFault pFault, string pMessageContains)
 {
     MockItem
     .Setup(x => x.NewStepFault(pFault.ErrCode, It.IsAny <string>(), pFault.ParamIndex, null))
     .Callback((FabFault.Code c, string m, int pi, Exception e) =>
               TestUtil.AssertContains("Fault.Message", m, pMessageContains))
     .Returns(pFault);
 }
Exemple #6
0
        public void ErrorInvalidStep()
        {
            FabStepFault f = TestUtil.Throws <FabStepFault>(
                () => vOper.Execute(vMockOpCtx.Object, "Users/BadStep(123)"));

            TestUtil.AssertContains("Fault.Message", f.Message, "not valid");
            TestUtil.AssertContains("Fault.Message", f.Message, "BadStep");
        }
Exemple #7
0
        public void ErrorAliasParamFormat()
        {
            MockItem.Setup(x => x.GetParamAt <string>(0)).Returns("badAL!A$");
            var f = new FabStepFault(FabFault.Code.IncorrectParamValue, 0, "", "", 0);

            SetupFault(f, "format");
            CheckConsumePathThrows(f);
        }
Exemple #8
0
        public void ErrorAliasParamLength()
        {
            MockItem.Setup(x => x.GetParamAt <string>(0)).Returns("abcdefghi");
            var f = new FabStepFault(FabFault.Code.IncorrectParamValue, 0, "", "", 0);

            SetupFault(f, "cannot exceed");
            CheckConsumePathThrows(f);
        }
Exemple #9
0
        public void ErrorDirectlyAfterAs()
        {
            MockPath.Setup(x => x.DoesBackTouchAs(vAlias)).Returns(true);
            var f = new FabStepFault(FabFault.Code.InvalidStep, 0, "", "", 0);

            SetupFault(f, "directly after");
            CheckConsumePathThrows(f);
        }
Exemple #10
0
        public void ErrorAliasNotFound()
        {
            MockPath.Setup(x => x.HasAlias(vAlias)).Returns(false);
            var f = new FabStepFault(FabFault.Code.IncorrectParamValue, 0, "", "", 0);

            SetupFault(f, "not be found");
            CheckConsumePathThrows(f);
        }
Exemple #11
0
        public void ErrorDuplicateAlias()
        {
            MockPath.Setup(x => x.HasAlias(vAlias)).Returns(true);
            var f = new FabStepFault(FabFault.Code.IncorrectParamValue, 0, "", "", 0);

            SetupFault(f, "in use");
            CheckConsumePathThrows(f);
        }
Exemple #12
0
        public void ErrorDateParamRange(int pIndex, byte pValue, bool pLow)
        {
            MockItem.Setup(x => x.GetParamAt <byte>(pIndex)).Returns(pValue);
            var f = new FabStepFault(FabFault.Code.IncorrectParamValue, 0, "", "", pIndex);

            SetupFault(f, (pLow ? "less" : "greater") + " than");
            CheckConsumePathThrows(f);
        }
Exemple #13
0
        public void ErrorYearParamRange(long pYear, bool pLow)
        {
            MockItem.Setup(x => x.GetParamAt <long>(1)).Returns(pYear);
            var f = new FabStepFault(FabFault.Code.IncorrectParamValue, 0, "", "", 1);

            SetupFault(f, (pLow ? "less" : "greater") + " than");
            CheckConsumePathThrows(f);
        }
Exemple #14
0
        public void ErrorNotAllowed()
        {
            string confAlias;

            MockPath.Setup(x => x.AllowBackToAlias(vAlias, out confAlias)).Returns(false);
            var f = new FabStepFault(FabFault.Code.InvalidStep, 0, "", "", 0);

            SetupFault(f, "Cannot traverse");
            CheckConsumePathThrows(f);
        }
Exemple #15
0
        public void VerifyParamCount(string pRaw, int pMin, int pMax, bool pError)
        {
            var          pi = new TravPathItem(123, pRaw);
            FabStepFault f  = TestUtil.CheckThrows <FabStepFault>(
                pError, () => pi.VerifyParamCount(pMin, pMax));

            if (f != null)
            {
                Assert.AreEqual(FabFault.Code.IncorrectParamCount, f.ErrCode, "Incorrect ErrCode.");
            }
        }
Exemple #16
0
        public void ErrorNoActiveMember()
        {
            vMemId = null;
            MockPath.SetupGet(x => x.MemberId).Returns(vMemId);

            var f = new FabStepFault(FabFault.Code.InvalidStep, 0, "", "");

            SetupFault(f, "active");

            CheckConsumePathThrows(f);
        }
Exemple #17
0
        /*--------------------------------------------------------------------------------------------*/
        private void CheckGetParamAt <T>(int pIndex, T pExpectResult, bool pExpectError)
        {
            var pi     = new TravPathItem(123, RawParamTypes);
            T   result = default(T);

            FabStepFault f = TestUtil.CheckThrows <FabStepFault>(pExpectError, () => {
                result = pi.GetParamAt <T>(pIndex);
            });

            if (pExpectError)
            {
                Assert.AreEqual(FabFault.Code.IncorrectParamType, f.ErrCode, "Incorrect ErrCode.");
            }
            else
            {
                Log.Debug("Result: " + result);
                Assert.AreEqual(pExpectResult, result, "Incorrect result.");
            }
        }
Exemple #18
0
        public void NewStepFault(int pParamI, string pExpectRawParam)
        {
            const FabFault.Code code = FabFault.Code.InvalidStep;
            const string        msg  = "My Error Message.";
            var       innerEx        = new Exception("Inner!");
            const int stepIndex      = 4;

            var          pi     = new TravPathItem(stepIndex, RawParamTypes);
            FabStepFault result = pi.NewStepFault(code, msg, pParamI, innerEx);

            Log.Debug("Message:\n\n" + result.Message);

            Assert.NotNull(result, "Result should be filled.");
            Assert.AreEqual(code, result.ErrCode, "Incorrect ErrCode.");
            Assert.AreEqual(0, result.Message.IndexOf(msg), "Incorrect Message.");
            Assert.AreEqual(stepIndex, result.StepIndex, "Incorrect StepIndex.");
            Assert.AreEqual(RawParamTypes, result.StepText, "Incorrect StepText.");
            Assert.AreEqual(pParamI, result.ParamIndex, "Incorrect ParamIndex.");
            Assert.AreEqual(pExpectRawParam, result.ParamText, "Incorrect ParamText.");
        }
Exemple #19
0
		public void ErrorValueParamEmpty() {
			MockItem.Setup(x => x.GetParamAt<string>(0)).Returns("");
			var f = new FabStepFault(FabFault.Code.IncorrectParamValue, 0, "", "", 0);
			SetupFault(f, "empty");
			CheckConsumePathThrows(f);
		}
Exemple #20
0
        public void NewErrorCommand(string pRaw)
        {
            FabStepFault f = TestUtil.Throws <FabStepFault>(() => new TravPathItem(123, pRaw));

            Assert.AreEqual(FabFault.Code.InvalidStep, f.ErrCode, "Incorrect ErrCode.");
        }