• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# RhetosTestContainer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中RhetosTestContainer的典型用法代码示例。如果您正苦于以下问题:C# RhetosTestContainer类的具体用法?C# RhetosTestContainer怎么用?C# RhetosTestContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RhetosTestContainer类属于命名空间,在下文中一共展示了RhetosTestContainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SqlObject

        public void SqlObject()
        {
            using (var container = new RhetosTestContainer())
            {
                container.Resolve<ISqlExecuter>().ExecuteSql(new[]
                {
                    "DELETE FROM TestSqlWorkarounds.E",
                    "INSERT INTO TestSqlWorkarounds.E (I) VALUES (100)"
                });

                string report = "";
                container.Resolve<ISqlExecuter>().ExecuteReader(
                    @"SELECT E.I, V1.I1, V2.I2
                        FROM TestSqlWorkarounds.E
                        INNER JOIN TestSqlWorkarounds.V1 ON V1.ID = E.ID
                        INNER JOIN TestSqlWorkarounds.V2 ON V2.ID = E.ID",
                    reader => report += reader.GetInt32(0) + ", " + reader.GetInt32(1) + ", " + reader.GetInt32(2) + ".");
                Assert.AreEqual("100, 101, 102.", report);

                report = "";
                container.Resolve<ISqlExecuter>().ExecuteReader(
                    @"SELECT X FROM TestSqlWorkarounds.V3 ORDER BY X",
                    reader => report += reader.GetInt32(0) + ".");
                Assert.AreEqual("101.102.", report);
            }
        }
开发者ID:tjakopovic,项目名称:Rhetos,代码行数:26,代码来源:SqlWorkaroundsTest.cs


示例2: ComputeForNewBaseItems

        public void ComputeForNewBaseItems()
        {
            using (var container = new RhetosTestContainer())
            {
                var repository = container.Resolve<Common.DomRepository>();

                var d1ID = Guid.NewGuid();
                container.Resolve<ISqlExecuter>().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");
            }
        }
开发者ID:kmeze,项目名称:Rhetos,代码行数:33,代码来源:PersistedDataStructureTest.cs


示例3: LeavePredefinedUser

        public void LeavePredefinedUser()
        {
            using (var container = new RhetosTestContainer())
            {
                var genericRepositories = container.Resolve<GenericRepositories>();
                var repository = container.Resolve<Common.DomRepository>();

                string currentUserName = container.Resolve<IUserInfo>().UserName;
                Assert.IsTrue(!string.IsNullOrWhiteSpace(currentUserName));
                var currentPrincipal = new Common.Principal { Name = currentUserName };
                genericRepositories.InsertOrReadId(currentPrincipal, p => p.Name);

                string otherUserName = "otherUser-" + Guid.NewGuid();
                var otherPrincipal = new Common.Principal { Name = otherUserName };
                genericRepositories.InsertOrReadId(otherPrincipal, p => p.Name);

                var testItem1 = new TestCreatedBy.Simple { ID = Guid.NewGuid(), Name = "test1", AuthorID = otherPrincipal.ID };
                var testItem2 = new TestCreatedBy.Simple { ID = Guid.NewGuid(), Name = "test2" };
                repository.TestCreatedBy.Simple.Insert(testItem1, testItem2);

                Assert.AreEqual(
                    "test1 " + otherUserName + ", test2 " + currentUserName,
                    TestUtility.DumpSorted(repository.TestCreatedBy.Simple
                        .Query(new[] { testItem1.ID, testItem2.ID })
                        .Select(item => item.Name + " " + item.Author.Name)));
            }
        }
开发者ID:Rhetos,项目名称:Rhetos,代码行数:27,代码来源:CreatedByTest.cs


