Ejemplo n.º 1
0
        public void DeletePersonal_SelectedItem_NotFounded_NotDelete()
        {
            PersonalTelephone n = null;
            var list            = new List <PersonalTelephone>
            {
                new PersonalTelephone {
                    PhoneNumber = "1234567890000", Id = 5
                }
            }.AsQueryable();

            DataGrid grid = new DataGrid()
            {
                ItemsSource = list, SelectedItem = list.FirstOrDefault()
            };
            var mockSet = new Mock <DbSet <PersonalTelephone> >();

            mockSet.As <IQueryable <PersonalTelephone> >().Setup(m => m.Provider).Returns(list.Provider);
            mockSet.As <IQueryable <PersonalTelephone> >().Setup(m => m.Expression).Returns(list.Expression);
            mockSet.As <IQueryable <PersonalTelephone> >().Setup(m => m.ElementType).Returns(list.ElementType);
            mockSet.As <IQueryable <PersonalTelephone> >().Setup(m => m.GetEnumerator()).Returns(list.GetEnumerator());

            var mockContext = new Mock <PhoneContext>();

            mockContext.Setup(m => m.PersPhone).Returns(mockSet.Object);
            mockSet.Setup(m => m.Find(It.IsAny <int>())).Returns(n);

            DeleteService service = new DeleteService(mockContext.Object);

            service.DeletePersonal(grid);

            mockSet.Verify(m => m.Remove(It.IsAny <PersonalTelephone>()), Times.Never());
            mockContext.Verify(m => m.SaveChanges(), Times.Never());
        }
Ejemplo n.º 2
0
        public void Test10AddressDeleteNotPossibleViaServiceOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var snap    = new CustomerSnapShot(db);
                var service = new DeleteService(db);
                var addressUsedInTwoPlaces =
                    db.Addresses.Include(x => x.CustomerAddresses)
                    .AsNoTracking()
                    .OrderByDescending(x => x.AddressID)
                    .First(x => x.CustomerAddresses.Count > 0 && x.SalesOrderHeaders.Count > 0);

                //ATTEMPT
                var status = service.DeleteWithRelationships <CustomerAddress>(DeleteHelpers.DeleteAssociatedAddress,
                                                                               addressUsedInTwoPlaces.CustomerAddresses.First().CustomerID,
                                                                               addressUsedInTwoPlaces.AddressID);

                //VERIFY
                status.IsValid.ShouldEqual(false, status.Errors);
                status.Errors.Count.ShouldEqual(1);
                status.Errors.First().ErrorMessage.ShouldEqual("This operation failed because another data entry uses this entry.");
                snap.CheckSnapShot(db);
            }
        }
        public void DeleteService_Action_Fails()
        {
            // Arrange
            var serviceDto = TestHelper.ServiceDto();

            GenericServiceResponse <bool> fakeResponse = null;

            mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable();
            mockClientServicesProvider.Setup(x => x.ServiceService.DeleteService(serviceDto)).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericViewModel();

            var action = new DeleteService <GenericViewModel>(mockClientServicesProvider.Object)
            {
                OnComplete = model => viewModel = model
            };

            // Act
            var result = action.Invoke(serviceDto);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(GenericViewModel));
            Assert.IsNotNull(result.Notifications);
            Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection));
            Assert.IsTrue(result.Notifications.Count() == 1);
            Assert.IsTrue(result.HasErrors);
            Assert.IsNotNull(result.Success);
            Assert.IsInstanceOfType(result.Success, typeof(bool));
            Assert.IsFalse(result.Success);
        }
