public void DeleteElement_CollectionNotOwnedByUserButHasEditRights_Ok()
        {
            //Arrange
            var userId1 = NewGuid;
            var userId2 = NewGuid;
            var newLink = NewGuid;

            AddUser(userId1);
            AddUser(userId2);
            var collection = AddCollection(userId1, 50);

            ShareCollection(collection.Id, userId2, true);
            Element element = null;

            InTransaction(context =>
            {
                element = context.Element.First();
            });

            //Act
            IActionResult result = null;

            InTransaction(context =>
            {
                var controller = new ElementsController(context, GetUserProviderMock(userId2), getCollectionConfigurationProviderMock());
                result         = controller.DeleteElement(collection.Id, element.Id);
            });

            //Assert
            result.Should().BeOfType <OkResult>();
        }
        public void DeleteElement_ElementDoesNotExist_NotFound()
        {
            //Arrange
            var userId = NewGuid;

            AddUser(userId);
            var     collection = AddCollection(userId, 1);
            Element element    = null;

            InTransaction(context =>
            {
                element = context.Element.First();
            });

            //Act
            IActionResult result = null;

            InTransaction(context =>
            {
                var controller = new ElementsController(context, GetUserProviderMock(userId), getCollectionConfigurationProviderMock());
                result         = controller.DeleteElement(collection.Id, element.Id + 1);
            });

            //Assert
            result.Should().BeOfType <NotFoundResult>();
        }
        public void DeleteElement_ElementHasSucceedingElements_SequencesAdjusted()
        {
            //Arrange
            var userId1 = NewGuid;
            var userId2 = NewGuid;

            AddUser(userId1);
            AddUser(userId2);
            var collection = AddCollection(userId1, 50);

            ShareCollection(collection.Id, userId2, true);
            Element element = null;

            InTransaction(context =>
            {
                element = context.Element.First();
            });

            //Act
            IActionResult result = null;

            InTransaction(context =>
            {
                var controller = new ElementsController(context, GetUserProviderMock(userId2), getCollectionConfigurationProviderMock());
                result         = controller.DeleteElement(collection.Id, element.Id);
            });

            //Assert
            InTransaction(context =>
            {
                var collectionFromContext = context.Collection
                                            .Include(c => c.Elements)
                                            .Single(c => c.Id == collection.Id);
                var elements         = collectionFromContext.Elements.OrderBy(s => s.Sequence);
                var expectedSequence = 0;
                foreach (var element in elements)
                {
                    element.Sequence.Should().Be(expectedSequence);
                    expectedSequence++;
                }
            });
        }