Exemplo n.º 1
0
        public void CascadeDelete()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var repository = new Common.DomRepository(executionContext);

                var pid1 = Guid.NewGuid();
                var pid2 = Guid.NewGuid();
                var pid3 = Guid.NewGuid();
                var cid11 = Guid.NewGuid();
                var cid12 = Guid.NewGuid();
                var cid21 = Guid.NewGuid();
                var cid31 = Guid.NewGuid();

                executionContext.SqlExecuter.ExecuteSql(new[]
                {
                    "DELETE FROM TestEntity.Child",
                    "DELETE FROM TestEntity.BaseEntity",
                    "INSERT INTO TestEntity.BaseEntity (ID, Name) SELECT '" + pid1 + "', '1'",
                    "INSERT INTO TestEntity.BaseEntity (ID, Name) SELECT '" + pid2+ "', '2'",
                    "INSERT INTO TestEntity.BaseEntity (ID, Name) SELECT '" + pid3 + "', '3'",
                    "INSERT INTO TestEntity.Child (ID, Name, ParentID) SELECT '" + cid11 + "', '11', '" + pid1 + "'",
                    "INSERT INTO TestEntity.Child (ID, Name, ParentID) SELECT '" + cid12 + "', '12', '" + pid1 + "'",
                    "INSERT INTO TestEntity.Child (ID, Name, ParentID) SELECT '" + cid21 + "', '21', '" + pid2 + "'",
                    "INSERT INTO TestEntity.Child (ID, Name, ParentID) SELECT '" + cid31 + "', '31', '" + pid3 + "'",
                });

                Assert.AreEqual("11, 12, 21, 31", TestUtility.DumpSorted(repository.TestEntity.Child.All(), item => item.Name));

                repository.TestEntity.BaseEntity.Delete(new [] { new TestEntity.BaseEntity { ID = pid1 }, new TestEntity.BaseEntity { ID = pid2 } });

                Assert.AreEqual("31", TestUtility.DumpSorted(repository.TestEntity.Child.All(), item => item.Name));
            }
        }
Exemplo n.º 2
0
        public void CRUD()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var repository = new Common.DomRepository(executionContext);
                var unitTestClaims = repository.Common.Claim.Query().Where(c => c.ClaimResource.StartsWith("unittest_")).ToList();
                Console.WriteLine("Delete old: " + TestUtility.DumpSorted(unitTestClaims, c => c.ClaimResource + "." + c.ClaimRight) + ".");
                repository.Common.Claim.Delete(unitTestClaims);

                IClaimRepository cr = repository.Common.Claim;
                var c1 = new Claim("unittest_c1", "c11");
                var c2 = new Claim("unittest_c2", "c22");
                var c3 = new Claim("unittest_c3", "c33");
                cr.SaveClaims(new[] { c1, c2, c3 }, new ICommonClaim[] {}, new ICommonClaim[] {});

                var loaded = cr.LoadClaims().Where(c => c.ClaimResource.StartsWith("unittest_")).ToList();
                loaded.Sort((cl1, cl2) => cl1.ClaimResource.CompareTo(cl2.ClaimResource));
                Assert.AreEqual("c11, c22, c33", TestUtility.Dump(loaded, c => c.ClaimRight));

                loaded[0].ClaimRight = loaded[0].ClaimRight.ToUpper();
                var c4 = new Claim("unittest_c4", "c44");
                cr.SaveClaims(new[] { c4 }, new[] { loaded[0] }, new[] { loaded[1] });

                loaded = cr.LoadClaims().Where(c => c.ClaimResource.StartsWith("unittest_")).ToList();
                loaded.Sort((cl1, cl2) => cl1.ClaimResource.CompareTo(cl2.ClaimResource));
                Assert.AreEqual("C11, c33, c44", TestUtility.Dump(loaded, c => c.ClaimRight));
            }
        }
Exemplo n.º 3
0
        public void Update_Index3()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                executionContext.SqlExecuter.ExecuteSql(new[]
                    {
                        "DELETE FROM TestUnique.E;",
                        "DELETE FROM TestUnique.R;"
                    });

                var repository = new Common.DomRepository(executionContext);
                var helper = new EntityHelper(executionContext, repository);

                var r1 = new TestUnique.R { S = "r1" };
                var r2 = new TestUnique.R { S = "r2" };
                repository.TestUnique.R.Insert(new[] { r1, r2 });

                var id1 = Guid.NewGuid();

                helper.Insert("a", 1, r1);
                helper.Insert("b", 2, r2, id1);
                helper.Update("c", 2, r2, id1);
                helper.UpdateShouldFail("a", 1, r1, id1);
            }
        }