Ejemplo n.º 4
0
        public DeleteServiceTests()
        {
            _indexDataStore        = Substitute.For <IIndexDataStore>();
            _metadataStore         = Substitute.For <IMetadataStore>();
            _fileDataStore         = Substitute.For <IFileStore>();
            _indexDataStoreFactory = Substitute.For <IIndexDataStoreFactory>();
            _deleteConfiguration   = new DeletedInstanceCleanupConfiguration
            {
                DeleteDelay     = TimeSpan.FromDays(1),
                BatchSize       = 10,
                MaxRetries      = 5,
                PollingInterval = TimeSpan.FromSeconds(1),
                RetryBackOff    = TimeSpan.FromDays(4),
            };

            IOptions <DeletedInstanceCleanupConfiguration> deletedInstanceCleanupConfigurationOptions = Substitute.For <IOptions <DeletedInstanceCleanupConfiguration> >();

            deletedInstanceCleanupConfigurationOptions.Value.Returns(_deleteConfiguration);
            ITransactionHandler transactionHandler = Substitute.For <ITransactionHandler>();

            _transactionScope = Substitute.For <ITransactionScope>();
            transactionHandler.BeginTransaction().Returns(_transactionScope);

            _indexDataStoreFactory.GetInstance().Returns(_indexDataStore);
            _deleteService = new DeleteService(_indexDataStoreFactory, _metadataStore, _fileDataStore, deletedInstanceCleanupConfigurationOptions, transactionHandler, NullLogger <DeleteService> .Instance);
        }
Ejemplo n.º 5
0
        public async Task InitializeAsync()
        {
            await _sqlDataStoreTestsFixture.InitializeAsync();

            await _blobStorageTestsFixture.InitializeAsync();

            var cleanupConfiguration = new DeletedInstanceCleanupConfiguration
            {
                BatchSize       = 10,
                DeleteDelay     = TimeSpan.FromSeconds(1),
                MaxRetries      = 3,
                PollingInterval = TimeSpan.FromSeconds(1),
                RetryBackOff    = TimeSpan.FromSeconds(2),
            };

            var optionsConfiguration = Substitute.For <IOptions <DeletedInstanceCleanupConfiguration> >();

            optionsConfiguration.Value.Returns(cleanupConfiguration);
            DeleteService = new DeleteService(
                _sqlDataStoreTestsFixture.SqlIndexDataStoreFactory,
                _blobStorageTestsFixture.MetadataStore,
                _blobStorageTestsFixture.FileStore,
                optionsConfiguration,
                _sqlDataStoreTestsFixture.SqlTransactionHandler,
                NullLogger <DeleteService> .Instance);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public DeleteServiceTests()
        {
            _indexDataStore      = Substitute.For <IIndexDataStore>();
            _metadataStore       = Substitute.For <IMetadataStore>();
            _fileDataStore       = Substitute.For <IFileStore>();
            _deleteConfiguration = new DeletedInstanceCleanupConfiguration
            {
                DeleteDelay     = TimeSpan.FromDays(1),
                BatchSize       = 10,
                MaxRetries      = 5,
                PollingInterval = TimeSpan.FromSeconds(1),
                RetryBackOff    = TimeSpan.FromDays(4),
            };

            IOptions <DeletedInstanceCleanupConfiguration> deletedInstanceCleanupConfigurationOptions = Substitute.For <IOptions <DeletedInstanceCleanupConfiguration> >();

            deletedInstanceCleanupConfigurationOptions.Value.Returns(_deleteConfiguration);
            ITransactionHandler transactionHandler = Substitute.For <ITransactionHandler>();

            _transactionScope = Substitute.For <ITransactionScope>();
            transactionHandler.BeginTransaction().Returns(_transactionScope);
            _dicomRequestContextAccessor = Substitute.For <IDicomRequestContextAccessor>();
            _dicomRequestContextAccessor.RequestContext.DataPartitionEntry = new PartitionEntry(DefaultPartition.Key, DefaultPartition.Name);

            _deleteService = new DeleteService(_indexDataStore, _metadataStore, _fileDataStore, deletedInstanceCleanupConfigurationOptions, transactionHandler, NullLogger <DeleteService> .Instance, _dicomRequestContextAccessor);
        }
Ejemplo n.º 8
0
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     if (Id_Country != 0)
     {
         DeleteService.DeleteAllCoutry(Id_Country);
     }
 }
        public async Task InitializeAsync()
        {
            await _sqlDataStoreTestsFixture.InitializeAsync();

            await _blobStorageTestsFixture.InitializeAsync();

            var cleanupConfiguration = new DeletedInstanceCleanupConfiguration
            {
                BatchSize       = 10,
                DeleteDelay     = TimeSpan.FromSeconds(1),
                MaxRetries      = 3,
                PollingInterval = TimeSpan.FromSeconds(1),
                RetryBackOff    = TimeSpan.FromSeconds(2),
            };

            var optionsConfiguration = Substitute.For <IOptions <DeletedInstanceCleanupConfiguration> >();

            optionsConfiguration.Value.Returns(cleanupConfiguration);
            var dicomRequestContextAccessor = Substitute.For <IDicomRequestContextAccessor>();

            dicomRequestContextAccessor.RequestContext.DataPartitionEntry = new PartitionEntry(DefaultPartition.Key, DefaultPartition.Name);

            DeleteService = new DeleteService(
                _sqlDataStoreTestsFixture.IndexDataStore,
                _blobStorageTestsFixture.MetadataStore,
                _blobStorageTestsFixture.FileStore,
                optionsConfiguration,
                _sqlDataStoreTestsFixture.SqlTransactionHandler,
                NullLogger <DeleteService> .Instance,
                dicomRequestContextAccessor);
        }
