public void AddEdge() { var plc = new PersonLikesCandy(); plc.Enjoyment = 0.84f; plc.TimesEaten = 54; plc.Notes = "Tastes great!"; const string perId = "a99"; const string candyId = "x1234"; var person = new Person { Id = perId }; var candy = new Candy { Id = candyId }; IWeaverQuery q = vGraph.AddEdge(person, plc, candy); int bracketI = q.Script.IndexOf('['); int bracketIClose = q.Script.LastIndexOf(']'); Assert.True(q.IsFinalized, "Incorrect IsFinalized."); Assert.NotNull(q.Script, "Script should be filled."); Assert.AreEqual("g.addEdge(g.v(_P0),g.v(_P1),_P2,[", q.Script.Substring(0, bracketI + 1), "Incorrect starting code."); Assert.AreEqual("]);", q.Script.Substring(bracketIClose), "Incorrect ending code."); //// string vals = q.Script.Substring(bracketI + 1, bracketIClose - bracketI - 1); Dictionary <string, string> pairMap = WeaverTestUtil.GetPropListDictionary(vals); Assert.AreEqual(3, pairMap.Keys.Count, "Incorrect Key count."); Assert.True(pairMap.ContainsKey(TestSchema.PersonLikesCandy_TimesEaten), "Missing TimesEaten key."); Assert.True(pairMap.ContainsKey(TestSchema.PersonLikesCandy_Enjoyment), "Missing Enjoyment key."); Assert.True(pairMap.ContainsKey(TestSchema.PersonLikesCandy_Notes), "Missing Notes key."); Assert.AreEqual("_P3", pairMap[TestSchema.PersonLikesCandy_TimesEaten], "Incorrect TimesEaten value."); Assert.AreEqual("_P4", pairMap[TestSchema.PersonLikesCandy_Enjoyment], "Incorrect Enjoyment value."); Assert.AreEqual("_P5", pairMap[TestSchema.PersonLikesCandy_Notes], "Incorrect Notes value."); var expectParams = new Dictionary <string, IWeaverQueryVal>(); expectParams.Add("_P0", new WeaverQueryVal(person.Id)); expectParams.Add("_P1", new WeaverQueryVal(candy.Id)); expectParams.Add("_P2", new WeaverQueryVal(TestSchema.PersonLikesCandy)); expectParams.Add("_P3", new WeaverQueryVal(plc.TimesEaten)); expectParams.Add("_P4", new WeaverQueryVal(plc.Enjoyment)); expectParams.Add("_P5", new WeaverQueryVal(plc.Notes)); WeaverTestUtil.CheckQueryParamsOriginalVal(q, expectParams); }
public void IsValidInVertexType(bool pValid) { Type t = (pValid ? typeof(Candy) : typeof(Person)); var plc = new PersonLikesCandy(); Assert.AreEqual(pValid, plc.IsValidInVertexType(t), "Incorrect result."); }
public void VertexType() { var r = new PersonLikesCandy(); Assert.AreEqual(typeof(Person), r.OutVertexType, "Incorrect FromVertexType."); Assert.AreEqual(typeof(Candy), r.InVertexType, "Incorrect ToVertexType."); }
public void Id() { PersonLikesCandy p = vAllEdges.Id <PersonLikesCandy>("abc-123"); Assert.NotNull(p, "Result should be filled."); vMockPath.Verify(x => x.AddItem(It.IsAny <WeaverStepCustom>()), Times.Once()); Assert.True(vAllEdges.ForSpecificId, "Incorrect ForSpecificId."); }
public void EdgeType() { var r = new PersonLikesCandy(); IWeaverEdgeType hasType = r.EdgeType; Assert.NotNull(hasType, "EdgeType should be filled."); Assert.NotNull((hasType as Likes), "Incorrect EdgeType."); }
public void ExactIndex() { PersonLikesCandy p = vAllEdges.ExactIndex <PersonLikesCandy>(x => x.TimesEaten, 5); Assert.NotNull(p, "Result should be filled."); vMockPath.Verify(x => x.AddItem(It.IsAny <WeaverStepExactIndex <PersonLikesCandy> >()), Times.Once()); Assert.False(vAllEdges.ForSpecificId, "Incorrect ForSpecificId."); }
public void NewRel() { var mockPath = new Mock <IWeaverPath>(); var person = new Person { Path = mockPath.Object }; PersonLikesCandy rel = person.OutLikesCandy; Assert.NotNull(rel, "Rel should be filled."); mockPath.Verify(x => x.AddItem(It.IsAny <PersonLikesCandy>()), Times.Once()); }
public void ItemAtIndex() { var i0 = new Root(); var i1 = new Person(); var i2 = new PersonLikesCandy(); var i3 = new Candy(); IWeaverPath p = NewPath(); p.AddItem(i0); p.AddItem(i1); p.AddItem(i2); p.AddItem(i3); Assert.AreEqual(4, p.Length, "Incorrect Length."); Assert.AreEqual(i0, p.ItemAtIndex(0), "Incorrect item at index 0."); Assert.AreEqual(i1, p.ItemAtIndex(1), "Incorrect item at index 1."); Assert.AreEqual(i2, p.ItemAtIndex(2), "Incorrect item at index 2."); Assert.AreEqual(i3, p.ItemAtIndex(3), "Incorrect item at index 3."); }
public void IndexOfItem() { var i0 = new Root(); var i1 = new Person(); var i2 = new PersonLikesCandy(); var i3 = new Candy(); IWeaverPath p = NewPath(); p.AddItem(i0); p.AddItem(i1); p.AddItem(i2); p.AddItem(i3); Assert.AreEqual(4, p.Length, "Incorrect Path.Length."); Assert.AreEqual(0, p.IndexOfItem(i0), "Incorrect item index at 0."); Assert.AreEqual(1, p.IndexOfItem(i1), "Incorrect item index at 1."); Assert.AreEqual(2, p.IndexOfItem(i2), "Incorrect item index at 2."); Assert.AreEqual(3, p.IndexOfItem(i3), "Incorrect item index at 3."); }