Exemplo n.º 4
0
        public void DeleteModifiedPersistentObject()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestLockItems.Simple;" });
                var repository = new Common.DomRepository(executionContext);

                {
                    var s3Lock = new TestLockItems.Simple { ID = Guid.NewGuid(), Name = "s3_lock" };
                    repository.TestLockItems.Simple.Insert(new[] { s3Lock });

                    AssertData("s3_lock", repository);
                    executionContext.NHibernateSession.Clear();
                    AssertData("s3_lock", repository);
                }

                {
                    var s3Persistent = repository.TestLockItems.Simple.All().Single();
                    s3Persistent.Name = "abc";
                    TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Delete(new[] { s3Persistent }),
                        "Name contains lock mark");

                    AssertData("s3_lock", repository);
                    executionContext.NHibernateSession.Clear();
                    AssertData("s3_lock", repository);
                }
            }
        }
Exemplo n.º 5
0
        public void ComputeForNewBaseItems_InvalidCommand()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var repository = new Common.DomRepository(executionContext);

                var d1ID = Guid.NewGuid();
                var d2ID = Guid.NewGuid();
                executionContext.SqlExecuter.ExecuteSql(new[]
                    {
                        "DELETE FROM Test9.Document;",
                        "DELETE FROM Test9.DocumentCreationInfo;",
                        "INSERT INTO Test9.Document (ID, Name) SELECT '" + d1ID + "', 'd1'",
                        "INSERT INTO Test9.Document (ID, Name) SELECT '" + d2ID + "', 'd2'",
                        "INSERT INTO Test9.DocumentCreationInfo (ID, Rank) SELECT '" + d1ID + "', 1",
                        "INSERT INTO Test9.DocumentCreationInfo (ID, Rank) SELECT '" + d2ID + "', 2",
                    });

                Assert.AreEqual("d1:1, d2:2", ReportDocumentCreationInfo(repository), "initial");

                var documents = repository.Test9.Document;

                TestUtility.ShouldFail(() => documents.Insert(new[] { new Test9.Document { ID = d1ID, Name = "d1" } }), "existing");
                Assert.AreEqual("d1:1, d2:2", ReportDocumentCreationInfo(repository), "creation info of previously inserted documents shoud not be changed");

                // TODO: Instead of using the wrapper 'Save' function to check data validations, we should handle insert/update/delete events (NHibernate event listener) for faster and more reliable validations.
                TestUtility.ShouldFail(() => documents.Update(new[] { new Test9.Document { ID = Guid.NewGuid(), Name = "d3" } }));
                Assert.AreEqual("d1:1, d2:2", ReportDocumentCreationInfo(repository), "creation info of previously inserted documents shoud not be changed");
            }
        }
Exemplo n.º 6
0
        public void SqlDependsOnSqlIndex()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var features = new Dictionary<string, string>
                {
                    { "base", "DataStructureInfo TestSqlWorkarounds.DependencyBase" },
                    { "baseA", "PropertyInfo TestSqlWorkarounds.DependencyBase.A" },
                    { "baseB", "PropertyInfo TestSqlWorkarounds.DependencyBase.B" },
                    { "baseBAIndex", "SqlIndexMultipleInfo TestSqlWorkarounds.DependencyBase.'B A'" },
                    { "depA", "SqlObjectInfo TestSqlWorkarounds.DependencyA" },
                    { "depB", "SqlObjectInfo TestSqlWorkarounds.DependencyB" },
                    { "depAll", "SqlObjectInfo TestSqlWorkarounds.DependencyAll" }
                };

                Dictionary<Guid, string> featuresById = features
                    .Select(f => new { Name = f.Key, Id = ReadConceptId(f.Value, executionContext) })
                    .ToDictionary(fid => fid.Id, fid => fid.Name);

                var deployedDependencies = ReadConceptDependencies(featuresById.Keys, executionContext)
                    .Select(dep => featuresById[dep.Item1] + "-" + featuresById[dep.Item2]);

                var expectedDependencies = // Second concept depends on first concept.
                    "base-baseA, base-baseB," // Standard properties depend on their entity.
                    + "base-baseBAIndex, baseA-baseBAIndex, baseB-baseBAIndex," // Standard index depends on its properties.
                    + "baseA-depA,"
                    + "baseB-depB, baseBAIndex-depB," // SqlDependsOnSqlIndex should be automatically included when depending on its first property.
                    + "baseA-depAll, baseB-depAll,"
                    + "baseBAIndex-depAll"; // SqlDependsOnSqlIndex should be automatically included when depending on its entity.

                Assert.AreEqual(
                    TestUtility.DumpSorted(expectedDependencies.Split(',').Select(s => s.Trim()).Where(s => !string.IsNullOrEmpty(s))),
                    TestUtility.DumpSorted(deployedDependencies));
            }
        }