Ejemplo n.º 10
0
        public void DeleteCorporative_SelectedItem_Founded_ClickYes_Delete()
        {
            var list = new List <CorporativeTelephone>
            {
                new CorporativeTelephone {
                    PhoneNumber = "1234567890000", Id = 5
                }
            }.AsQueryable();

            DataGrid grid = new DataGrid()
            {
                ItemsSource = list, SelectedItem = list.FirstOrDefault()
            };
            var mockSet = new Mock <DbSet <CorporativeTelephone> >();

            mockSet.As <IQueryable <CorporativeTelephone> >().Setup(m => m.Provider).Returns(list.Provider);
            mockSet.As <IQueryable <CorporativeTelephone> >().Setup(m => m.Expression).Returns(list.Expression);
            mockSet.As <IQueryable <CorporativeTelephone> >().Setup(m => m.ElementType).Returns(list.ElementType);
            mockSet.As <IQueryable <CorporativeTelephone> >().Setup(m => m.GetEnumerator()).Returns(list.GetEnumerator());

            var mockContext = new Mock <PhoneContext>();

            mockContext.Setup(m => m.CorpPhones).Returns(mockSet.Object);
            mockSet.Setup(m => m.Find(It.IsAny <int>())).Returns(new CorporativeTelephone {
                PhoneNumber = "1234567890000", Id = 5
            });

            DeleteService service = new DeleteService(mockContext.Object);

            service.DeleteCorporative(grid);

            mockSet.Verify(m => m.Remove(It.IsAny <CorporativeTelephone>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
Ejemplo n.º 11
0
 public DeletePage()
 {
     InitializeComponent();
     context = new PhoneContext();
     service = new DeleteService(context);
     personalGrid.ItemsSource    = context.PersPhone.ToList();
     corporativeGrid.ItemsSource = context.CorpPhones.ToList();
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Deletes the business's all services.
        /// </summary>
        /// <param name="uConn">The UDDI connection.</param>
        /// <param name="pName">Name of the provider</param>
        public static void DeleteBusinessAllServices(UddiConnection uConn, string pName)
        {
            BusinessEntity businessEntity = UDDISearcher.GetBusinessEntity(uConn, UDDISearcher.GetBusinessKey(uConn, pName));

            foreach (BusinessService businessService in businessEntity.BusinessServices)
            {
                DeleteService dService = new DeleteService(businessService.ServiceKey);
                dService.Send(uConn);
            }
        }
Ejemplo n.º 13
0
 public StatUnitsController(NSCRegDbContext context, StatUnitAnalysisRules statUnitAnalysisRules,
                            DbMandatoryFields mandatoryFields, ValidationSettings validationSettings)
 {
     _searchService  = new SearchService(context);
     _viewService    = new ViewService(context, mandatoryFields);
     _createService  = new CreateService(context, statUnitAnalysisRules, mandatoryFields, validationSettings, StatUnitTypeOfSave.WebApplication);
     _editService    = new EditService(context, statUnitAnalysisRules, mandatoryFields, validationSettings);
     _deleteService  = new DeleteService(context);
     _historyService = new HistoryService(context);
 }
Ejemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult DeleteReservationDate(Guid id)
        {
            var date = Db.ActivityDates.SingleOrDefault(d => d.Id == id);

            var activity = date.Activity;

            DeleteService.DeleteActivityDate(id);

            return(RedirectToAction("Details", new { id = activity.Id }));
        }
Ejemplo n.º 15
0
        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();
            }
        }
Ejemplo n.º 18
0
 public SuppliersController(
     ILogger <SuppliersController> logger,
     WarehouseContext context,
     IExceptionLogger exceptionLogger)
 {
     _logger          = logger;
     _exceptionLogger = exceptionLogger;
     _postService     = new PostService(context);
     _putService      = new PutService <Supplier>(context, context.Suppliers);
     _deleteService   = new DeleteService <Supplier>(context, context.Suppliers, nameof(Supplier));
     _getService      = new GetService <Supplier>(context.Suppliers, nameof(Supplier));
 }
Ejemplo n.º 19
0
 public UnitsController(
     ILogger <UnitsController> logger,
     IExceptionLogger exceptionLogger,
     WarehouseContext context)
 {
     _logger          = logger;
     _exceptionLogger = exceptionLogger;
     _postService     = new PostService(context);
     _putService      = new PutService <Unit>(context, context.Units);
     _deleteService   = new DeleteService <Unit>(context, context.Units, nameof(Unit));
     _getService      = new GetService <Unit>(context.Units, nameof(Unit));
 }
Ejemplo n.º 20
0
        public CategoriesController(
            ILogger <CategoriesController> logger,
            WarehouseContext context,
            IExceptionLogger exceptionLogger)
        {
            _logger          = logger;
            _exceptionLogger = exceptionLogger;

            _postService   = new PostService(context);
            _putService    = new PutService <Category>(context, context.Categories);
            _getService    = new GetService <Category>(context.Categories, nameof(Category));
            _deleteService = new DeleteService <Category>(context, context.Categories, nameof(Supplier));
        }
Ejemplo n.º 21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="expService"></param>
 /// <param name="editService"></param>
 /// <param name="deleteService"></param>
 /// <param name="createService"></param>
 /// <param name="detailService"></param>
 /// <param name="rankMoviesService"></param>
 public MediaController(ExportService expService,
                        EditService editService,
                        DeleteService deleteService,
                        CreateService createService,
                        DetailsService detailService,
                        RankMoviesService rankMoviesService)
 {
     _expService        = expService;
     _editService       = editService;
     _deleteService     = deleteService;
     _createService     = createService;
     _detailService     = detailService;
     _rankMoviesService = rankMoviesService;
 }
Ejemplo n.º 22
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 Test41DeleteWithRelationshipsViaDtoBad()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DeleteService(db);

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

                //VERIFY
                ex.Message.ShouldEqual("The entity type SimplePostDto is not part of the model for the current context.");
            }
        }
