public void Test21AddTwiceToErrorHandleDictOk()
        {
            //SETUP
            GenericServicesConfig.AddToSqlHandlerDict(2601, TestExceptionNoCatch);

            //ATTEMPT
            GenericServicesConfig.AddToSqlHandlerDict(2601, TestExceptionCatch, false);

            //VERIFY
            GenericServicesConfig.SqlHandlerDict.Keys.Count().ShouldEqual(1);
            GenericServicesConfig.SqlHandlerDict[2601].Method.Name.ShouldEqual("TestExceptionCatch");
        }
        public void Test20AddTwiceToErrorHandleDictBad()
        {
            //SETUP
            GenericServicesConfig.AddToSqlHandlerDict(2601, TestExceptionNoCatch);

            //ATTEMPT
            var ex =
                Assert.Throws <InvalidOperationException>(
                    () => GenericServicesConfig.AddToSqlHandlerDict(2601, TestExceptionCatch));

            //VERIFY
            ex.Message.ShouldEqual("You tried to add an exception handler for sql error 2601 but a handler called TestExceptionNoCatch was already there.");
        }
        public void Test01ValidateTagCaughtByHandleDictError()
        {
            //SETUP
            GenericServicesConfig.AddToSqlHandlerDict(2601, TestExceptionCatch);
            using (var db = new SampleWebAppDb())
            {
                var existingTag = db.Tags.First();

                //ATTEMPT
                var dupTag = new Tag {
                    Name = "duplicate slug", Slug = existingTag.Slug
                };
                db.Tags.Add(dupTag);
                var status = db.SaveChangesWithChecking();

                //VERIFY
                status.IsValid.ShouldEqual(false);
                status.Errors.Count.ShouldEqual(1);
                status.Errors[0].ErrorMessage.ShouldEqual("SQL error 2601. Following class types had errors: Tag.");
            }
        }
        public void Test10ValidateTagCaughtBySqlDict()
        {
            //SETUP
            GenericServicesConfig.AddToSqlHandlerDict(2601, TestExceptionNoCatch);
            using (var db = new SampleWebAppDb())
            {
                var existingTag = db.Tags.First();

                //ATTEMPT
                var dupTag = new Tag {
                    Name = "duplicate slug", Slug = existingTag.Slug
                };
                db.Tags.Add(dupTag);
                var status = db.SaveChangesWithChecking();

                //VERIFY
                status.IsValid.ShouldEqual(false);
                status.Errors.Count.ShouldEqual(1);
                status.Errors[0].ErrorMessage.ShouldEqual("One of the properties is marked as Unique index and there is already an entry with that value.");
            }
        }