Beispiel #1
0
        public void ShouldBeAbleToRetrieveWithDynamicParameter()
        {
            HashSet <Database> dbs = DataTools.Setup();

            dbs.Each(db =>
            {
                try
                {
                    string name        = "Name_".RandomLetters(8);
                    TestTable instance = new TestTable();
                    instance.Name      = name;
                    instance.Save(db);
                    TestTable retrieved = RetrieveByNameAndValidate(db, instance);

                    SqlStringBuilder sql = db.Sql().Select(nameof(TestTable)).Where(new { Name = name });
                    TestTable queried    = sql.ExecuteReader <TestTable>(db).SingleOrDefault();
                    Message.PrintLine("Result type is ({0})", queried.GetType().Name, ConsoleColor.Cyan);

                    Expect.AreEqual(retrieved.Id, queried.Id);
                    Expect.AreEqual(retrieved.Uuid, queried.Uuid);
                    Expect.AreEqual(retrieved.Cuid, queried.Cuid);
                    Expect.AreEqual(retrieved.Name, queried.Name);

                    Pass($"{db.GetType().Name} passed");
                }
                catch (Exception ex)
                {
                    Error($"{db.GetType().Name}: failed: {ex.Message}", ex);
                }
            });
            DataTools.Cleanup(dbs);
        }