public void BuildParameterizedString(string pPropName, object pValue, string pExpect) { Expression <Func <Person, object> > func = null; switch (pPropName) { case "PersonId": func = (p => p.PersonId); break; case "Name": func = (p => p.Name); break; case "Age": func = (p => p.Age); break; } var val = (pValue is string? "_P0" : pValue + ""); if (pValue == null) { val = "null"; } vMockQuery.Setup(x => x.AddParam(It.IsAny <WeaverQueryVal>())).Returns(val); vKeyIndex = new WeaverStepExactIndex <Person>(func, pValue + ""); vKeyIndex.Path = vMockPath.Object; Assert.AreEqual(pExpect, vKeyIndex.BuildParameterizedString(), "Incorrect result."); }
public void IndexNameInvalid() { vKeyIndex = new WeaverStepExactIndex <Person>(n => (n.PersonId == 99), 1); vKeyIndex.Path = vMockPath.Object; WeaverTestUtil.CheckThrows <WeaverStepException>(true, () => { var p = vKeyIndex.IndexName; }); }
/*--------------------------------------------------------------------------------------------*/ protected T ExactIndexInner <T>(Expression <Func <T, object> > pProperty, object pValue) where T : IWeaverElement, new() { var ei = new WeaverStepExactIndex <T>(pProperty, pValue); Path.AddItem(ei); return(new T { Path = Path }); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ protected override void SetUp() { base.SetUp(); vMockQuery = new Mock <IWeaverQuery>(); vMockPath = new Mock <IWeaverPath>(); vMockPath.SetupGet(x => x.Query).Returns(vMockQuery.Object); vMockPath.SetupGet(x => x.Config).Returns(WeavInst.Config); vKeyIndex = new WeaverStepExactIndex <Person>(x => x.PersonId, 123); vKeyIndex.Path = vMockPath.Object; }