public void CoreCommand_Provider() { var engine = new Concrete.DataEngine(); var link = new FakeLink(engine, NestableTransactionMode.Database); var other = new FakeCommandProvider(link); other.TheCommand.From(x => x.Employees); var provider = new FakeCommandProvider(link); provider.TheCommand.From(x => x(other).As(x.Emp)); provider.TheCommand.Select(x => x.Number.As(x.Id)); provider.TheCommand.Where(x => x.Name == "James Bond"); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse(provider, pars); Assert.AreEqual( "SELECT Number AS Id FROM (SELECT * FROM Employees) AS Emp WHERE (Name = #0)" , result); Assert.AreEqual(1, pars.Count); Assert.AreEqual("James Bond", pars[0].Value); }
public void NullValues() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse(null, pars); Assert.AreEqual("NULL", result); Assert.AreEqual(0, pars.Count); }
public void ShortTag() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func<dynamic, object>)(x => x.Name), pars); Assert.AreEqual("Name", result); Assert.AreEqual(0, pars.Count); }
public void GetMember() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func<dynamic, object>)(x => x.Alpha.Beta), pars); Assert.AreEqual("Alpha.Beta", result); Assert.AreEqual(0, pars.Count); }
public void GetMember() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func <dynamic, object>)(x => x.Alpha.Beta), pars); Assert.AreEqual("Alpha.Beta", result); Assert.AreEqual(0, pars.Count); }
public void Dispose_Twice() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); parser.Dispose(); parser.Dispose(); Assert.IsTrue(parser.IsDisposed); Assert.IsNull(parser.Engine); }
public void Method_Distinct() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func <dynamic, object>)(x => x.Distinct(x.Alpha)), pars); Assert.AreEqual("DISTINCT Alpha", result); Assert.AreEqual(0, pars.Count); }
public void Is_NotNull() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func <dynamic, object>)(x => x.Name != null), pars); Assert.AreEqual("(Name IS NOT NULL)", result); Assert.AreEqual(0, pars.Count); }
public void GetIndexed_RoundedSyntax() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func <dynamic, object>)(x => x("James", "Bond")), pars); Assert.AreEqual("JamesBond", result); Assert.AreEqual(0, pars.Count); }
public void LongTag() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); Parser.ComplexTags = true; var result = parser.Parse((Func<dynamic, object>)(emp => emp.Name), pars); Assert.AreEqual("emp.Name", result); Assert.AreEqual(0, pars.Count); }
public void ShortTag() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func <dynamic, object>)(x => x.Name), pars); Assert.AreEqual("Name", result); Assert.AreEqual(0, pars.Count); }
public void Binary_WithNegate() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func <dynamic, object>)(x => - x.Name + 5), pars); Assert.AreEqual("(-Name + #0)", result); Assert.AreEqual(1, pars.Count); Assert.AreEqual(5, pars[0].Value); }
public void LongTag() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); Parser.ComplexTags = true; var result = parser.Parse((Func <dynamic, object>)(emp => emp.Name), pars); Assert.AreEqual("emp.Name", result); Assert.AreEqual(0, pars.Count); }
public void Validate_Standard_Transformers() { var obj = new Concrete.DataEngine(); Assert.IsTrue(obj.IsTransformerRegistered<CalendarDate>()); Assert.IsTrue(obj.IsTransformerRegistered<ClockTime>()); var rd = obj.TryTransform(new CalendarDate(2000, 1, 1)); Assert.AreEqual(new DateTime(2000, 1, 1), (DateTime)rd); var rc = obj.TryTransform(new ClockTime(1, 1, 1)); Assert.AreEqual("1:1:1", (string)rc); }
public void Method_NotIn() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func <dynamic, object>)(x => x.Alpha.NotIn(x.Beta, "37", "40")), pars); Assert.AreEqual("NOT Alpha IN (Beta, #0, #1)", result); Assert.AreEqual(2, pars.Count); Assert.AreEqual("37", pars[0].Value); Assert.AreEqual("40", pars[1].Value); }
public void SetMember() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func<dynamic, object>)(x => x.Alpha.Beta = null), pars); Assert.AreEqual("Alpha.Beta = (NULL)", result); Assert.AreEqual(0, pars.Count); result = parser.Parse((Func<dynamic, object>)(x => x.Alpha.Beta = "Bond"), pars); Assert.AreEqual("Alpha.Beta = (#0)", result); Assert.AreEqual(1, pars.Count); Assert.AreEqual("Bond", pars[0].Value); }
public void Validate_Standard_Transformers() { var obj = new Concrete.DataEngine(); Assert.IsTrue(obj.IsTransformerRegistered <CalendarDate>()); Assert.IsTrue(obj.IsTransformerRegistered <ClockTime>()); var rd = obj.TryTransform(new CalendarDate(2000, 1, 1)); Assert.AreEqual(new DateTime(2000, 1, 1), (DateTime)rd); var rc = obj.TryTransform(new ClockTime(1, 1, 1)); Assert.AreEqual("1:1:1", (string)rc); }
public void SetMember() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func <dynamic, object>)(x => x.Alpha.Beta = null), pars); Assert.AreEqual("Alpha.Beta = (NULL)", result); Assert.AreEqual(0, pars.Count); result = parser.Parse((Func <dynamic, object>)(x => x.Alpha.Beta = "Bond"), pars); Assert.AreEqual("Alpha.Beta = (#0)", result); Assert.AreEqual(1, pars.Count); Assert.AreEqual("Bond", pars[0].Value); }
public void Disposing() { DataEngine.ClearEngines(); var template = new Concrete.DataEngine(); var cloned = template.Clone(new Dictionary <string, object>() { { "InvariantName", "WhateverName" }, { "ServerVersion", "8" } }); DataEngine.RegisterEngine(cloned); Assert.AreEqual(1, DataEngine.Engines.Count()); Assert.AreEqual(cloned, DataEngine.Engines.First()); cloned.Dispose(); Assert.AreEqual(0, DataEngine.Engines.Count()); }
public void Disposing() { DataEngine.ClearEngines(); var template = new Concrete.DataEngine(); var cloned = template.Clone(new Dictionary<string, object>() { { "InvariantName", "WhateverName"}, { "ServerVersion", "8"} }); DataEngine.RegisterEngine(cloned); Assert.AreEqual(1, DataEngine.Engines.Count()); Assert.AreEqual(cloned, DataEngine.Engines.First()); cloned.Dispose(); Assert.AreEqual(0, DataEngine.Engines.Count()); }
public void Embedded_Commands() { var engine = new Concrete.DataEngine(); var link = new FakeLink(engine, NestableTransactionMode.Database); var inner = link.Raw("SELECT * From WhoKnows WHERE Name == {0}", "James Bond"); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); pars.AddCreate("PlaceHolderForPositionCero"); Assert.AreEqual(1, pars.Count); var result = parser.Parse(inner, pars); Assert.AreEqual("SELECT * From WhoKnows WHERE Name == #1", result); Assert.AreEqual(2, pars.Count); Assert.AreEqual("James Bond", pars[1].Value); }
public void Locate_With_MinVersion() { DataEngine.ClearEngines(); var template = new Concrete.DataEngine(); DataEngine.RegisterEngine(template.Clone(new Dictionary<string, object>() { { "InvariantName", "WhateverName"}, { "ServerVersion", "8"} })); DataEngine.RegisterEngine(template.Clone(new Dictionary<string, object>() { { "InvariantName", "WhateverName"}, { "ServerVersion", "10"} })); var engine = DataEngine.Locate("WhateverName", minVersion: "9"); Assert.IsNotNull(engine); Assert.AreEqual("10", engine.ServerVersion); }
public void Locate_With_MaxVersion() { DataEngine.ClearEngines(); var template = new Concrete.DataEngine(); DataEngine.RegisterEngine(template.Clone(new Dictionary <string, object>() { { "InvariantName", "WhateverName" }, { "ServerVersion", "8" } })); DataEngine.RegisterEngine(template.Clone(new Dictionary <string, object>() { { "InvariantName", "WhateverName" }, { "ServerVersion", "10" } })); var engine = DataEngine.Locate("WhateverName", maxVersion: "9"); Assert.IsNotNull(engine); Assert.AreEqual("8", engine.ServerVersion); }
public void GetIndexed_SquareSyntax() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func<dynamic, object>)(x => x.Name["James", "Bond"]), pars); Assert.AreEqual("NameJamesBond", result); Assert.AreEqual(0, pars.Count); }
public void Method_NotIn() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func<dynamic, object>)(x => x.Alpha.NotIn(x.Beta, "37", "40")), pars); Assert.AreEqual("NOT Alpha IN (Beta, #0, #1)", result); Assert.AreEqual(2, pars.Count); Assert.AreEqual("37", pars[0].Value); Assert.AreEqual("40", pars[1].Value); }
public void Method_Distinct() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func<dynamic, object>)(x => x.Distinct(x.Alpha)), pars); Assert.AreEqual("DISTINCT Alpha", result); Assert.AreEqual(0, pars.Count); }
public void Binary_WithNegate() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func<dynamic, object>)(x => -x.Name + 5), pars); Assert.AreEqual("(-Name + #0)", result); Assert.AreEqual(1, pars.Count); Assert.AreEqual(5, pars[0].Value); }
public void Is_NotNull() { var engine = new Concrete.DataEngine(); var parser = new Concrete.Parser(engine); var pars = engine.CreateParameterCollection(); var result = parser.Parse((Func<dynamic, object>)(x => x.Name != null), pars); Assert.AreEqual("(Name IS NOT NULL)", result); Assert.AreEqual(0, pars.Count); }