Exemplo n.º 7
0
        public void ActivePropertyValueDoesNotHaveToBeDefinedOnUpdate()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var id1 = Guid.NewGuid();
                var id2 = Guid.NewGuid();
                var id3 = Guid.NewGuid();
                executionContext.SqlExecuter.ExecuteSql(new[] {
                    "DELETE FROM TestDeactivatable.BasicEnt",
                    "INSERT INTO TestDeactivatable.BasicEnt (ID, Name) VALUES (" + SqlUtility.QuoteGuid(id1) + ", 'a')",
                    "INSERT INTO TestDeactivatable.BasicEnt (ID, Name, Active) VALUES (" + SqlUtility.QuoteGuid(id2) + ", 'b', 0)",
                    "INSERT INTO TestDeactivatable.BasicEnt (ID, Name) VALUES (" + SqlUtility.QuoteGuid(id3) + ", 'c')"
                });
                var repository = new Common.DomRepository(executionContext);
                var e1 = new BasicEnt { ID = id1, Name = "a2", Active = false };
                var e2 = new BasicEnt { ID = id2, Name = "b2" };
                var e3 = new BasicEnt { ID = id3, Name = "c2" };
                repository.TestDeactivatable.BasicEnt.Update(new[] { e1, e2, e3});

                var afterUpdate = repository.TestDeactivatable.BasicEnt.All();
                Assert.AreEqual(
                    "a2 False, b2 False, c2 True",
                    TestUtility.DumpSorted(afterUpdate, item => item.Name + " " + item.Active));
            }
        }
Exemplo n.º 8
0
        public void ComputeForNewBaseItems()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var repository = new Common.DomRepository(executionContext);

                var d1ID = Guid.NewGuid();
                executionContext.SqlExecuter.ExecuteSql(new[]
                    {
                        "DELETE FROM Test9.Document;",
                        "DELETE FROM Test9.DocumentCreationInfo;",
                        "INSERT INTO Test9.Document (ID, Name) SELECT '" + d1ID + "', 'd1'"
                    });

                Assert.AreEqual("", ReportDocumentCreationInfo(repository), "initial");
                repository.Test9.DocumentCreationInfo.Recompute();
                Assert.AreEqual("d1:1", ReportDocumentCreationInfo(repository), "initial recalc");

                var documents = repository.Test9.Document;

                var d2ID = Guid.NewGuid();
                documents.Insert(new[] { new Test9.Document { ID = d2ID, Name = "d2" } });
                Assert.AreEqual("d1:1, d2:2", ReportDocumentCreationInfo(repository), "autorecompute after new");

                var d3ID = Guid.NewGuid();
                var d4ID = Guid.NewGuid();
                documents.Insert(new[] { new Test9.Document { ID = d3ID, Name = "d3" }, new Test9.Document { ID = d4ID, Name = "d4" } });
                Assert.AreEqual("d1:1, d2:2, d3:4, d4:4", ReportDocumentCreationInfo(repository), "autorecompute after new2");

                documents.Save(null, new[] { new Test9.Document { ID = d1ID, Name = "d1x" } }, new[] { new Test9.Document { ID = d3ID } });
                Assert.AreEqual("d1x:1, d2:2, d4:4", ReportDocumentCreationInfo(repository), "autorecompute after update&delete");
            }
        }
