public async Task VoidMode_AsAdmin_ShouldVoidMode() { // Arrange var id = await ModesControllerTestsHelper.CreateModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, Guid.NewGuid().ToString()); var mode = await ModesControllerTestsHelper.GetModeAsync(UserType.LibraryAdmin, TestFactory.PlantWithAccess, id); var currentRowVersion = mode.RowVersion; Assert.IsFalse(mode.IsVoided); // Act var newRowVersion = await ModesControllerTestsHelper.VoidModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, mode.Id, currentRowVersion); // Assert mode = await ModesControllerTestsHelper.GetModeAsync(UserType.LibraryAdmin, TestFactory.PlantWithAccess, id); AssertRowVersionChange(currentRowVersion, newRowVersion); Assert.IsTrue(mode.IsVoided); }
public async Task DeleteMode_AsAdmin_ShouldDeleteMode() { // Arrange var id = await ModesControllerTestsHelper.CreateModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, Guid.NewGuid().ToString()); var mode = await ModesControllerTestsHelper.GetModeAsync(UserType.LibraryAdmin, TestFactory.PlantWithAccess, id); var currentRowVersion = await ModesControllerTestsHelper.VoidModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, mode.Id, mode.RowVersion); // Act await ModesControllerTestsHelper.DeleteModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, mode.Id, currentRowVersion); // Assert var modes = await ModesControllerTestsHelper.GetAllModesAsync(UserType.LibraryAdmin, TestFactory.PlantWithAccess); Assert.IsNull(modes.SingleOrDefault(m => m.Id == id)); }
public async Task GetMode_AsAdmin_ShouldGetMode() { // Act var mode = await ModesControllerTestsHelper.GetModeAsync(UserType.LibraryAdmin, TestFactory.PlantWithAccess, _modeIdUnderTest); // Assert Assert.AreEqual(_modeIdUnderTest, mode.Id); Assert.IsNotNull(mode.RowVersion); }
public async Task UpdateMode_AsAdmin_ShouldUpdateModeAndRowVersion() { var mode = await ModesControllerTestsHelper.GetModeAsync(UserType.LibraryAdmin, TestFactory.PlantWithAccess, _modeIdUnderTest); var currentRowVersion = mode.RowVersion; // Act var newRowVersion = await ModesControllerTestsHelper.UpdateModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, mode.Id, Guid.NewGuid().ToString(), currentRowVersion); // Assert AssertRowVersionChange(currentRowVersion, newRowVersion); }
public async Task GetMode_AsAdmin_ShouldReturnNotFound() => await ModesControllerTestsHelper.GetModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, 9999, HttpStatusCode.NotFound);
public async Task GetMode_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant() => await ModesControllerTestsHelper.GetModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithoutAccess, 9999, HttpStatusCode.Forbidden);
public async Task GetMode_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant() => await ModesControllerTestsHelper.GetModeAsync( UserType.LibraryAdmin, TestFactory.UnknownPlant, 9999, HttpStatusCode.BadRequest, "is not a valid plant");
public async Task GetMode_AsAnonymous_ShouldReturnUnauthorized() => await ModesControllerTestsHelper.GetModeAsync( UserType.Anonymous, TestFactory.UnknownPlant, 9999, HttpStatusCode.Unauthorized);
public async Task GetMode_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing() => await ModesControllerTestsHelper.GetModeAsync( UserType.Preserver, TestFactory.PlantWithAccess, 9999, HttpStatusCode.Forbidden);