public async Task UpdateStep_AsAdmin_ShouldUpdateStepAndRowVersion()
        {
            // Arrange
            var journeyIdUnderTest = TwoStepJourneyWithTagsIdUnderTest;
            var stepIdUnderTest    = FirstStepInJourneyWithTagsIdUnderTest;
            var step = await GetStepDetailsAsync(journeyIdUnderTest, stepIdUnderTest);

            var currentRowVersion = step.RowVersion;
            var newTitle          = Guid.NewGuid().ToString();

            // Act
            var newRowVersion = await JourneysControllerTestsHelper.UpdateStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                step.Id,
                newTitle,
                OtherModeIdUnderTest,
                KnownTestData.ResponsibleCode,
                currentRowVersion);

            // Assert
            AssertRowVersionChange(currentRowVersion, newRowVersion);
            step = await GetStepDetailsAsync(journeyIdUnderTest, stepIdUnderTest);

            Assert.AreEqual(newTitle, step.Title);
        }
Exemplo n.º 2
0
 public async Task UpdateStep_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing()
 => await JourneysControllerTestsHelper.UpdateStepAsync(
     UserType.Preserver, TestFactory.PlantWithAccess,
     9999,
     8888,
     "Step1",
     7777,
     "RC",
     TestFactory.AValidRowVersion,
     HttpStatusCode.Forbidden);
Exemplo n.º 3
0
 public async Task UpdateStep_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant()
 => await JourneysControllerTestsHelper.UpdateStepAsync(
     UserType.LibraryAdmin, TestFactory.PlantWithoutAccess,
     9999,
     8888,
     "Step1",
     7777,
     "RC",
     TestFactory.AValidRowVersion,
     HttpStatusCode.Forbidden);
Exemplo n.º 4
0
 public async Task UpdateStep_AsAnonymous_ShouldReturnUnauthorized()
 => await JourneysControllerTestsHelper.UpdateStepAsync(
     UserType.Anonymous, TestFactory.UnknownPlant,
     9999,
     8888,
     "Step1",
     7777,
     "RC",
     TestFactory.AValidRowVersion,
     HttpStatusCode.Unauthorized);
Exemplo n.º 5
0
 public async Task UpdateStep_AsAdmin_ShouldReturnBadRequest_WhenUnknownJourneyOrStepId()
 => await JourneysControllerTestsHelper.UpdateStepAsync(
     UserType.LibraryAdmin, TestFactory.PlantWithAccess,
     JourneyNotInUseIdUnderTest,
     FirstStepInJourneyWithTagsIdUnderTest,     // step in other Journey
     Guid.NewGuid().ToString(),
     OtherModeIdUnderTest,
     KnownTestData.ResponsibleCode,
     TestFactory.AValidRowVersion,
     HttpStatusCode.BadRequest,
     "Journey and/or step doesn't exist!");
Exemplo n.º 6
0
 public async Task UpdateStep_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant()
 => await JourneysControllerTestsHelper.UpdateStepAsync(
     UserType.LibraryAdmin, TestFactory.UnknownPlant,
     9999,
     8888,
     "Step1",
     7777,
     "RC",
     TestFactory.AValidRowVersion,
     HttpStatusCode.BadRequest,
     "is not a valid plant");
        public async Task UpdateStep_AsAdmin_ShouldUpdateSecondStepToBeSupplier()
        {
            // Arrange
            var journeyIdUnderTest = await JourneysControllerTestsHelper.CreateJourneyAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                Guid.NewGuid().ToString());

            var firstStepId = await JourneysControllerTestsHelper.CreateStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                Guid.NewGuid().ToString(),
                SupModeAIdUnderTest,
                KnownTestData.ResponsibleCode);

            var secondStepId = await JourneysControllerTestsHelper.CreateStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                Guid.NewGuid().ToString(),
                OtherModeIdUnderTest,
                KnownTestData.ResponsibleCode);

            var secondStep = await GetStepDetailsAsync(journeyIdUnderTest, secondStepId);

            Assert.IsFalse(secondStep.Mode.ForSupplier);
            var currentRowVersion = secondStep.RowVersion;

            // Act
            var newRowVersion = await JourneysControllerTestsHelper.UpdateStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                secondStep.Id,
                secondStep.Title,
                SupModeBIdUnderTest,
                secondStep.Responsible.Code,
                currentRowVersion);

            // Assert
            AssertRowVersionChange(currentRowVersion, newRowVersion);
            await AssertStepIsForSupplier(journeyIdUnderTest, firstStepId);
            await AssertStepIsForSupplier(journeyIdUnderTest, secondStep.Id);
        }