public async Task UpdateMode_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing() => await ModesControllerTestsHelper.UpdateModeAsync( UserType.Preserver, TestFactory.PlantWithAccess, 9999, "Mode1", TestFactory.AValidRowVersion, HttpStatusCode.Forbidden);
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 UnvoidMode_AsHacker_ShouldReturnBadRequest_WhenUnknownPlant() => await ModesControllerTestsHelper.UnvoidModeAsync( UserType.Hacker, TestFactory.UnknownPlant, 9999, TestFactory.AValidRowVersion, HttpStatusCode.BadRequest, "is not a valid plant");
public async Task DeleteMode_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant() => await ModesControllerTestsHelper.DeleteModeAsync( UserType.LibraryAdmin, TestFactory.UnknownPlant, 9999, TestFactory.AValidRowVersion, HttpStatusCode.BadRequest, "is not a valid plant");
public async Task UpdateMode_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant() => await ModesControllerTestsHelper.UpdateModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithoutAccess, 9999, "Mode1", TestFactory.AValidRowVersion, HttpStatusCode.Forbidden);
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 UpdateMode_AsAnonymous_ShouldReturnUnauthorized() => await ModesControllerTestsHelper.UpdateModeAsync( UserType.Anonymous, TestFactory.UnknownPlant, 9999, "Mode1", TestFactory.AValidRowVersion, HttpStatusCode.Unauthorized);
public async Task TestInitialize() { var modes = await ModesControllerTestsHelper.GetAllModesAsync(UserType.LibraryAdmin, TestFactory.PlantWithAccess); _initialModesCount = modes.Count; _modeIdUnderTest = TestFactory.Instance.SeededData[KnownPlantData.PlantA].OtherModeId; }
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 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 GetMode_AsAnonymous_ShouldReturnUnauthorized() => await ModesControllerTestsHelper.GetModeAsync( UserType.Anonymous, TestFactory.UnknownPlant, 9999, HttpStatusCode.Unauthorized);
public async Task GetAllModes_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing() => await ModesControllerTestsHelper.GetAllModesAsync( UserType.Preserver, TestFactory.PlantWithAccess, HttpStatusCode.Forbidden);
public async Task DeleteMode_AsHacker_ShouldReturnForbidden_WhenNoAccessToPlant() => await ModesControllerTestsHelper.DeleteModeAsync( UserType.Hacker, TestFactory.PlantWithoutAccess, 9999, TestFactory.AValidRowVersion, HttpStatusCode.Forbidden);
public async Task GetAllModes_AsHacker_ShouldReturnForbidden_WhenNoAccessToPlant() => await ModesControllerTestsHelper.GetAllModesAsync( UserType.Hacker, TestFactory.PlantWithoutAccess, HttpStatusCode.Forbidden);
public async Task CreateMode_AsPlanner_ShouldReturnForbidden_WhenPermissionMissing() => await ModesControllerTestsHelper.CreateModeAsync( UserType.Planner, TestFactory.PlantWithAccess, "Mode1", HttpStatusCode.Forbidden);
public async Task CreateMode_AsHacker_ShouldReturnBadRequest_WhenUnknownPlant() => await ModesControllerTestsHelper.CreateModeAsync( UserType.Hacker, TestFactory.UnknownPlant, "Mode1", HttpStatusCode.BadRequest, "is not a valid plant");
public async Task GetMode_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant() => await ModesControllerTestsHelper.GetModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithoutAccess, 9999, HttpStatusCode.Forbidden);
public async Task GetMode_AsAdmin_ShouldReturnNotFound() => await ModesControllerTestsHelper.GetModeAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, 9999, HttpStatusCode.NotFound);
public async Task GetAllModes_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant() => await ModesControllerTestsHelper.GetAllModesAsync( UserType.LibraryAdmin, TestFactory.UnknownPlant, HttpStatusCode.BadRequest, "is not a valid plant");