Пример #1
0
        public void Return301()
        {
            var result = new RedirectResourceResult("//localhost{?a}{&b}");

            var providerMock = new Mock <IFrameworkProvider>();
            var contextMock  = new Mock <IResourceResultContext>();

            contextMock.Setup(c => c.FrameworkProvider).Returns(providerMock.Object);

            result.Execute(contextMock.Object);

            providerMock.Verify(p => p.SetHttpResponseStatusCode(301));
        }
Пример #2
0
        public void ResolveTemplateParameters()
        {
            var expected = "expected";
            var data     = new Dictionary <string, object> {
                { "a", expected }
            };

            var result = new RedirectResourceResult("//localhost{?a}{&b}", data);

            var providerMock = new Mock <IFrameworkProvider>();
            var contextMock  = new Mock <IResourceResultContext>();

            contextMock.Setup(c => c.FrameworkProvider).Returns(providerMock.Object);

            result.Execute(contextMock.Object);

            providerMock.Verify(p => p.SetHttpResponseHeader("Location", It.Is <string>(uri => uri.Contains(expected) && !uri.Contains("b"))));
        }