Ejemplo n.º 24
0
        public async Task DeleteServiceRoute()
        {
            var comand = new DeleteService(1);

            var result = await _handler.Handle(comand, GetCancelationToken(TimeSpan.FromSeconds(1)).Token);

            Assert.NotNull(result);

            var objectResult = result as Response;

            Assert.NotNull(objectResult);

            Assert.Equal("Serviço excluido com sucesso!", objectResult.Result);
        }
Ejemplo n.º 25
0
        public ProductsController(
            ILogger <ProductsController> logger,
            WarehouseContext context,
            IExceptionLogger exceptionLogger)
        {
            _logger          = logger;
            _context         = context;
            _exceptionLogger = exceptionLogger;

            _postService       = new PostService(context);
            _putService        = new PutService <Product>(context, context.Products);
            _getService        = new GetProductsService(context);
            _deleteService     = new DeleteService <Product>(context, context.Products, nameof(Product));
            _validationService = new ValidationService(context);
        }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
 public DataSourcesQueueService(NSCRegDbContext ctx,
                                CreateService createSvc,
                                EditService editSvc,
                                ServicesSettings config,
                                DbMandatoryFields dbMandatoryFields)
 {
     _dbContext             = ctx;
     _createSvc             = createSvc;
     _editSvc               = editSvc;
     _rootPath              = config.RootPath;
     _uploadDir             = config.UploadDir;
     _dbMandatoryFields     = dbMandatoryFields;
     _statUnitDeleteService = new DeleteService(ctx);
     _elasticService        = new ElasticService(ctx);
 }
