示例#1
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);
        }
示例#2
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));
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
 public async Task GetMode_AsAdmin_ShouldReturnNotFound()
 => await ModesControllerTestsHelper.GetModeAsync(
     UserType.LibraryAdmin, TestFactory.PlantWithAccess,
     9999,
     HttpStatusCode.NotFound);
示例#6
0
 public async Task GetMode_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant()
 => await ModesControllerTestsHelper.GetModeAsync(
     UserType.LibraryAdmin, TestFactory.PlantWithoutAccess,
     9999,
     HttpStatusCode.Forbidden);
示例#7
0
 public async Task GetMode_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant()
 => await ModesControllerTestsHelper.GetModeAsync(
     UserType.LibraryAdmin, TestFactory.UnknownPlant,
     9999,
     HttpStatusCode.BadRequest,
     "is not a valid plant");
示例#8
0
 public async Task GetMode_AsAnonymous_ShouldReturnUnauthorized()
 => await ModesControllerTestsHelper.GetModeAsync(
     UserType.Anonymous, TestFactory.UnknownPlant,
     9999,
     HttpStatusCode.Unauthorized);
示例#9
0
 public async Task GetMode_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing()
 => await ModesControllerTestsHelper.GetModeAsync(
     UserType.Preserver, TestFactory.PlantWithAccess,
     9999,
     HttpStatusCode.Forbidden);