Exemple #1
0
 public async Task UpdateMode_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing()
 => await ModesControllerTestsHelper.UpdateModeAsync(
     UserType.Preserver, TestFactory.PlantWithAccess,
     9999,
     "Mode1",
     TestFactory.AValidRowVersion,
     HttpStatusCode.Forbidden);
Exemple #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));
        }
Exemple #3
0
 public async Task UnvoidMode_AsHacker_ShouldReturnBadRequest_WhenUnknownPlant()
 => await ModesControllerTestsHelper.UnvoidModeAsync(
     UserType.Hacker, TestFactory.UnknownPlant,
     9999,
     TestFactory.AValidRowVersion,
     HttpStatusCode.BadRequest,
     "is not a valid plant");
Exemple #4
0
 public async Task DeleteMode_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant()
 => await ModesControllerTestsHelper.DeleteModeAsync(
     UserType.LibraryAdmin, TestFactory.UnknownPlant,
     9999,
     TestFactory.AValidRowVersion,
     HttpStatusCode.BadRequest,
     "is not a valid plant");
Exemple #5
0
 public async Task UpdateMode_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant()
 => await ModesControllerTestsHelper.UpdateModeAsync(
     UserType.LibraryAdmin, TestFactory.PlantWithoutAccess,
     9999,
     "Mode1",
     TestFactory.AValidRowVersion,
     HttpStatusCode.Forbidden);
Exemple #6
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);
        }
Exemple #7
0
 public async Task UpdateMode_AsAnonymous_ShouldReturnUnauthorized()
 => await ModesControllerTestsHelper.UpdateModeAsync(
     UserType.Anonymous, TestFactory.UnknownPlant,
     9999,
     "Mode1",
     TestFactory.AValidRowVersion,
     HttpStatusCode.Unauthorized);
Exemple #8
0
        public async Task TestInitialize()
        {
            var modes = await ModesControllerTestsHelper.GetAllModesAsync(UserType.LibraryAdmin, TestFactory.PlantWithAccess);

            _initialModesCount = modes.Count;

            _modeIdUnderTest = TestFactory.Instance.SeededData[KnownPlantData.PlantA].OtherModeId;
        }
Exemple #9
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);
        }
Exemple #10
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);
        }
Exemple #11
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);
        }
Exemple #12
0
 public async Task GetMode_AsAnonymous_ShouldReturnUnauthorized()
 => await ModesControllerTestsHelper.GetModeAsync(
     UserType.Anonymous, TestFactory.UnknownPlant,
     9999,
     HttpStatusCode.Unauthorized);
Exemple #13
0
 public async Task GetAllModes_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing()
 => await ModesControllerTestsHelper.GetAllModesAsync(
     UserType.Preserver, TestFactory.PlantWithAccess,
     HttpStatusCode.Forbidden);
Exemple #14
0
 public async Task DeleteMode_AsHacker_ShouldReturnForbidden_WhenNoAccessToPlant()
 => await ModesControllerTestsHelper.DeleteModeAsync(
     UserType.Hacker, TestFactory.PlantWithoutAccess,
     9999,
     TestFactory.AValidRowVersion,
     HttpStatusCode.Forbidden);
Exemple #15
0
 public async Task GetAllModes_AsHacker_ShouldReturnForbidden_WhenNoAccessToPlant()
 => await ModesControllerTestsHelper.GetAllModesAsync(
     UserType.Hacker, TestFactory.PlantWithoutAccess,
     HttpStatusCode.Forbidden);
Exemple #16
0
 public async Task CreateMode_AsPlanner_ShouldReturnForbidden_WhenPermissionMissing()
 => await ModesControllerTestsHelper.CreateModeAsync(
     UserType.Planner, TestFactory.PlantWithAccess,
     "Mode1",
     HttpStatusCode.Forbidden);
Exemple #17
0
 public async Task CreateMode_AsHacker_ShouldReturnBadRequest_WhenUnknownPlant()
 => await ModesControllerTestsHelper.CreateModeAsync(
     UserType.Hacker, TestFactory.UnknownPlant,
     "Mode1",
     HttpStatusCode.BadRequest,
     "is not a valid plant");
Exemple #18
0
 public async Task GetMode_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant()
 => await ModesControllerTestsHelper.GetModeAsync(
     UserType.LibraryAdmin, TestFactory.PlantWithoutAccess,
     9999,
     HttpStatusCode.Forbidden);
Exemple #19
0
 public async Task GetMode_AsAdmin_ShouldReturnNotFound()
 => await ModesControllerTestsHelper.GetModeAsync(
     UserType.LibraryAdmin, TestFactory.PlantWithAccess,
     9999,
     HttpStatusCode.NotFound);
Exemple #20
0
 public async Task GetAllModes_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant()
 => await ModesControllerTestsHelper.GetAllModesAsync(
     UserType.LibraryAdmin, TestFactory.UnknownPlant,
     HttpStatusCode.BadRequest,
     "is not a valid plant");