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 TestInitialize() { var modes = await ModesControllerTestsHelper.GetAllModesAsync(UserType.LibraryAdmin, TestFactory.PlantWithAccess); _initialModesCount = modes.Count; _modeIdUnderTest = TestFactory.Instance.SeededData[KnownPlantData.PlantA].OtherModeId; }
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 GetAllModes_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing() => await ModesControllerTestsHelper.GetAllModesAsync( UserType.Preserver, TestFactory.PlantWithAccess, HttpStatusCode.Forbidden);
public async Task GetAllModes_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant() => await ModesControllerTestsHelper.GetAllModesAsync( UserType.LibraryAdmin, TestFactory.PlantWithoutAccess, HttpStatusCode.Forbidden);
public async Task GetAllModes_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant() => await ModesControllerTestsHelper.GetAllModesAsync( UserType.LibraryAdmin, TestFactory.UnknownPlant, HttpStatusCode.BadRequest, "is not a valid plant");
public async Task GetAllModes_AsAnonymous_ShouldReturnUnauthorized() => await ModesControllerTestsHelper.GetAllModesAsync( UserType.Anonymous, TestFactory.UnknownPlant, HttpStatusCode.Unauthorized);