コード例 #1
0
        public async Task CreateStep_AsAdmin_ShouldCreateTwoSupplierSteps()
        {
            // Arrange
            var journeyIdUnderTest = await JourneysControllerTestsHelper.CreateJourneyAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                Guid.NewGuid().ToString());

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

            // Act
            var stepBId = await JourneysControllerTestsHelper.CreateStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                Guid.NewGuid().ToString(),
                SupModeBIdUnderTest,
                KnownTestData.ResponsibleCode);

            // Assert
            await AssertStepIsForSupplier(journeyIdUnderTest, stepAId);
            await AssertStepIsForSupplier(journeyIdUnderTest, stepBId);
        }
コード例 #2
0
        public async Task UnvoidStep_AsAdmin_ShouldUnvoidStep_AndUpdateRowVersion()
        {
            // Arrange
            var journeyIdUnderTest = TwoStepJourneyWithTagsIdUnderTest;
            var stepId             = await JourneysControllerTestsHelper.CreateStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                Guid.NewGuid().ToString(),
                OtherModeIdUnderTest,
                KnownTestData.ResponsibleCode);

            var step = await GetStepDetailsAsync(journeyIdUnderTest, stepId);

            var currentRowVersion = await JourneysControllerTestsHelper.VoidStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                stepId,
                step.RowVersion);

            // Act
            var newRowVersion = await JourneysControllerTestsHelper.UnvoidStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                stepId,
                currentRowVersion);

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

            Assert.IsFalse(step.IsVoided);
        }
コード例 #3
0
        public async Task CreateStep_AsAdmin_ShouldCreateStep()
        {
            // Arrange
            var journeyIdUnderTest = await JourneysControllerTestsHelper.CreateJourneyAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                Guid.NewGuid().ToString());

            var title = Guid.NewGuid().ToString();

            // Act
            var stepId = await JourneysControllerTestsHelper.CreateStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                title,
                OtherModeIdUnderTest,
                KnownTestData.ResponsibleCode);

            // Assert
            var step = await GetStepDetailsAsync(journeyIdUnderTest, stepId);

            Assert.IsNotNull(step);
            Assert.AreEqual(title, step.Title);
        }
コード例 #4
0
        public async Task DeleteStep_AsAdmin_ShouldDeleteStep()
        {
            // Arrange
            var journeyIdUnderTest = JourneyNotInUseIdUnderTest;
            var stepId             = await JourneysControllerTestsHelper.CreateStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                Guid.NewGuid().ToString(),
                OtherModeIdUnderTest,
                KnownTestData.ResponsibleCode);

            var step = await GetStepDetailsAsync(journeyIdUnderTest, stepId);

            var currentRowVersion = await JourneysControllerTestsHelper.VoidStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                stepId,
                step.RowVersion);

            // Act
            await JourneysControllerTestsHelper.DeleteStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                stepId,
                currentRowVersion);

            // Assert
            step = await GetStepDetailsAsync(journeyIdUnderTest, stepId);

            Assert.IsNull(step);
        }
コード例 #5
0
 public async Task CreateStep_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing()
 => await JourneysControllerTestsHelper.CreateStepAsync(
     UserType.Preserver, TestFactory.PlantWithAccess,
     9999,
     "Step1",
     7777,
     "RC",
     HttpStatusCode.Forbidden);
コード例 #6
0
 public async Task CreateStep_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant()
 => await JourneysControllerTestsHelper.CreateStepAsync(
     UserType.LibraryAdmin, TestFactory.PlantWithoutAccess,
     9999,
     "Step1",
     7777,
     "RC",
     HttpStatusCode.Forbidden);
コード例 #7
0
 public async Task CreateStep_AsAnonymous_ShouldReturnUnauthorized()
 => await JourneysControllerTestsHelper.CreateStepAsync(
     UserType.Anonymous, TestFactory.UnknownPlant,
     9999,
     "Step1",
     7777,
     "RC",
     HttpStatusCode.Unauthorized);
コード例 #8
0
 public async Task CreateStep_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant()
 => await JourneysControllerTestsHelper.CreateStepAsync(
     UserType.LibraryAdmin, TestFactory.UnknownPlant,
     9999,
     "Step1",
     7777,
     "RC",
     HttpStatusCode.BadRequest,
     "is not a valid plant");
コード例 #9
0
        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);
        }
コード例 #10
0
        public async Task SwapSteps_AsAdmin_ShouldSwapSteps_AndUpdateRowVersions()
        {
            // Arrange
            var journeyIdUnderTest = await JourneysControllerTestsHelper.CreateJourneyAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                Guid.NewGuid().ToString());

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

            var originalFirstStep = await GetStepDetailsAsync(journeyIdUnderTest, stepId);

            Assert.IsTrue(originalFirstStep.Mode.ForSupplier);
            stepId = await JourneysControllerTestsHelper.CreateStepAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                Guid.NewGuid().ToString(),
                OtherModeIdUnderTest,
                KnownTestData.ResponsibleCode);

            var originalSecondStep = await GetStepDetailsAsync(journeyIdUnderTest, stepId);

            Assert.IsFalse(originalSecondStep.Mode.ForSupplier);

            // Act
            var newRowVersions = await JourneysControllerTestsHelper.SwapStepsAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest,
                new StepIdAndRowVersion
            {
                Id         = originalFirstStep.Id,
                RowVersion = originalFirstStep.RowVersion
            },
                new StepIdAndRowVersion
            {
                Id         = originalSecondStep.Id,
                RowVersion = originalSecondStep.RowVersion
            });

            // Assert
            var updatedJourney = await JourneysControllerTestsHelper.GetJourneyAsync(
                UserType.LibraryAdmin,
                TestFactory.PlantWithAccess,
                journeyIdUnderTest);

            var swappedStepA = updatedJourney.Steps.ElementAt(0);
            var swappedStepB = updatedJourney.Steps.ElementAt(1);

            Assert.AreEqual(originalSecondStep.Id, swappedStepA.Id);
            Assert.AreEqual(originalFirstStep.Id, swappedStepB.Id);
            Assert.IsFalse(swappedStepA.Mode.ForSupplier);
            Assert.IsTrue(swappedStepB.Mode.ForSupplier);

            var updatedFirstStepRowVersion  = updatedJourney.Steps.Single(s => s.Id == originalFirstStep.Id).RowVersion;
            var updatedSecondStepRowVersion = updatedJourney.Steps.Single(s => s.Id == originalSecondStep.Id).RowVersion;

            AssertRowVersionChange(originalFirstStep.RowVersion, updatedFirstStepRowVersion);
            AssertRowVersionChange(originalSecondStep.RowVersion, updatedSecondStepRowVersion);

            Assert.AreEqual(updatedFirstStepRowVersion, newRowVersions.Single(r => r.Id == originalFirstStep.Id).RowVersion);
            Assert.AreEqual(updatedSecondStepRowVersion, newRowVersions.Single(r => r.Id == originalSecondStep.Id).RowVersion);
        }