示例4: NonEditablePropertyUpdate

        public void NonEditablePropertyUpdate()
        {
            using (var container = new RhetosTestContainer())
            {
                var simpleID = Guid.NewGuid();
                container.Resolve<ISqlExecuter>().ExecuteSql(new[]
                    {
                        "DELETE FROM TestDenyUserEdit.Simple",
                        "DELETE FROM TestDenyUserEdit.Parent",
                        "INSERT INTO TestDenyUserEdit.Simple (ID, Editable, NonEditable) VALUES (" + SqlUtility.QuoteGuid(simpleID) + ", 'a', 'x')"
                    });

                var repository = container.Resolve<Common.DomRepository>();

                Assert.AreEqual("a x null", DumpSimple(repository));

                var simple = new TestDenyUserEdit.Simple { ID = simpleID, Editable = "b", NonEditable = "x" };
                repository.TestDenyUserEdit.Simple.Save(null, new[] { simple }, null, true);
                Assert.AreEqual("b x null", DumpSimple(repository));

                simple.NonEditable = "y";
                TestUtility.ShouldFail(() => repository.TestDenyUserEdit.Simple.Save(null, new[] { simple }, null, true),
                    "Simple", "NonEditable", "not allowed");
            }
        }
开发者ID:tjakopovic,项目名称:Rhetos,代码行数:25,代码来源:DenyUserEditTest.cs


示例5: AutoInherit

        public void AutoInherit()
        {
            using (var container = new RhetosTestContainer())
            {
                var names = new[] { "1", "1b", "2", "3", "4" };
                var itemsE4 = names.Select(name => new TestRowPermissions4.E4 { ID = Guid.NewGuid(), Name4 = name }).ToList();
                var itemsE3 = names.Select((name, x) => new TestRowPermissions3.E3 { ID = Guid.NewGuid(), Name3 = name, E4 = itemsE4[x] }).ToList();
                var itemsE2 = names.Select((name, x) => new TestRowPermissions2.E2 { ID = Guid.NewGuid(), Name2 = name, E3 = itemsE3[x] }).ToList();
                var itemsE1 = names.Select((name, x) => new TestRowPermissions1.E1 { ID = Guid.NewGuid(), Name1 = name, E2 = itemsE2[x] }).ToList();

                var reposE1 = container.Resolve<GenericRepository<TestRowPermissions1.E1>>();
                var reposE1Browse = container.Resolve<GenericRepository<TestRowPermissions1.E1Browse>>();
                var reposE1BrowseRP = container.Resolve<GenericRepository<TestRowPermissions1.E1BrowseRP>>();
                var reposE2 = container.Resolve<GenericRepository<TestRowPermissions2.E2>>();
                var reposE3 = container.Resolve<GenericRepository<TestRowPermissions3.E3>>();
                var reposE4 = container.Resolve<GenericRepository<TestRowPermissions4.E4>>();

                reposE4.Save(itemsE4, null, reposE4.Read());
                reposE3.Save(itemsE3, null, reposE3.Read());
                reposE2.Save(itemsE2, null, reposE2.Read());
                reposE1.Save(itemsE1, null, reposE1.Read());

                Assert.AreEqual("4", TestUtility.DumpSorted(reposE4.Read<Common.RowPermissionsReadItems>(), item => item.Name4));
                Assert.AreEqual("3->3", TestUtility.DumpSorted(reposE3.Read<Common.RowPermissionsReadItems>(), item => item.Name3 + "->" + item.E4.Name4));
                Assert.AreEqual("2, 3", TestUtility.DumpSorted(reposE2.Read<Common.RowPermissionsReadItems>(), item => item.Name2));
                Assert.AreEqual("1, 2, 3", TestUtility.DumpSorted(reposE1.Read<Common.RowPermissionsReadItems>(), item => item.Name1));
                Assert.AreEqual("1, 2, 3", TestUtility.DumpSorted(reposE1Browse.Read<Common.RowPermissionsReadItems>(), item => item.Name1Browse));
                Assert.AreEqual("1, 1b, 2, 3", TestUtility.DumpSorted(reposE1BrowseRP.Read<Common.RowPermissionsReadItems>(), item => item.Name1Browse));
            }
        }
开发者ID:kmeze,项目名称:Rhetos,代码行数:30,代码来源:RowPermissionsRulesTest.cs


