public void UpdateElement_ElementDoesNotExist_NotFound() { //Arrange var userId = NewGuid; var newLink = NewGuid; var updateData = new ElementUpdateData { Link = newLink }; 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.UpdateElement(collection.Id, element.Id + 1, updateData); }); //Assert result.Should().BeOfType <NotFoundResult>(); }
public void UpdateElement_CollectionNotOwnedByUserButHasEditRights_Ok() { //Arrange var userId1 = NewGuid; var userId2 = NewGuid; var newLink = NewGuid; var updateData = new ElementUpdateData { Link = newLink }; 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.UpdateElement(collection.Id, element.Id, updateData); }); //Assert result.Should().BeOfType <OkResult>(); }
public void UpdateElement_MixedUpdateData_ProperFieldsUpdated(string newName, string newLink) { //Arrange var userId = NewGuid; var updateData = new ElementUpdateData { Link = newLink, Name = newName }; AddUser(userId); var collection = AddCollection(userId, 50); 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.UpdateElement(collection.Id, element.Id, updateData); }); //Assert result.Should().BeOfType <OkResult>(); InTransaction(context => { context.Element.Single(el => el.Id == element.Id).Link.Should().Be(newLink ?? element.Link); context.Element.Single(el => el.Id == element.Id).Name.Should().Be(newName ?? element.Name); }); }