Exemplo n.º 9
0
        public void CreatedColumns()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var sql = @"SELECT
                        OBJECT_NAME(object_id) + '.' + name
                    FROM
                        sys.columns
                    WHERE
                        object_id IN (OBJECT_ID('TestCloning.Clone1'), OBJECT_ID('TestCloning.Clone2'), OBJECT_ID('TestCloning.Clone3'))
                    ORDER BY
                        1";

                var expected =
            @"Clone1.ID
            Clone1.Start
            Clone2.ID
            Clone2.Name
            Clone2.ParentID
            Clone2.Start
            Clone3.Code
            Clone3.ID
            Clone3.Name
            Clone3.ParentID
            Clone3.Start
            ";
                var actual = new StringBuilder();
                executionContext.SqlExecuter.ExecuteReader(sql, reader => actual.AppendLine(reader.GetString(0)));

                Assert.AreEqual(expected, actual.ToString());
            }
        }
Exemplo n.º 10
0
        public void UpdateLockedData()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestLockItems.Simple;" });
                var repository = new Common.DomRepository(executionContext);

                var s1 = new TestLockItems.Simple { ID = Guid.NewGuid(), Name = "s1", Count = -1 };
                var s2 = new TestLockItems.Simple { ID = Guid.NewGuid(), Name = "s2", Count = 1 };

                repository.TestLockItems.Simple.Insert(new[] { s1, s2 });
                AssertData("s1, s2", repository);

                foreach (var e in new[] { s1, s2 })
                    e.Name = e.Name + "x";
                AssertData("s1, s2", repository);

                TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Update(new[] { s1 }), "Name is locked if count negative.");
                TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Update(new[] { s2, s1 }), "Name is locked if count negative.");
                TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Update(new[] { s1, s2 }), "Name is locked if count negative.");
                AssertData("s1, s2", repository);

                repository.TestLockItems.Simple.Update(new[] { s2 });
                AssertData("s1, s2x", repository);
            }
        }
Exemplo n.º 11
0
        public void UpdateLockedDataReference()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestLockItems.Simple;" });
                var repository = new Common.DomRepository(executionContext);
                Guid[] guids = new Guid[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
                var s1 = new TestLockItems.Simple { ID = guids[0], Name = "s1", Count = -1 };
                var s2 = new TestLockItems.Simple { ID = guids[1], Name = "s2", Count = 1 };

                var t1 = new TestLockItems.Simple2 { ID = guids[2], Name = "t1", TestReference = s1, Count = -1 };
                var t2 = new TestLockItems.Simple2 { ID = guids[3], Name = "t2", TestReference = s1, Count = 1 };

                repository.TestLockItems.Simple.Insert(new[] { s1, s2 });
                AssertData("s1, s2", repository);
                repository.TestLockItems.Simple2.Insert(new[] { t1, t2 });
                AssertDataSimple2("t1, t2", repository);

                foreach (var e in new[] { t1, t2 })
                    e.TestReference = s1;
                repository.TestLockItems.Simple2.Update(new[] { t1 });

                AssertDataSimple2("t1, t2", repository);
                foreach (var e in new[] { t1, t2 })
                    e.TestReference = s2;

                TestUtility.ShouldFail(() => repository.TestLockItems.Simple2.Update(new[] { t1 }), "TestReference is locked if count negative.");
                TestUtility.ShouldFail(() => repository.TestLockItems.Simple2.Update(new[] { t2, t1 }), "TestReference is locked if count negative.");
                TestUtility.ShouldFail(() => repository.TestLockItems.Simple2.Update(new[] { t1, t2 }), "TestReference is locked if count negative.");
                AssertDataSimple2("t1, t2", repository);

                repository.TestLockItems.Simple2.Update(new[] { t2 });
                AssertDataSimple2("t1, t2", repository);
            }
        }
Exemplo n.º 12
0
 public void DomRepositoryHasModuleRepositories()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         var repository = new Common.DomRepository(executionContext);
         Assert.IsNotNull(repository.TestDataStructure);
     }
 }
Exemplo n.º 13
0
 public void EmptyValuesAreAllowed()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         var repository = new Common.DomRepository(executionContext);
         var entity = new Simple { StringFrom200To249 = null };
         repository.TestRegex.Simple.Insert(new[] { entity });
     }
 }