示例6: CreatedIndexes

        public void CreatedIndexes()
        {
            using (var container = new RhetosTestContainer())
            {
                var sql = @"SELECT
                        i.name + '.' + c.name
                    FROM
                        sys.indexes i
                        INNER JOIN sys.index_columns ic ON ic.object_id = i.object_id AND ic.index_id = i.index_id
                        INNER JOIN sys.columns c ON c.object_id = ic.object_id AND c.column_id = ic.column_id
                    WHERE
                        c.object_id IN (OBJECT_ID('TestCloning.Clone1'), OBJECT_ID('TestCloning.Clone2'), OBJECT_ID('TestCloning.Clone3'))
                    ORDER BY
                        i.name, ic.key_ordinal";

                string[] expected =
                    ("IX_Clone2_Parent.ParentID IX_Clone2_Start_Parent.Start IX_Clone2_Start_Parent.ParentID"
                    + " IX_Clone3_Code.Code IX_Clone3_Parent.ParentID IX_Clone3_Start_Parent.Start"
                    + " IX_Clone3_Start_Parent.ParentID PK_Clone1.ID PK_Clone2.ID PK_Clone3.ID").Split(' ');

                var actual = new List<string>();
                container.Resolve<ISqlExecuter>().ExecuteReader(sql, reader => actual.Add(reader.GetString(0)));

                Assert.AreEqual(TestUtility.DumpSorted(expected), TestUtility.DumpSorted(actual));
            }
        }
开发者ID:tjakopovic,项目名称:Rhetos,代码行数:26,代码来源:CloningTest.cs


示例7: SqlFunction

 public void SqlFunction()
 {
     using (var container = new RhetosTestContainer())
     {
         Assert.AreEqual("11", ReportSqlQueryResult(container.Resolve<ISqlExecuter>(), "SELECT * FROM TestSqlWorkarounds.Fun2(10)"));
     }
 }
开发者ID:tjakopovic,项目名称:Rhetos,代码行数:7,代码来源:SqlWorkaroundsTest.cs


示例8: LazyLoadReferenceBaseExtensionLinkedItems

        public void LazyLoadReferenceBaseExtensionLinkedItems()
        {
            using (var container = new RhetosTestContainer())
            {
                var repository = container.Resolve<Common.DomRepository>();
                repository.TestLazyLoad.Simple.Delete(repository.TestLazyLoad.Simple.Load());
                repository.TestLazyLoad.SimpleBase.Delete(repository.TestLazyLoad.SimpleBase.Load());
                repository.TestLazyLoad.Parent.Delete(repository.TestLazyLoad.Parent.Load());

                var p1 = new TestLazyLoad.Parent { ID = Guid.NewGuid(), Name = "p1" };
                repository.TestLazyLoad.Parent.Insert(p1);

                var sb1 = new TestLazyLoad.SimpleBase { ID = Guid.NewGuid(), Name = "sb1" };
                var sb2 = new TestLazyLoad.SimpleBase { ID = Guid.NewGuid(), Name = "sb2" };
                repository.TestLazyLoad.SimpleBase.Insert(sb1, sb2);

                var s1 = new TestLazyLoad.Simple { ID = sb1.ID, ParentID = p1.ID };
                var s2 = new TestLazyLoad.Simple { ID = sb2.ID, ParentID = p1.ID };
                repository.TestLazyLoad.Simple.Insert(s1, s2);

                container.Resolve<IPersistenceCache>().ClearCache();
                var loadedSimple = repository.TestLazyLoad.Simple.Query().ToList();
                Assert.AreEqual("p1/sb1, p1/sb2", TestUtility.DumpSorted(loadedSimple, item => item.Parent.Name + "/" + item.Base.Name));

                container.Resolve<IPersistenceCache>().ClearCache();
                var loadedBase = repository.TestLazyLoad.SimpleBase.Query().ToList();
                Assert.AreEqual("p1/sb1, p1/sb2", TestUtility.DumpSorted(loadedBase, item => item.Extension_Simple.Parent.Name + "/" + item.Name));

                container.Resolve<IPersistenceCache>().ClearCache();
                var loadedParent = repository.TestLazyLoad.Parent.Query().ToList().Single();
                Assert.AreEqual("p1/sb1, p1/sb2", TestUtility.DumpSorted(loadedParent.Children, item => item.Parent.Name + "/" + item.Base.Name));
            }
        }
开发者ID:davorpr1,项目名称:Rhetos,代码行数:33,代码来源:LazyLoadTest.cs