Ejemplo n.º 28
0
        public DispositionReport Send(DeleteService deleteService, AuthToken authToken)
        {
            SetAuthToken(deleteService, authToken);

            try
            {
                return(soapClient.DeleteService(deleteService));
            }
            catch (UddiException uddiException)
            {
                AttemptRefreshAuthInfo(uddiException, authToken);

                return(soapClient.DeleteService(deleteService));
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult DeleteReservationConfirmed(Guid id)
        {
            var reservation = Db.Activities.OfType <Reservation>().SingleOrDefault(r => r.Id == id);

            var dateList = reservation.Dates.ToList();

            foreach (var date in dateList)
            {
                DeleteService.DeleteActivityDate(date.Id);
            }

            Db.Activities.Remove(reservation);
            Db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        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);
            }
        }
Ejemplo n.º 31
0
        public void Check11DeleteWithRelationshipsDirectOk()
        {
            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.DeleteWithRelationships <Post>(DeleteBloggerWithPost, firstPostUntracked.PostId);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.SuccessMessage.ShouldEqual("Successfully deleted Post and given relationships.");
                snap.CheckSnapShot(db, -1, -2, -1, 0, -2);
            }
        }
        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 DeleteService_Test()
        {
            using (ShimsContext.Create())
            {
                CloudFoundry.CloudController.V2.Client.Fakes.ShimCloudFoundryClient.AllInstances.LoginCloudCredentials = TestUtils.CustomLogin;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractSpacesEndpoint.AllInstances.ListAllSpacesRequestOptions = TestUtils.CustomListAllSpaces;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllSpacesResponse>.AllInstances.ResourcesGet = TestUtils.CustomGetPaged;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractSpacesEndpoint.AllInstances.ListAllServiceInstancesForSpaceNullableOfGuidRequestOptions = TestUtils.CustomListAllServiceInstances;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllServiceInstancesForSpaceResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllServiceInstancesResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractServiceInstancesEndpoint.AllInstances.DeleteServiceInstanceNullableOfGuid = TestUtils.CustomDeleteServiceInstance;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllOrganizationsResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllOrganizationsResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllOrganizationsRequestOptions = TestUtils.CustomListAllOrganizations;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllSpacesForOrganizationResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllSpacesForOrganizationResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllSpacesForOrganizationNullableOfGuidRequestOptions = TestUtils.CustomListAllSpacesForOrganization;

                TestUtils.InitTestMetadata();

                DeleteService task = new DeleteService();
                task.CFUser = Settings.Default.User;
                task.CFPassword = Settings.Default.Password;
                task.CFServerUri = Settings.Default.ServerUri;
                task.CFSpace = "TestSpace";
                task.CFOrganization = "TestOrg";
                task.CFServiceName = "service1";

                task.BuildEngine = new FakeBuildEngine();
                Assert.IsTrue(task.Execute());

            }
        }
        public void Test11DeleteLineItemCheckHeaderOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                AddLineItem(db, 10);
                var newOrder = AddLineItem(db, 5);
                var service = new DeleteService(db);

                //ATTEMPT
                var status = service.DeleteWithRelationships<SalesOrderDetail>(DeleteLineItemHelper.UpdateSalesOrderHeader, newOrder.SalesOrderID, newOrder.SalesOrderDetailID);

                //VERIFY
                status.ShouldBeValid();
                db.SalesOrderDetails.Any( x => x.SalesOrderDetailID == newOrder.SalesOrderDetailID).ShouldEqual(false);
                CheckTotals(db);
            }
        }
        public void Test10AddressDeleteNotPossibleViaServiceOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var snap = new CustomerSnapShot(db);
                var service = new DeleteService(db);
                var addressUsedInTwoPlaces =
                    db.Addresses.Include(x => x.CustomerAddresses)
                        .AsNoTracking()
                        .OrderByDescending(x => x.AddressID)
                        .First(x => x.CustomerAddresses.Count > 0 && x.SalesOrderHeaders.Count > 0);

                //ATTEMPT
                var status = service.DeleteWithRelationships<CustomerAddress>(DeleteHelpers.DeleteAssociatedAddress,
                    addressUsedInTwoPlaces.CustomerAddresses.First().CustomerID,
                    addressUsedInTwoPlaces.AddressID);

                //VERIFY
                status.IsValid.ShouldEqual(false, status.Errors);
                status.Errors.Count.ShouldEqual(1);
                status.Errors.First().ErrorMessage.ShouldEqual("This operation failed because another data entry uses this entry.");
                snap.CheckSnapShot(db);
            }
        }
        public void Test11AddressDeleteViaServiceOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var snap = new CustomerSnapShot(db);
                var service = new DeleteService(db);
                var addressUsedInTwoPlaces =
                    db.Addresses.Include(x => x.CustomerAddresses)
                        .AsNoTracking()
                        .OrderByDescending(x => x.AddressID)
                        .First(x => x.CustomerAddresses.Count == 1 && x.SalesOrderHeaders.Count == 0 && x.SalesOrderHeaders1.Count == 0);

                //ATTEMPT
                var status = service.DeleteWithRelationships<CustomerAddress>(DeleteHelpers.DeleteAssociatedAddress,
                    addressUsedInTwoPlaces.CustomerAddresses.First().CustomerID,
                    addressUsedInTwoPlaces.AddressID);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                snap.CheckSnapShot(db, 0, -1, -1);
            }
        }
