예제 #1
0
        //--------------------------

        public static void DeletePostGenericDirect(this SampleWebAppDb db, int postId)
        {
            var service = new DeleteService(db);
            var status  = service.Delete <Post>(postId);

            status.IsValid.ShouldEqual(true, status.Errors);
        }
        public void ThrowArgumentNullException_WhenAnItemToDeleteIsNotProvided()
        {
            // Arrange
            var dbSetWrapperMock         = new Mock <IEfDbSetWrapper <Photo> >();
            var dbContextSaveChangesMock = new Mock <IEfDbContextSaveChanges>();

            IDeleteService <Photo> deleteService = new DeleteService <Photo>(dbSetWrapperMock.Object, dbContextSaveChangesMock.Object);

            // Act, Assert
            Assert.Throws <ArgumentNullException>(() => deleteService.Delete(null));
        }
        public void FixtureTearDown()
        {
            //we delete our unit test SaleOrderHeader
            using (var db = new AdventureWorksLt2012())
            {
                var service = new DeleteService(db);

                var status = service.Delete<SalesOrderHeader>(_salesOrderId);
                status.ShouldBeValid();
            }
        }
        public void FixtureTearDown()
        {
            //we delete our unit test SaleOrderHeader
            using (var db = new AdventureWorksLt2012())
            {
                var service = new DeleteService(db);

                var status = service.Delete <SalesOrderHeader>(_salesOrderId);
                status.ShouldBeValid();
            }
        }
        public void Test40DeleteViaDtoBad()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DeleteService(db);

                //ATTEMPT
                var ex = Assert.Throws <InvalidOperationException>(() => service.Delete <SimplePostDto>(0));

                //VERIFY
                ex.Message.ShouldEqual("The entity type SimplePostDto is not part of the model for the current context.");
            }
        }
예제 #6
0
        private static void Run(Options options)
        {
            // 'parse' the commandline options
            var config = new DeleteConfiguration(options);

            // Run the Delete/Purge
            var errors = DeleteService.Delete(config);

            if (errors.Any())
            {
                ConsoleHelpers.WriteErrors(errors);
                _returnCode = FAILURE;
            }
        }
        public void InvokeDeleteMethodFromDbSetWrapper_WhenAnItemToDeleteIsProvided()
        {
            // Arrange
            var itemMock                 = new Mock <Tag>();
            var dbSetWrapperMock         = new Mock <IEfDbSetWrapper <Tag> >();
            var dbContextSaveChangesMock = new Mock <IEfDbContextSaveChanges>();

            IDeleteService <Tag> deleteService = new DeleteService <Tag>(dbSetWrapperMock.Object, dbContextSaveChangesMock.Object);

            // Act
            deleteService.Delete(itemMock.Object);

            // Assert
            dbSetWrapperMock.Verify(x => x.Delete(itemMock.Object), Times.Once);
        }
        public void Check01PostTagGradeDeleteOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var snap              = new DbSnapShot(db);
                var service           = new DeleteService(db);
                var firstPtgUntracked = db.PostTagGrades.AsNoTracking().First();

                //ATTEMPT
                var status = service.Delete <PostTagGrade>(firstPtgUntracked.PostId, firstPtgUntracked.TagId);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                snap.CheckSnapShot(db, 0, 0, 0, 0, -1);
            }
        }
        public void Check01PostTagGradeDeleteOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var snap = new DbSnapShot(db);
                var service = new DeleteService(db);
                var firstPtgUntracked = db.PostTagGrades.AsNoTracking().First();

                //ATTEMPT
                var status = service.Delete<PostTagGrade>(firstPtgUntracked.PostId, firstPtgUntracked.TagId);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                snap.CheckSnapShot(db, 0,0,0,0,-1);

            }
        }
예제 #10
0
        public void Check10DeleteDirectOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var snap = new DbSnapShot(db);
                var firstPostUntracked = db.Posts.AsNoTracking().First();
                var service            = new DeleteService(db);

                //ATTEMPT
                var status = service.Delete <Post>(firstPostUntracked.PostId);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.SuccessMessage.ShouldEqual("Successfully deleted Post.");
                snap.CheckSnapShot(db, -1, -2, 0, 0, -2);
            }
        }
예제 #11
0
        public DispositionReport DeleteService(DeleteService ds)
        {
            Debug.Enter();
            DispositionReport dr = new DispositionReport();

            try
            {
                //
                // Delete the service
                //
                ds.Delete();
            }
            catch (Exception e)
            {
                DispositionReport.Throw(e);
            }

            return(dr);
        }
        public void Test40DeleteViaDtoBad()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DeleteService(db);

                //ATTEMPT
                var ex = Assert.Throws<InvalidOperationException>(() => service.Delete<SimplePostDto>(0));

                //VERIFY
                ex.Message.ShouldEqual("The entity type SimplePostDto is not part of the model for the current context.");
            }
        }
        public void Test40DeleteDirectOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var snap = new DbSnapShot(db);
                var firstPostUntracked = db.Posts.AsNoTracking().First();
                var service = new DeleteService(db);

                //ATTEMPT
                var status = service.Delete<Post>(firstPostUntracked.PostId);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.SuccessMessage.ShouldEqual("Successfully deleted Post.");
                snap.CheckSnapShot(db, -1,-2, 0, 0, -2);
            }
        }