Ejemplo n.º 1
0
        public AuthorizeTagHelperTests()
        {
            Task <TagHelperContent> content = Task.FromResult <TagHelperContent>(new DefaultTagHelperContent());

            output             = new TagHelperOutput("authorize", new TagHelperAttributeList(), (_, __) => content);
            helper             = new AuthorizeTagHelper(authorization = Substitute.For <IAuthorization>());
            helper.ViewContext = HtmlHelperFactory.CreateHtmlHelper().ViewContext;
        }
Ejemplo n.º 2
0
        public AuthorizeTagHelperTests()
        {
            TagHelperContent content = new DefaultTagHelperContent();

            output             = new TagHelperOutput("authorize", new TagHelperAttributeList(), (_, __) => Task.FromResult(content));
            context            = new TagHelperContext(new TagHelperAttributeList(), new Dictionary <Object, Object>(), "test");
            helper             = new AuthorizeTagHelper(authorization = Substitute.For <IAuthorization>());
            helper.ViewContext = HtmlHelperFactory.CreateHtmlHelper().ViewContext;
        }
        public void Process_NullAuthorizationProvider_RemovedWrappingTag()
        {
            helper = new AuthorizeTagHelper(null);

            output.PostContent.SetContent("PostContent");
            output.PostElement.SetContent("PostElement");
            output.PreContent.SetContent("PreContent");
            output.PreElement.SetContent("PreElement");
            output.Content.SetContent("Content");
            output.TagName = "TagName";

            helper.Process(null, output);

            Assert.Equal("PostContent", output.PostContent.GetContent());
            Assert.Equal("PostElement", output.PostElement.GetContent());
            Assert.Equal("PreContent", output.PreContent.GetContent());
            Assert.Equal("PreElement", output.PreElement.GetContent());
            Assert.Equal("Content", output.Content.GetContent());
            Assert.Null(output.TagName);
        }
Ejemplo n.º 4
0
        public void Process_NoAuthorization_RemovedWrappingTag()
        {
            helper             = new AuthorizeTagHelper(null);
            helper.ViewContext = HtmlHelperFactory.CreateHtmlHelper().ViewContext;

            output.PostContent.SetContent("PostContent");
            output.PostElement.SetContent("PostElement");
            output.PreContent.SetContent("PreContent");
            output.PreElement.SetContent("PreElement");
            output.Content.SetContent("Content");
            output.TagName = "TagName";

            helper.Process(null, output);

            Assert.Equal("PostContent", output.PostContent.GetContent());
            Assert.Equal("PostElement", output.PostElement.GetContent());
            Assert.Equal("PreContent", output.PreContent.GetContent());
            Assert.Equal("PreElement", output.PreElement.GetContent());
            Assert.Equal("Content", output.Content.GetContent());
            Assert.Null(output.TagName);
        }
 public AuthorizeTagHelperTests()
 {
     output             = new TagHelperOutput("authorize", new TagHelperAttributeList(), (useCachedResult, encoder) => null);
     helper             = new AuthorizeTagHelper(authorizationProvider = Substitute.For <IAuthorizationProvider>());
     helper.ViewContext = HtmlHelperFactory.CreateHtmlHelper().ViewContext;
 }