Пример #1
0
 public async Task VoidMode_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant()
 => await ModesControllerTestsHelper.VoidModeAsync(
     UserType.LibraryAdmin, TestFactory.UnknownPlant,
     9999,
     TestFactory.AValidRowVersion,
     HttpStatusCode.BadRequest,
     "is not a valid plant");
Пример #2
0
        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);
        }
Пример #3
0
        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));
        }
Пример #4
0
 public async Task VoidMode_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing()
 => await ModesControllerTestsHelper.VoidModeAsync(
     UserType.Preserver, TestFactory.PlantWithAccess,
     9999,
     TestFactory.AValidRowVersion,
     HttpStatusCode.Forbidden);
Пример #5
0
 public async Task VoidMode_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant()
 => await ModesControllerTestsHelper.VoidModeAsync(
     UserType.LibraryAdmin, TestFactory.PlantWithoutAccess,
     9999,
     TestFactory.AValidRowVersion,
     HttpStatusCode.Forbidden);
Пример #6
0
 public async Task VoidMode_AsAnonymous_ShouldReturnUnauthorized()
 => await ModesControllerTestsHelper.VoidModeAsync(
     UserType.Anonymous, TestFactory.UnknownPlant,
     9999,
     TestFactory.AValidRowVersion,
     HttpStatusCode.Unauthorized);