Exemplo n.º 14
0
 public void ShouldThowUserExceptionOnInsert()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         var repository = new Common.DomRepository(executionContext);
         var entity = new SimpleMaxLength { StringLessThan10Chars = "More than 10 characters." };
         repository.TestLengthLimit.SimpleMaxLength.Insert(new[] { entity });
     }
 }
Exemplo n.º 15
0
 public void NormallyInsertInteger()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         var repository = new Common.DomRepository(executionContext);
         var entity = new SimpleInteger { Value = 1 };
         repository.TestMaxValue.SimpleInteger.Insert(new[] { entity });
     }
 }
Exemplo n.º 16
0
 public void ShouldThowUserExceptionOnUpdate()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         var repository = new Common.DomRepository(executionContext);
         var entity = new SimpleMinLength { StringMoreThan2Chars = "." };
         repository.TestLengthLimit.SimpleMinLength.Update(new[] { entity });
     }
 }
Exemplo n.º 17
0
 public void NormallyInsertDateTime()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         var repository = new Common.DomRepository(executionContext);
         var entity = new SimpleDateTime { Value = new DateTime(2013, 7, 5, 12, 33, 1) };
         repository.TestMaxValue.SimpleDateTime.Insert(new[] { entity });
     }
 }
Exemplo n.º 18
0
 public void NormallyInsertDecimal()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         var repository = new Common.DomRepository(executionContext);
         var entity = new SimpleDecimal { Value = (decimal)2.30 };
         repository.TestMaxValue.SimpleDecimal.Insert(new[] { entity });
     }
 }
Exemplo n.º 19
0
 public void ShouldThowUserExceptionOnInsert()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         var repository = new Common.DomRepository(executionContext);
         var entity = new SimpleRange { FromValue = 1, ToValue = 0 };
         repository.TestRange.SimpleRange.Insert(new[] { entity });
     }
 }
Exemplo n.º 20
0
 public void ShouldInsertNormallyJustOneDate()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         var repository = new Common.DomRepository(executionContext);
         var entity = new DateRangeWithoutDef { FromDate = DateTime.Today };
         var entity2 = new DateRangeWithoutDef { ToDate = DateTime.Today };
         repository.TestRange.DateRangeWithoutDef.Insert(new[] { entity, entity2 });
     }
 }
Exemplo n.º 21
0
        public void NullString()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestRequired.Simple" });
                var repository = new Common.DomRepository(executionContext);

                TestUtility.ShouldFail(() => repository.TestRequired.Simple.Insert(new[] { new TestRequired.Simple { Count = 4, Name = null } }), "required", "Name");
            }
        }
Exemplo n.º 22
0
        public void InsertValidAndInvalidData()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestDenySave.Simple;" });
                var repository = new Common.DomRepository(executionContext);

                TestUtility.ShouldFail(() => repository.TestDenySave.Simple.Insert(CreateSimple(3, 300)), "larger than 100");
            }
        }
Exemplo n.º 23
0
        public void QueryableFromRepository()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var repository = new Common.DomRepository(executionContext);

                var secondString = repository.TestDataStructure.SqlQueryable1.Query().Where(item => item.i == 2).Select(item => item.s).Single();
                Assert.AreEqual("b", secondString);
            }
        }
Exemplo n.º 24
0
 public void ThrowException()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         var repository = new Common.DomRepository(executionContext);
         TestUtility.ShouldFail(
             () => repository.TestAction.ThrowException.Execute(new TestAction.ThrowException { Message = "abcd" }),
             "abcd");
     }
 }
