public void DeleteDataModels_RelatedModelException()
        {
            _data.Add(new ProjectDataModel
            {
                Id         = 2,
                Name       = "Category",
                ProjectId  = 1,
                Properties = new List <ProjectDataModelProperty>
                {
                    new ProjectDataModelProperty
                    {
                        Name = "Products",
                        RelatedProjectDataModelId = 1,
                        RelatedProjectDataModel   = new ProjectDataModel
                        {
                            Id   = 1,
                            Name = "Product"
                        }
                    }
                },
            });

            _data.Add(new ProjectDataModel
            {
                Id         = 3,
                Name       = "Service",
                ProjectId  = 1,
                Properties = new List <ProjectDataModelProperty>
                {
                    new ProjectDataModelProperty
                    {
                        Name = "Category",
                        RelatedProjectDataModelId = 2,
                        RelatedProjectDataModel   = new ProjectDataModel
                        {
                            Id   = 1,
                            Name = "Category"
                        }
                    }
                },
            });

            var projectDataModelService = new ProjectDataModelService(_dataModelRepository.Object, _propertyRepository.Object, _projectRepository.Object);

            var exception = Record.ExceptionAsync(() => projectDataModelService.DeleteDataModels(1, new int[] { 1, 2 }));

            Assert.IsType <RelatedProjectDataModelException>(exception?.Result);
            Assert.Equal($"Cannot perform bulk delete because the following models depend on the models to be deleted: Service", exception?.Result.Message);
        }
        public async void DeleteDataModels_ValidItem()
        {
            var relatedModel = new ProjectDataModel
            {
                Id         = 2,
                Name       = "Category",
                ProjectId  = 1,
                Properties = new List <ProjectDataModelProperty>
                {
                    new ProjectDataModelProperty
                    {
                        Name = "Products",
                        RelatedProjectDataModelId = 1
                    }
                }
            };

            _data.Add(relatedModel);

            int callOrder = 0;

            _dataModelRepository.Setup(r => r.Delete(2, It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask).Callback((int id, CancellationToken cancellationToken) =>
            {
                Assert.Equal(0, callOrder++);
            });

            _dataModelRepository.Setup(r => r.Delete(1, It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask).Callback((int id, CancellationToken cancellationToken) =>
            {
                Assert.Equal(1, callOrder);
            });

            var projectDataModelService = new ProjectDataModelService(_dataModelRepository.Object, _propertyRepository.Object, _projectRepository.Object);
            await projectDataModelService.DeleteDataModels(1, new int[] { 1, 2 });
        }