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 CreateMode_AsAdmin_ShouldCreateMode() { // Act var title = Guid.NewGuid().ToString(); var id = await ModesControllerTestsHelper.CreateModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, title); // Assert Assert.IsTrue(id > 0); var modes = await ModesControllerTestsHelper.GetAllModesAsync(UserType.LibraryAdmin, TestFactory.PlantWithAccess); Assert.AreEqual(_initialModesCount + 1, modes.Count); var mode = modes.SingleOrDefault(m => m.Id == id); Assert.IsNotNull(mode); Assert.AreEqual(title, mode.Title); }
public async Task CreateMode_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing() => await ModesControllerTestsHelper.CreateModeAsync( UserType.Preserver, TestFactory.PlantWithAccess, "Mode1", HttpStatusCode.Forbidden);
public async Task CreateMode_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant() => await ModesControllerTestsHelper.CreateModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithoutAccess, "Mode1", HttpStatusCode.Forbidden);
public async Task CreateMode_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant() => await ModesControllerTestsHelper.CreateModeAsync( UserType.LibraryAdmin, TestFactory.UnknownPlant, "Mode1", HttpStatusCode.BadRequest, "is not a valid plant");
public async Task CreateMode_AsAnonymous_ShouldReturnUnauthorized() => await ModesControllerTestsHelper.CreateModeAsync( UserType.Anonymous, TestFactory.UnknownPlant, "Mode1", HttpStatusCode.Unauthorized);