示例#1
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));
        }
示例#2
0
        public async Task TestInitialize()
        {
            var modes = await ModesControllerTestsHelper.GetAllModesAsync(UserType.LibraryAdmin, TestFactory.PlantWithAccess);

            _initialModesCount = modes.Count;

            _modeIdUnderTest = TestFactory.Instance.SeededData[KnownPlantData.PlantA].OtherModeId;
        }
示例#3
0
        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);
        }
示例#4
0
 public async Task GetAllModes_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing()
 => await ModesControllerTestsHelper.GetAllModesAsync(
     UserType.Preserver, TestFactory.PlantWithAccess,
     HttpStatusCode.Forbidden);
示例#5
0
 public async Task GetAllModes_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant()
 => await ModesControllerTestsHelper.GetAllModesAsync(
     UserType.LibraryAdmin, TestFactory.PlantWithoutAccess,
     HttpStatusCode.Forbidden);
示例#6
0
 public async Task GetAllModes_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant()
 => await ModesControllerTestsHelper.GetAllModesAsync(
     UserType.LibraryAdmin, TestFactory.UnknownPlant,
     HttpStatusCode.BadRequest,
     "is not a valid plant");
示例#7
0
 public async Task GetAllModes_AsAnonymous_ShouldReturnUnauthorized()
 => await ModesControllerTestsHelper.GetAllModesAsync(
     UserType.Anonymous, TestFactory.UnknownPlant,
     HttpStatusCode.Unauthorized);