public async Task GetRemove_ValidRequest_ReturnsExpectedContent() { // Arrange var provider = await TestData.CreateProvider(providerType : ProviderType.Apprenticeships); var venueId = (await TestData.CreateVenue(provider.ProviderId, venueName: "The Venue")).Id; var parentMptxInstance = MptxManager.CreateInstance(new ParentFlow()); var childMptxInstance = MptxManager.CreateInstance <FlowModel, IFlowModelCallback>( parentMptxInstance.InstanceId, FlowModel.Edit( provider.ProviderId, venueId, radius: 5, new[] { ApprenticeshipDeliveryMode.BlockRelease }), new Dictionary <string, object>() { { "ReturnUrl", "callback" } }); await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships); // Act var response = await HttpClient.GetAsync( $"apprenticeships/remove-classroom-location?ffiid={childMptxInstance.InstanceId}"); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); var doc = await response.GetDocument(); Assert.Equal("The Venue", doc.GetElementsByTagName("h2").First().TextContent); }
public async Task PostRemove_ValidRequest_UpdatesParentStateAndRedirects() { // Arrange var provider = await TestData.CreateProvider(providerType : ProviderType.Apprenticeships); var venueId = (await TestData.CreateVenue(provider.ProviderId)).Id; var parentMptxInstance = MptxManager.CreateInstance(new ParentFlow()); var childMptxInstance = MptxManager.CreateInstance <FlowModel, IFlowModelCallback>( parentMptxInstance.InstanceId, FlowModel.Edit( provider.ProviderId, venueId, radius: 5, new[] { ApprenticeshipDeliveryMode.BlockRelease }), new Dictionary <string, object>() { { "ReturnUrl", "callback" } }); await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships); var requestContent = new FormUrlEncodedContentBuilder().ToContent(); // Act var response = await HttpClient.PostAsync( $"apprenticeships/remove-classroom-location?ffiid={childMptxInstance.InstanceId}", requestContent); // Assert Assert.Equal(HttpStatusCode.Found, response.StatusCode); Assert.Equal("callback", response.Headers.Location.OriginalString); Assert.Null(parentMptxInstance.State.VenueId); Assert.Null(parentMptxInstance.State.Radius); Assert.Null(parentMptxInstance.State.DeliveryModes); }