public virtual void Test8RollbackDeleteAndStore() { DeleteBase("rollback.neodatis"); NeoDatis.Odb.ODB odb = Open("rollback.neodatis", "u1", "p1"); odb.Store(new Function("f1")); odb.Store(new Function("f2")); odb.Store(new Function("f3")); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(); while (objects.HasNext()) { Function f = (Function)objects .Next(); f.SetName(OdbString.Substring(f.GetName(), 1)); odb.Store(f); } objects.Reset(); while (objects.HasNext()) { odb.Delete(objects.Next()); } for (int i = 0; i < 500; i++) { odb.Store(new Function("f3 - " + i)); } odb.Rollback(); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); AssertEquals(3, odb.GetObjects <Function>().Count ); odb.Close(); }
public void It_should_match_any_string_by_regex() { const string input = "Julia Spólnik"; var result = OdbString.Matches("Julia.*", input); Assert.That(result, Is.True); }
public virtual void Test9subString() { string s = "NeoDatis ODB - The open source object database"; string s1 = OdbString.Substring(s, 0, s.Length); string s2 = OdbString.Substring(s, 0, s.Length); AssertEquals(s1, s2); }
public virtual void Test8subString() { string s = "NeoDatis ODB - The open source object database"; for (int i = 0; i < 10; i++) { string s1 = OdbString.Substring(s, i, i + 15); string s2 = OdbString.Substring(s, i, i + 15); AssertEquals(s1, s2); } }
public override bool Evaluate(object candidate) { string regExp; if (candidate == null) { return(false); } candidate = AsAttributeValuesMapValue(candidate); if (candidate == null) { return(false); } // Like operator only work with String if (!(candidate is string)) { throw new OdbRuntimeException( NDatabaseError.QueryAttributeTypeNotSupportedInLikeExpression.AddParameter( candidate.GetType().FullName)); } var value = (string)candidate; var criterionValue = (string)TheObject; if (criterionValue.IndexOf("%", StringComparison.Ordinal) != -1) { regExp = criterionValue.Replace("%", "(.)*"); return(_isCaseSensitive ? OdbString.Matches(regExp, value) : OdbString.Matches(regExp.ToLower(), value.ToLower())); } if (!_isCaseSensitive) { criterionValue = criterionValue.ToLower(); value = value.ToLower(); } regExp = string.Format(LikePattern, criterionValue); return(OdbString.Matches(regExp, value)); }
public override bool Match(object valueToMatch) { string regExp = null; if (valueToMatch == null) { return(false); } // If it is a AttributeValuesMap, then gets the real value from the map if (valueToMatch is AttributeValuesMap) { AttributeValuesMap attributeValues = (AttributeValuesMap)valueToMatch; valueToMatch = attributeValues[attributeName]; } if (valueToMatch == null) { return(false); } // Like operator only work with String if (!(valueToMatch is string)) { throw new ODBRuntimeException(NeoDatisError.QueryAttributeTypeNotSupportedInLikeExpression .AddParameter(valueToMatch.GetType().FullName)); } string value = (string)valueToMatch; if (criterionValue.IndexOf("%") != -1) { regExp = OdbString.ReplaceToken(criterionValue, "%", "(.)*"); if (isCaseSensitive) { bool b = value != null && OdbString.Matches(regExp, value); return(b); } return(value != null && OdbString.Matches(regExp.ToLower() , value.ToLower())); } if (isCaseSensitive) { regExp = string.Format("(.)*%s(.)*", criterionValue); return(value != null && OdbString.Matches(regExp, value)); } regExp = string.Format("(.)*%s(.)*", criterionValue.ToLower()); return(value != null && OdbString.Matches(regExp, value.ToLower())); }
public virtual void Test() { string s = "olivier"; string ss = OdbString.Substring(s, 0, 1); AssertEquals(1, ss.Length); ss = OdbString.Substring(s, 0, 2); AssertEquals(2, ss.Length); System.Collections.Generic.IList <object> l = new System.Collections.Generic.List <object>(); l.Add("s1"); l.Add("s2"); l.Add("s3"); l.Add("s4"); l.Add("s5"); AssertEquals(1, NeoDatisCollectionUtil.SublistGeneric(l, 0, 1).Count); AssertEquals(2, NeoDatisCollectionUtil.SublistGeneric(l, 0, 2).Count); AssertEquals(3, NeoDatisCollectionUtil.SublistGeneric(l, 0, 3).Count); }
public virtual void Test() { string s = "olivier"; string ss = OdbString.Substring(s, 0, 1); AssertEquals(1, ss.Length); ss = OdbString.Substring(s, 0, 2); AssertEquals(2, ss.Length); System.Collections.Generic.IList <string> l = new System.Collections.Generic.List < string>(); l.Add("s1"); l.Add("s2"); l.Add("s3"); l.Add("s4"); l.Add("s5"); AssertEquals(1, l.SubList(0, 1).Count); AssertEquals(2, l.SubList(0, 2).Count); AssertEquals(3, l.SubList(0, 3).Count); }
public virtual void Test7Update() { DeleteBase("rollback.neodatis"); NeoDatis.Odb.ODB odb = Open("rollback.neodatis", "u1", "p1"); odb.Store(new Function("1function")); odb.Store(new Function("2function")); odb.Store(new Function("3function")); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(); while (objects.HasNext()) { Function f = (Function)objects .Next(); f.SetName(OdbString.Substring(f.GetName(), 1)); odb.Store(f); } odb.Rollback(); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); AssertEquals(3, odb.GetObjects <Function>().Count ); odb.Close(); }