示例9: ReportLegacy2

        static string ReportLegacy2(RhetosTestContainer container, Common.DomRepository domRepository)
        {
            container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();

            var loaded = domRepository.Test13.Legacy2.Query().Select(l2 => l2.Leg1.Name + " " + l2.NameNew + " " + l2.Same);
            return string.Join(", ", loaded.OrderBy(x => x));
        }
开发者ID:tjakopovic,项目名称:Rhetos,代码行数:7,代码来源:LegacyEntityTest.cs


示例10: QueryComplex

        public void QueryComplex()
        {
            using (var container = new RhetosTestContainer())
            {
                var repository = container.Resolve<Common.DomRepository>();

                container.Resolve<ISqlExecuter>().ExecuteSql(new[]
                    {
                        "DELETE FROM TestEntity.Permission",
                        "DELETE FROM TestEntity.Principal",
                        "DELETE FROM TestEntity.Claim",
                        "INSERT INTO TestEntity.Claim (ID, ClaimResource, ClaimRight) SELECT '4074B807-FA5A-4772-9631-198E89A302DE', 'res1', 'rig1'",
                        "INSERT INTO TestEntity.Claim (ID, ClaimResource, ClaimRight) SELECT 'A45F7194-7288-4B25-BC77-4FCC920A1479', 'res2', 'rig2'",
                        "INSERT INTO TestEntity.Principal (ID, Name) SELECT 'A45F7194-7288-4B25-BC77-4FCC920A1479', 'p1'",
                        "INSERT INTO TestEntity.Permission (ID, PrincipalID, ClaimID, IsAuthorized) SELECT '65D4B68E-B0E7-491C-9405-800F531866CA', 'A45F7194-7288-4B25-BC77-4FCC920A1479', '4074B807-FA5A-4772-9631-198E89A302DE', 0",
                        "INSERT INTO TestEntity.Permission (ID, PrincipalID, ClaimID, IsAuthorized) SELECT 'B7F19BA7-C70F-46ED-BFC7-29A44DFECA9B', 'A45F7194-7288-4B25-BC77-4FCC920A1479', 'A45F7194-7288-4B25-BC77-4FCC920A1479', 1"
                    });

                var q1 = repository.TestEntity.Principal.Query();
                var q2 = repository.TestEntity.Permission.Query();
                var loaded =
                    from principal in q1
                    from permission in q2
                    where principal.Name == "p1" && permission.Principal == principal && permission.IsAuthorized.Value
                    select permission.Claim.ClaimResource + "." + permission.Claim.ClaimRight;

                Assert.AreEqual("res2.rig2", loaded.Single());
            }
        }
开发者ID:davorpr1,项目名称:Rhetos,代码行数:29,代码来源:EntityTest.cs


示例11: UpdateLockedData

        public void UpdateLockedData()
        {
            using (var container = new RhetosTestContainer())
            {
                container.Resolve<ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestLockItems.Simple;" });
                var repository = container.Resolve<Common.DomRepository>();

                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);
            }
        }
开发者ID:tjakopovic,项目名称:Rhetos,代码行数:26,代码来源:LockPropertyTest.cs


示例12: SearchOnIndexTable

        public void SearchOnIndexTable()
        {
            Assert.IsTrue(dataPrepared.Value);

            using (var container = new RhetosTestContainer(false))
            {
                var tests = new Dictionary<string, string>
                {
                    { "\"ab*\"", "ab, abc, cd ab" },
                    { "\"12*\"", "123, ab, xy" },
                    { "a'b", "" },
                    { "a'#'b", "" },
                };

                var repository = container.Resolve<Common.DomRepository>();

                foreach (var test in tests)
                {
                    Console.WriteLine("Searching '" + test.Key + "'");

                    var filtered = repository.TestFullTextSearch.Simple_Search.Query()
                        .Where(item => DatabaseExtensionFunctions.FullTextSearch(item.ID, test.Key, "TestFullTextSearch.Simple_Search", "*"))
                        .Select(item => item.Base.Name).ToList();
                    Assert.AreEqual(test.Value, TestUtility.DumpSorted(filtered), "Searching '" + test.Key + "'.");

                    filtered = repository.TestFullTextSearch.Simple_Search.Query()
                        .Where(item => DatabaseExtensionFunctions.FullTextSearch(item.ID, test.Key, "TestFullTextSearch.Simple_Search", "Text"))
                        .Select(item => item.Base.Name).ToList();
                    Assert.AreEqual(test.Value, TestUtility.DumpSorted(filtered), "Searching '" + test.Key + "'.");
                }
            }
        }
