예제 #1
0
        public void TryResolve_RandomIdGenerationSourceMissingQueryParameter_ReturnsFalse()
        {
            // Arrange
            var flowDescriptor = new FormFlowDescriptor(
                key: "key",
                stateType: typeof(MyState),
                idGenerationSource: IdGenerationSource.RandomId);

            var httpContext = new DefaultHttpContext();

            var routeData = new RouteData();

            // Act
            var created = FormFlowInstanceId.TryResolve(flowDescriptor, httpContext.Request, routeData, out var instanceId);

            // Assert
            Assert.False(created);
        }
예제 #2
0
        public void TryResolve_RandomIdGenerationSourceContainsQueryParameter_ReturnsTrue()
        {
            // Arrange
            var flowDescriptor = new FormFlowDescriptor(
                key: "key",
                stateType: typeof(MyState),
                idGenerationSource: IdGenerationSource.RandomId);

            var httpContext = new DefaultHttpContext();

            httpContext.Request.QueryString = new QueryString("?ffiid=some-id");

            var routeData = new RouteData();

            // Act
            var created = FormFlowInstanceId.TryResolve(flowDescriptor, httpContext.Request, routeData, out var instanceId);

            // Assert
            Assert.True(created);
            Assert.Equal("some-id", instanceId.ToString());
        }
예제 #3
0
        public void TryResolve_RouteValuesGenerationSourceMissingRouteParameter_ReturnsFalse()
        {
            // Arrange
            var flowDescriptor = new FormFlowDescriptor(
                key: "key",
                stateType: typeof(MyState),
                idGenerationSource: IdGenerationSource.RouteValues,
                idRouteParameterNames: new[] { "id1", "id2" });

            var httpContext = new DefaultHttpContext();

            var routeData = new RouteData(new RouteValueDictionary()
            {
                { "id1", "foo" }
            });

            // Act
            var created = FormFlowInstanceId.TryResolve(flowDescriptor, httpContext.Request, routeData, out var instanceId);

            // Assert
            Assert.False(created);
        }
예제 #4
0
        public void TryResolve_RouteValuesGenerationSourceContainsAllRouteParameters_ReturnsTrue()
        {
            // Arrange
            var flowDescriptor = new FormFlowDescriptor(
                key: "key",
                stateType: typeof(MyState),
                idGenerationSource: IdGenerationSource.RouteValues,
                idRouteParameterNames: new[] { "id1", "id2" });

            var httpContext = new DefaultHttpContext();

            var routeData = new RouteData(new RouteValueDictionary()
            {
                { "id1", "foo" },
                { "id2", "bar" }
            });

            // Act
            var created = FormFlowInstanceId.TryResolve(flowDescriptor, httpContext.Request, routeData, out var instanceId);

            // Assert
            Assert.True(created);
            Assert.Equal("key?id1=foo&id2=bar", instanceId.ToString());
        }