Exemplo n.º 1
0
        public void AutocodeStringEmpty()
        {
            using (var container = new RhetosTestContainer())
            {
                DeleteOldData(container);

                var repository = container.Resolve <Common.DomRepository>();
                var item1      = new TestAutoCodeCached.Simple {
                    ID = Guid.NewGuid(), Code = ""
                };
                repository.TestAutoCodeCached.Simple.Insert(item1);
                Assert.AreEqual("", repository.TestAutoCodeCached.Simple.Load(new[] { item1.ID }).Single().Code);
            }
        }
        public void AutocodeStringEmpty()
        {
            using (var scope = TestScope.Create())
            {
                DeleteOldData(scope);

                var repository = scope.Resolve <Common.DomRepository>();
                var item1      = new TestAutoCodeCached.Simple {
                    ID = Guid.NewGuid(), Code = ""
                };
                repository.TestAutoCodeCached.Simple.Insert(item1);
                Assert.AreEqual("", repository.TestAutoCodeCached.Simple.Load(new[] { item1.ID }).Single().Code);
            }
        }
Exemplo n.º 3
0
        public void Grouping()
        {
            using (var container = new RhetosTestContainer())
            {
                DeleteOldData(container);
                var repository = container.Resolve <Common.DomRepository>();

                TestGroup <TestAutoCodeCached.IntGroup, int>(container, repository.TestAutoCodeCached.IntGroup, 500, "+", "1");
                TestGroup <TestAutoCodeCached.IntGroup, int>(container, repository.TestAutoCodeCached.IntGroup, 500, "+", "2");
                TestGroup <TestAutoCodeCached.IntGroup, int>(container, repository.TestAutoCodeCached.IntGroup, 600, "+", "1");
                TestGroup <TestAutoCodeCached.IntGroup, int>(container, repository.TestAutoCodeCached.IntGroup, 600, "A+", "A1");

                TestGroup <TestAutoCodeCached.StringGroup, string>(container, repository.TestAutoCodeCached.StringGroup, "x", "+", "1");
                TestGroup <TestAutoCodeCached.StringGroup, string>(container, repository.TestAutoCodeCached.StringGroup, "x", "+", "2");
                TestGroup <TestAutoCodeCached.StringGroup, string>(container, repository.TestAutoCodeCached.StringGroup, "y", "+", "1");
                TestGroup <TestAutoCodeCached.StringGroup, string>(container, repository.TestAutoCodeCached.StringGroup, "y", "A+", "A1");

                var simple1 = new TestAutoCodeCached.Simple {
                    ID = Guid.NewGuid(), Code = "1"
                };
                var simple2 = new TestAutoCodeCached.Simple {
                    ID = Guid.NewGuid(), Code = "2"
                };
                repository.TestAutoCodeCached.Simple.Insert(new[] { simple1, simple2 });

                TestGroup <TestAutoCodeCached.ReferenceGroup, TestAutoCodeCached.Simple>(container, repository.TestAutoCodeCached.ReferenceGroup, simple1, "+", "1");
                TestGroup <TestAutoCodeCached.ReferenceGroup, TestAutoCodeCached.Simple>(container, repository.TestAutoCodeCached.ReferenceGroup, simple1, "+", "2");
                TestGroup <TestAutoCodeCached.ReferenceGroup, TestAutoCodeCached.Simple>(container, repository.TestAutoCodeCached.ReferenceGroup, simple2, "+", "1");
                TestGroup <TestAutoCodeCached.ReferenceGroup, TestAutoCodeCached.Simple>(container, repository.TestAutoCodeCached.ReferenceGroup, simple2, "A+", "A1");

                var grouping1 = new TestAutoCodeCached.Grouping {
                    ID = Guid.NewGuid(), Code = "1"
                };
                var grouping2 = new TestAutoCodeCached.Grouping {
                    ID = Guid.NewGuid(), Code = "2"
                };
                repository.TestAutoCodeCached.Grouping.Insert(new[] { grouping1, grouping2 });

                TestGroup <TestAutoCodeCached.ShortReferenceGroup, TestAutoCodeCached.Grouping>(container, repository.TestAutoCodeCached.ShortReferenceGroup, grouping1, "+", "1");
                TestGroup <TestAutoCodeCached.ShortReferenceGroup, TestAutoCodeCached.Grouping>(container, repository.TestAutoCodeCached.ShortReferenceGroup, grouping1, "+", "2");
                TestGroup <TestAutoCodeCached.ShortReferenceGroup, TestAutoCodeCached.Grouping>(container, repository.TestAutoCodeCached.ShortReferenceGroup, grouping2, "+", "1");
                TestGroup <TestAutoCodeCached.ShortReferenceGroup, TestAutoCodeCached.Grouping>(container, repository.TestAutoCodeCached.ShortReferenceGroup, grouping2, "A+", "A1");
            }
        }
Exemplo n.º 4
0
        public void AllowedNullValueInternally()
        {
            using (var container = new RhetosTestContainer())
            {
                DeleteOldData(container);

                var context = container.Resolve <Common.ExecutionContext>();

                var s1 = new TestAutoCodeCached.Simple {
                    ID = Guid.NewGuid(), Code = null
                };

                AutoCodeHelper.UpdateCodesWithCache(
                    context.SqlExecuter, "TestAutoCodeCached.Simple", "Code",
                    new[] { AutoCodeItem.Create(s1, s1.Code) },
                    (item, newCode) => item.Code = newCode);

                Assert.AreEqual("1", s1.Code);
            }
        }
Exemplo n.º 5
0
        public void AllowedNullValueInternally()
        {
            using (var container = new RhetosTestContainer())
            {
                DeleteOldData(container);

                var context = container.Resolve <Common.ExecutionContext>();

                var s1 = new TestAutoCodeCached.Simple {
                    ID = Guid.NewGuid(), Code = null
                };

                AutoCodeHelper.UpdateCodes(
                    context.SqlExecuter, "TestAutoCodeCached.Simple", "Code",
                    new[] { new Rhetos.Dom.DefaultConcepts.AutoCodeItem <TestAutoCodeCached.Simple> {
                                Item = s1, Code = s1.Code, Grouping = ""
                            } },
                    (item, newCode) => item.Code = newCode);

                Assert.IsNull(s1.Code);
            }
        }
Exemplo n.º 6
0
        public void AllowedNullValueInternally()
        {
            using (var container = new RhetosTestContainer())
            {
                DeleteOldData(container);

                var context = container.Resolve<Common.ExecutionContext>();

                var s1 = new TestAutoCodeCached.Simple { ID = Guid.NewGuid(), Code = null };

                AutoCodeHelper.UpdateCodes(
                    context.SqlExecuter, "TestAutoCodeCached.Simple", "Code",
                    new[] { new Rhetos.Dom.DefaultConcepts.AutoCodeItem<TestAutoCodeCached.Simple> { Item = s1, Code = s1.Code, Grouping = "" } },
                    (item, newCode) => item.Code = newCode);

                Assert.IsNull(s1.Code);
            }
        }