开发者ID:davorpr1,项目名称:Rhetos,代码行数:32,代码来源:FullTextSearchTest.cs


示例13: PersistPartial

        public void PersistPartial()
        {
            using (var container = new RhetosTestContainer())
            {
                container.Resolve<ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestComputedFrom.PersistPartial" });
                var repository = container.Resolve<Common.DomRepository>();

                Assert.AreEqual("", TestUtility.DumpSorted(repository.TestComputedFrom.PersistPartial.All(), Dump));

                repository.TestComputedFrom.PersistPartial.RecomputeFromSource(new Rhetos.Dom.DefaultConcepts.FilterAll(), items => items.Where(item => item.Name == "aa"));
                container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
                Assert.AreEqual("aa", TestUtility.DumpSorted(repository.TestComputedFrom.PersistPartial.All(), Dump), "recompute all with SaveFilter to sync only Name aa ");

                repository.TestComputedFrom.PersistPartial.RecomputeFromSource();
                container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
                Assert.AreEqual("aa, bb", TestUtility.DumpSorted(repository.TestComputedFrom.PersistPartial.All(), Dump), "recompute all");

                repository.TestComputedFrom.PersistPartial.Delete(repository.TestComputedFrom.PersistPartial.All());
                container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();

                repository.TestComputedFrom.PersistPartial.RecomputeFromSource(new[] { repository.TestComputedFrom.Source.All().Where(item => item.Name == "bb").Single().ID });
                container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
                Assert.AreEqual("bb", TestUtility.DumpSorted(repository.TestComputedFrom.PersistPartial.All(), Dump), "recompute by ID (name bb)");
            }
        }
开发者ID:tjakopovic,项目名称:Rhetos,代码行数:25,代码来源:ComputedFromTest.cs


示例14: UpdateLockedData

        public void UpdateLockedData()
        {
            using (var container = new RhetosTestContainer())
            {
                container.Resolve<ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestLockItems.Simple;" });
                var repository = container.Resolve<Common.DomRepository>();

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

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

                TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Update(new[] { s3Lock }), "Name contains lock mark.");
                TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Update(new[] { s1, s3Lock }), "Name contains lock mark.");
                TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Update(new[] { s3Lock, s4 }), "Name contains lock mark.");
                AssertData("s1, s2, s3_lock, s4", repository);

                repository.TestLockItems.Simple.Update(new[] { s1 });
                AssertData("s1x, s2, s3_lock, s4", repository);
            }
        }
开发者ID:tjakopovic,项目名称:Rhetos,代码行数:27,代码来源:LockItemsTest.cs


示例15: FilterNoPermissions

        public void FilterNoPermissions()
        {
            using (var container = new RhetosTestContainer())
            {
                var repositories = container.Resolve<Common.DomRepository>();
                var itemsRepository = repositories.TestRowPermissions.RPRulesItem;
                var groupsRepository = repositories.TestRowPermissions.RPRulesGroup;
                itemsRepository.Delete(itemsRepository.All());
                groupsRepository.Delete(groupsRepository.All());

                var g1 = new RPRulesGroup { ID = Guid.NewGuid(), Name = "g1" };
                var g2 = new RPRulesGroup { ID = Guid.NewGuid(), Name = "g2" };
                var i1 = new RPRulesItem { ID = Guid.NewGuid(), Name = "i1", GroupID = g1.ID };
                var i2 = new RPRulesItem { ID = Guid.NewGuid(), Name = "i2", GroupID = g1.ID };
                var i3 = new RPRulesItem { ID = Guid.NewGuid(), Name = "i3", GroupID = g2.ID };
                var i4 = new RPRulesItem { ID = Guid.NewGuid(), Name = "i4", GroupID = g2.ID };

                groupsRepository.Insert(new[] { g1, g2 });
                itemsRepository.Insert(new[] { i1, i2, i3, i4 });

                var allowedItems = itemsRepository.Filter(itemsRepository.Query(), new Common.RowPermissionsReadItems());
                Console.WriteLine(itemsRepository.Query().Expression.ToString());
                Console.WriteLine(allowedItems.Expression.ToString());
                Assert.AreEqual("", TestUtility.DumpSorted(allowedItems, item => item.Name));
                Assert.AreEqual("Common.Queryable.TestRowPermissions_RPRulesItem[]", allowedItems.Expression.ToString(), "No need for query, an empty array should be returned.");
            }
        }
