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."); }
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); }
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); }
/*--------------------------------------------------------------------------------------------*/ protected void CheckConsumePathThrows(FabStepFault pFault) { FabStepFault faultResult = TestUtil.Throws <FabStepFault>( () => GetStep().ConsumePath(MockPath.Object, GetToType())); Assert.AreEqual(pFault, faultResult, "Incorrect fault result."); CheckSuccess(false); }
/*--------------------------------------------------------------------------------------------*/ 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); }
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"); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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."); } }
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); }
/*--------------------------------------------------------------------------------------------*/ 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."); } }
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."); }
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); }
public void NewErrorCommand(string pRaw) { FabStepFault f = TestUtil.Throws <FabStepFault>(() => new TravPathItem(123, pRaw)); Assert.AreEqual(FabFault.Code.InvalidStep, f.ErrCode, "Incorrect ErrCode."); }