public void CheckConstraintViolationExceptionIsRecognized2()
        {
            // --- Arrange
            var child = new ChildRecord
            {
                Name  = "Child",
                Value = 4
            };

            using (var ctx = DataAccessFactory.CreateContext <ITestDataOperations>())
            {
                ctx.InsertChild(child);
            }

            // --- Act
            CheckConstraintViolationException exCaught = null;

            try
            {
                using (var ctx = DataAccessFactory.CreateContext <ITestDataOperations>())
                {
                    child.Value = 14;
                    ctx.UpdateChild(child);
                }
            }
            catch (CheckConstraintViolationException ex)
            {
                exCaught = ex;
            }

            // --- Assert
            // ReSharper disable once PossibleNullReferenceException
            exCaught.TableName.ShouldEqual("dbo.Child");
            exCaught.CheckName.ShouldEqual("CK_Child_Value");
        }
        public void UniqueKeyExceptionIsRecognized1()
        {
            // --- Arrange
            var child1 = new ChildRecord
            {
                Name  = "Child1",
                Value = 1
            };
            var child2 = new ChildRecord
            {
                Name  = "Child1",
                Value = 2
            };

            // --- Act
            UniqueKeyViolationException exCaught = null;

            try
            {
                using (var ctx = DataAccessFactory.CreateContext <ITestDataOperations>())
                {
                    ctx.InsertChild(child1);
                    ctx.InsertChild(child2);
                }
            }
            catch (UniqueKeyViolationException ex)
            {
                exCaught = ex;
            }

            // --- Assert
            // ReSharper disable once PossibleNullReferenceException
            exCaught.TableName.ShouldEqual("dbo.Child");
            exCaught.KeyName.ShouldEqual("AK_Child_Name");
        }
        public void NullValueNotAllowedExceptionIsRecognized2()
        {
            // --- Arrange
            var child = new ChildRecord
            {
                Name  = "Child",
                Value = 2
            };

            using (var ctx = DataAccessFactory.CreateContext <ITestDataOperations>())
            {
                ctx.InsertChild(child);
            }

            // --- Act
            NullValueNotAllowedException exCaught = null;

            try
            {
                using (var ctx = DataAccessFactory.CreateContext <ITestDataOperations>())
                {
                    child.Value = null;
                    ctx.UpdateChild(child);
                }
            }
            catch (NullValueNotAllowedException ex)
            {
                exCaught = ex;
            }

            // --- Assert
            // ReSharper disable once PossibleNullReferenceException
            exCaught.TableName.ShouldEqual("Seemplest.Test.dbo.Child");
            exCaught.ColumnName.ShouldEqual("Value");
        }
        public void ForeignKeyExceptionIsRecognized1()
        {
            // --- Arrange
            var parent = new ParentRecord
            {
                Name = "Parent",
            };
            var child = new ChildRecord
            {
                Name     = "Child1",
                Value    = 1,
                ParentId = -1
            };

            // --- Act
            ForeignKeyViolationException exCaught = null;

            try
            {
                using (var ctx = DataAccessFactory.CreateContext <ITestDataOperations>())
                {
                    ctx.InsertParent(parent, false);
                    ctx.InsertChild(child);
                }
            }
            catch (ForeignKeyViolationException ex)
            {
                exCaught = ex;
            }

            // --- Assert
            // ReSharper disable once PossibleNullReferenceException
            exCaught.KeyName.ShouldEqual("FK_Child_ToParent");
        }
Exemple #5
0
        private async void HyperlinkClicked(ChildRecord child)
        {
            string firstName  = child.FirstName;
            string lastName   = child.LastName;
            int    maxRows    = 1000;
            int    pageNo     = 1;
            int    pageSize   = 25;
            string sortColumn = "name";
            string isortOrder = "ASC";

            Application.Current.MainPage = new Views.ChildInformationpageView(child.OfflineStudentId);
        }
Exemple #6
0
        private async void EditChildClicked(ChildRecord childRecord)
        {
            if (editIconClicked || actionIconClicked)
            {
                return;
            }

            editIconClicked = true;
            await App.Current.MainPage.Navigation.PushModalAsync(new ChildTabbedPage(childRecord.OfflineStudentId));

            await Task.Delay(300);

            editIconClicked = false;
        }
Exemple #7
0
        private async void ActionClicked(ChildRecord child)
        {
            if (actionIconClicked || editIconClicked)
            {
                return;
            }

            FullName          = child.FirstName + " " + child.LastName;
            actionIconClicked = true;
            await PopupNavigation.Instance.PushAsync(new AssessmentConfigPopupView(child.OfflineStudentId));

            await Task.Delay(300);

            actionIconClicked = false;
        }
 public int UpdateChild(ChildRecord record)
 {
     Operation(ctx => ctx.Update(record));
     return(record.Id);
 }
 public int InsertChild(ChildRecord record)
 {
     Operation(ctx => ctx.Insert(record));
     return(record.Id);
 }