Ejemplo n.º 37
0
 public ActionResult Delete(Guid id)
 {
     DeleteService deleteEntry = new DeleteService();
     deleteEntry.DeleteForID(id);
     return RedirectToAction("Index");
 }
        public void Test41DeleteWithRelationshipsViaDtoBad()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DeleteService(db);

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

                //VERIFY
                ex.Message.ShouldEqual("The entity type SimplePostDto is not part of the model for the current context.");
            }
        }
Ejemplo n.º 39
0
        /// <summary>
        ///     Sterge un grup de servicii de pe serverul UDDI.
        /// </summary>
        /// <param name="serviceKey">Cheia BusinessService-ului folosit pentru stocarea grupului de servicii pe serverul UDDI.</param>
        /// <returns>Raport al stergerii grupului de servicii (BusinessService-ului) de pe serverul UDDI.</returns>
        private DispositionReport performDeleteService(string serviceKey)
        {
            DeleteService deleteService         = new DeleteService(serviceKey);

            DispositionReport dispositionReport = deleteService.Send(uddiConnection);

            return dispositionReport;
        }
        public void Test43DeleteWithRelationshipsDirectFailOk()
        {
            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.DeleteWithRelationships<Post>(FailDeleteRelationships, firstPostUntracked.PostId);

                //VERIFY
                status.IsValid.ShouldEqual(false);
                status.Errors.Count.ShouldEqual(1);
                status.Errors[0].ErrorMessage.ShouldEqual("I failed.");
                snap.CheckSnapShot(db);
            }
        }
        public void Test41DeleteWithRelationshipsDirectOk()
        {
            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.DeleteWithRelationships<Post>(DeleteBloggerWithPost, firstPostUntracked.PostId);

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