开发者ID:tjakopovic,项目名称:Rhetos,代码行数:27,代码来源:RowPermissionsRulesTest.cs


示例16: UpdateLockedDataReference

        public void UpdateLockedDataReference()
        {
            using (var container = new RhetosTestContainer())
            {
                container.Resolve<ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestLockItems.Simple;" });
                var repository = container.Resolve<Common.DomRepository>();
                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);
            }
        }
开发者ID:kmeze,项目名称:Rhetos,代码行数:35,代码来源:LockPropertyTest.cs


示例17: CreatedColumns

        public void CreatedColumns()
        {
            using (var container = new RhetosTestContainer())
            {
                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();
                container.Resolve<ISqlExecuter>().ExecuteReader(sql, reader => actual.AppendLine(reader.GetString(0)));

                Assert.AreEqual(expected, actual.ToString());
            }
        }
开发者ID:tjakopovic,项目名称:Rhetos,代码行数:32,代码来源:CloningTest.cs


示例18: NullReference

        public void NullReference()
        {
            using (var container = new RhetosTestContainer())
            {
                var repository = container.Resolve<Common.DomRepository>();

                Guid refID = Guid.NewGuid();
                container.Resolve<ISqlExecuter>().ExecuteSql(new[]
                    {
                        "DELETE FROM TestBrowse.Source;",
                        "DELETE FROM TestBrowse.Other;",
                        "INSERT INTO TestBrowse.Other (ID, Name) SELECT '" + refID + "', 'abc';",
                        "INSERT INTO TestBrowse.Source (RefID) SELECT NULL;"
                    });

                Assert.IsNull(repository.TestBrowse.Source.Query().ToArray().Select(item => item.Ref != null ? item.Ref.Name : null).Single(), "separated loading with null checking");
                Assert.IsNull(repository.TestBrowse.Source.Query().Select(item => item.Ref != null ? item.Ref.Name : null).Single(), "all in one query with null checking");

                Assert.IsNull(repository.TestBrowse.Source.Query().Select(item => item.Ref.Name).Single(), "all in one query");

                // TODO: "'Separated loading' fails because LINQ2NH will handle nullable properies and null values differently than a simple LINQ query over materialized instances (Linq2Objects). Try to implement browse in a such way that it behaves the same in both scenarios without degrading performance (maybe generating SqlView).
            
                Assert.IsNull(repository.TestBrowse.Source.Query().ToArray().Select(item => item.Ref.Name).Single(), "separated loading");
            }
        }
开发者ID:tjakopovic,项目名称:Rhetos,代码行数:25,代码来源:BrowseTest.cs


示例19: CascadeDelete

        public void CascadeDelete()
        {
            using (var container = new RhetosTestContainer())
            {
                var repository = container.Resolve<Common.DomRepository>();

                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();

                container.Resolve<ISqlExecuter>().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));
            }
        }
开发者ID:kmeze,项目名称:Rhetos,代码行数:34,代码来源:EntityTest.cs


示例20: ActivePropertyValueDoesNotHaveToBeDefinedOnUpdate

        public void ActivePropertyValueDoesNotHaveToBeDefinedOnUpdate()
        {
            using (var container = new RhetosTestContainer())
            {
                var id1 = Guid.NewGuid();
                var id2 = Guid.NewGuid();
                var id3 = Guid.NewGuid();
                container.Resolve<ISqlExecuter>().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 = container.Resolve<Common.DomRepository>();
                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));
            }
        }
开发者ID:kmeze,项目名称:Rhetos,代码行数:25,代码来源:DeactivatableTest.cs



注:本文中的RhetosTestContainer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Rhino类代码示例发布时间:2022-05-24
下一篇:
C# RgbColorClass类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap