Example #1
0
        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);
        }
Example #2
0
        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 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 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);
		}
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        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);
        }
Example #9
0
        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);
        }
Example #10
0
		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);
		}
Example #11
0
        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);
        }
Example #12
0
        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);
        }
Example #13
0
        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);
        }
Example #14
0
        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);
        }
Example #15
0
        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);
        }
Example #16
0
        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);
        }
Example #17
0
		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);
		}
Example #18
0
		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);
		}
Example #19
0
		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);
		}
Example #20
0
		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);
		}
Example #21
0
		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);
		}
Example #22
0
		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);
		}
Example #23
0
		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);
		}
Example #24
0
		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);
		}