Example #1
0
        public void DoesNotShowContentWhenCurrentEnvironmentIsNotSpecified(
            string namesAttribute,
            string environmentName)
        {
            // Arrange
            var content = "content";
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList {
                { "names", namesAttribute }
            },
                content: content);
            var output             = MakeTagHelperOutput("environment");
            var hostingEnvironment = new Mock <IHostingEnvironment>();

            hostingEnvironment.SetupProperty(h => h.EnvironmentName);
            hostingEnvironment.Object.EnvironmentName = environmentName;

            // Act
            var helper = new EnvironmentTagHelper(hostingEnvironment.Object)
            {
                Names = namesAttribute
            };

            helper.Process(context, output);

            // Assert
            Assert.Null(output.TagName);
            Assert.Empty(output.PreContent.GetContent());
            Assert.True(output.Content.IsEmpty);
            Assert.Empty(output.PostContent.GetContent());
            Assert.True(output.IsContentModified);
        }
Example #2
0
        private void ShouldShowContent(string namesAttribute, string environmentName)
        {
            // Arrange
            var content = "content";
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList {
                { "names", namesAttribute }
            },
                content: content);
            var output             = MakeTagHelperOutput("environment");
            var hostingEnvironment = new Mock <IHostingEnvironment>();

            hostingEnvironment.SetupProperty(h => h.EnvironmentName);
            hostingEnvironment.Object.EnvironmentName = environmentName;

            // Act
            var helper = new EnvironmentTagHelper(hostingEnvironment.Object)
            {
                Names = namesAttribute
            };

            helper.Process(context, output);

            // Assert
            Assert.Null(output.TagName);
            Assert.False(output.IsContentModified);
        }
        public void ShouldShowContent_IncludeExcludeSpecified(string namesAttribute, string includeAttribute, string excludeAttribute)
        {
            // Arrange
            var content = "content";
            var context = MakeTagHelperContext(
                attributes: new TagHelperAttributeList {
                { "names", namesAttribute },
                { "include", includeAttribute },
                { "exclude", excludeAttribute },
            });
            var output             = MakeTagHelperOutput("environment", childContent: content);
            var hostingEnvironment = new Mock <IWebHostEnvironment>();

            hostingEnvironment.SetupProperty(h => h.EnvironmentName, "Development");

            // Act
            var helper = new EnvironmentTagHelper(hostingEnvironment.Object)
            {
                Names   = namesAttribute,
                Include = includeAttribute,
                Exclude = excludeAttribute,
            };

            helper.Process(context, output);

            // Assert
            Assert.Null(output.TagName);
            Assert.False(output.IsContentModified);
        }
Example #4
0
        public void DoesNotShowContentWhenCurrentEnvironmentIsNotSpecified(
            string namesAttribute,
            string environmentName)
        {
            // Arrange
            var content = "content";
            var context = MakeTagHelperContext(attributes: new TagHelperAttributeList { { "names", namesAttribute } });
            var output = MakeTagHelperOutput("environment", childContent: content);
            var hostingEnvironment = new Mock<IHostingEnvironment>();
            hostingEnvironment.SetupProperty(h => h.EnvironmentName);
            hostingEnvironment.Object.EnvironmentName = environmentName;

            // Act
            var helper = new EnvironmentTagHelper(hostingEnvironment.Object)
            {
                Names = namesAttribute
            };
            helper.Process(context, output);

            // Assert
            Assert.Null(output.TagName);
            Assert.Empty(output.PreContent.GetContent());
            Assert.True(output.Content.GetContent().Length == 0);
            Assert.Empty(output.PostContent.GetContent());
            Assert.True(output.IsContentModified);
        }
        private void ShouldShowContent(string namesAttribute, string environmentName)
        {
            // Arrange
            var content = "content";
            var context = MakeTagHelperContext(
                attributes: new Dictionary<string, object> { { "names", namesAttribute } },
                content: content);
            var output = MakeTagHelperOutput("environment");
            var hostingEnvironment = new Mock<IHostingEnvironment>();
            hostingEnvironment.SetupProperty(h => h.EnvironmentName);
            hostingEnvironment.Object.EnvironmentName = environmentName;

            // Act
            var helper = new EnvironmentTagHelper
            {
                HostingEnvironment = hostingEnvironment.Object,
                Names = namesAttribute
            };
            helper.Process(context, output);

            // Assert
            Assert.Null(output.TagName);
            Assert.False(output.IsContentModified);
        }