private async Task <StepDetailsDto> GetStepDetailsAsync(int journeyId, int stepId) { var journey = await JourneysControllerTestsHelper.GetJourneyAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, journeyId); return(journey.Steps.SingleOrDefault(s => s.Id == stepId)); }
public async Task GetJourney_AsAdmin_ShouldGetJourneyWithStep() { // Act var journey = await JourneysControllerTestsHelper.GetJourneyAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, TwoStepJourneyWithTagsIdUnderTest); // Assert Assert.IsNotNull(journey); Assert.IsNotNull(journey.Steps); Assert.AreNotEqual(0, journey.Steps.Count()); var step = journey.Steps.SingleOrDefault(s => s.Id == FirstStepInJourneyWithTagsIdUnderTest); Assert.IsNotNull(step); }
public async Task CreateJourney_AsAdmin_ShouldCreateJourney() { // Arrange var title = Guid.NewGuid().ToString(); // Act var journeyId = await JourneysControllerTestsHelper.CreateJourneyAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, title); // Assert var journey = await JourneysControllerTestsHelper.GetJourneyAsync( UserType.LibraryAdmin, TestFactory.PlantWithAccess, journeyId); Assert.IsNotNull(journey); Assert.AreEqual(title, journey.Title); }
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); }
public async Task GetJourney_AsPreserver_ShouldReturnForbidden_WhenPermissionMissing() => await JourneysControllerTestsHelper.GetJourneyAsync( UserType.Preserver, TestFactory.PlantWithAccess, 9999, HttpStatusCode.Forbidden);
public async Task GetJourney_AsAdmin_ShouldReturnForbidden_WhenNoAccessToPlant() => await JourneysControllerTestsHelper.GetJourneyAsync( UserType.LibraryAdmin, TestFactory.PlantWithoutAccess, 9999, HttpStatusCode.Forbidden);
public async Task GetJourney_AsAdmin_ShouldReturnBadRequest_WhenUnknownPlant() => await JourneysControllerTestsHelper.GetJourneyAsync( UserType.LibraryAdmin, TestFactory.UnknownPlant, 9999, HttpStatusCode.BadRequest, "is not a valid plant");
public async Task GetJourney_AsAnonymous_ShouldReturnUnauthorized() => await JourneysControllerTestsHelper.GetJourneyAsync( UserType.Anonymous, TestFactory.UnknownPlant, 9999, HttpStatusCode.Unauthorized);