Exemplo n.º 25
0
        public void Complex()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                executionContext.SqlExecuter.ExecuteSql(new[]
                    {
                        "DELETE FROM TestLogging.Complex",
                        "DELETE FROM TestLogging.Simple",
                    });
                var repository = new Common.DomRepository(executionContext);
                var id = Guid.NewGuid();

                var simple = new TestLogging.Simple { ID = Guid.NewGuid() };
                repository.TestLogging.Simple.Insert(new[] { simple });

                var complex = new TestLogging.Complex
                {
                    bi = new byte[] { 1, 2, 3 },
                    bo = true,
                    da = new DateTime(2001, 2, 3),
                    t = new DateTime(2001, 2, 3, 4, 5, 6),
                    de = 123.4567m,
                    g = Guid.NewGuid(),
                    ls = "abc",
                    m = 11.22m,
                    r = simple
                };
                repository.TestLogging.Complex.Insert(new[] { complex });
                complex.ls = "def";
                repository.TestLogging.Complex.Update(new[] { complex });
                repository.TestLogging.Complex.Delete(new[] { complex });

                var ids = new Guid?[] { simple.ID, complex.ID };

                var ins = repository.Common.Log.Query().Where(log => log.TableName == "TestLogging.Complex" && log.Action == "Insert" && ids.Contains(log.ItemId)).Single();
                var upd = repository.Common.Log.Query().Where(log => log.TableName == "TestLogging.Complex" && log.Action == "Update" && ids.Contains(log.ItemId)).Single();
                var del = repository.Common.Log.Query().Where(log => log.TableName == "TestLogging.Complex" && log.Action == "Delete" && ids.Contains(log.ItemId)).Single();

                Assert.AreEqual("", ins.Description);
                Assert.AreEqual(@"<PREVIOUS ls=""abc"" />", upd.Description);

                var description = del.Description.Split(' ');
                Assert.AreEqual(@"<PREVIOUS", description[0]);
                Assert.AreEqual(@"bi=""0x010203""", description[1]);
                Assert.AreEqual(@"bo=""1""", description[2]);
                Assert.AreEqual(@"da=""2001-02-03""", description[3]);
                Assert.IsTrue(new Regex(@"^t=""2001-02-03T04:05:06(.0+)?""$").IsMatch(description[4]));// optional millisconds
                Assert.IsTrue(new Regex(@"^de=""123\.45670*""$").IsMatch(description[5]));// optional additional zeros
                Assert.AreEqual(@"g=""" + SqlUtility.GuidToString(complex.g.Value) + @"""", description[6]);
                Assert.AreEqual(@"ls=""def""", description[7]);
                Assert.AreEqual(@"m=""11.2200""", description[8]);
                Assert.AreEqual(@"rID=""" + SqlUtility.GuidToString(simple.ID) + @"""", description[9]);
                Assert.AreEqual(@"/>", description[10]);
            }
        }
Exemplo n.º 26
0
        public void HardcodedEntity_Insert()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var repository = new Common.DomRepository(executionContext);

                TestUtility.ShouldFail(
                    () => repository.TestDenyUserEdit.Hardcoded.Save(new[] { new TestDenyUserEdit.Hardcoded { Name = "abc" } }, null, null, true),
                    "It is not allowed to directly modify TestDenyUserEdit.Hardcoded.");
            }
        }
Exemplo n.º 27
0
        public void SpecialLoad()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var repository = new Common.DomRepository(executionContext);

                var paremeter = new TestComputed.SpecialLoad { SpecialName = "spec" };
                var loaded = repository.TestComputed.Simple.Filter(paremeter);
                Assert.AreEqual("spec", TestUtility.DumpSorted(loaded, item => item.Name));
            }
        }
Exemplo n.º 28
0
 public void Spike2_NHInitializationTime()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestSqlFilter.Simple" });
         var repository = new Common.DomRepository(executionContext);
         var result = repository.TestSqlFilter.Simple.All();
         var report = string.Join("|", result.Select(item => item.Code + ", " + item.Start.Value.ToString("s")));
         Assert.AreEqual("", report);
     }
 }
Exemplo n.º 29
0
 public void UseExecutionContext()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         Assert.IsTrue(executionContext.UserInfo.UserName.Length > 0);
         var repository = new Common.DomRepository(executionContext);
         TestUtility.ShouldFail(
             () => repository.TestAction.UEC.Execute(new TestAction.UEC { }),
             "User " + executionContext.UserInfo.UserName);
     }
 }
Exemplo n.º 30
0
 public void EmptyValuesAreNotAllowedIfRequiredSet()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         var repository = new Common.DomRepository(executionContext);
         var entity = new SimpleRequired { StringFrom200To249 = null };
         TestUtility.ShouldFail(
             () => repository.TestRegex.SimpleRequired.Insert(new[] { entity }),
             "UserException", "Required", "Property:StringFrom200To249");
     }
 }