Esempio n. 1
0
        public void ErrorMetadataOnUpdate()
        {
            using (var scope = TestScope.Create())
            {
                var repository = scope.Resolve <Common.DomRepository>();
                repository.TestReference.Child.Delete(repository.TestReference.Child.Query());
                repository.TestReference.Parent.Delete(repository.TestReference.Parent.Query());

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

                var c1 = new TestReference.Child {
                    ParentID = p1.ID, Name = "c1"
                };
                repository.TestReference.Child.Insert(c1);

                c1.ParentID = Guid.NewGuid();
                var ex = TestUtility.ShouldFail <UserException>(
                    () => repository.TestReference.Child.Update(c1),
                    "The entered value references nonexistent record");
                Assert.AreEqual("DataStructure:TestReference.Child,Property:ParentID,Referenced:TestReference.Parent", ex.SystemMessage);
            }
        }
Esempio n. 2
0
        public void ErrorMetadataOnDelete()
        {
            using (var container = new RhetosTestContainer())
            {
                var repository = container.Resolve<Common.DomRepository>();
                repository.TestReference.Child.Delete(repository.TestReference.Child.Query());
                repository.TestReference.Parent.Delete(repository.TestReference.Parent.Query());

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

                var c1 = new TestReference.Child { ParentID = p1.ID, Name = "c1" };
                repository.TestReference.Child.Insert(c1);

                var ex = TestUtility.ShouldFail<UserException>(
                    () => repository.TestReference.Parent.Delete(p1),
                    "It is not allowed to delete a record that is referenced by other records.");
                Assert.AreEqual("DataStructure:TestReference.Child,Property:ParentID,Referenced:TestReference.Parent", ex.SystemMessage);
            }
        }
Esempio n. 3
0
        public void ErrorMetadataOnDelete()
        {
            using (var container = new RhetosTestContainer())
            {
                var repository = container.Resolve <Common.DomRepository>();
                repository.TestReference.Child.Delete(repository.TestReference.Child.Query());
                repository.TestReference.Parent.Delete(repository.TestReference.Parent.Query());

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

                var c1 = new TestReference.Child {
                    ParentID = p1.ID, Name = "c1"
                };
                repository.TestReference.Child.Insert(c1);

                var ex = TestUtility.ShouldFail <UserException>(
                    () => repository.TestReference.Parent.Delete(p1),
                    "It is not allowed to delete a record that is referenced by other records.");
                Assert.AreEqual("DataStructure:TestReference.Child,Property:ParentID,Referenced:TestReference.Parent", ex.SystemMessage);
            }
        }