public void GetCspPluginTypesConfigCloned_Configured_ClonesDirective()
        {
            var firstDirective = new CspPluginTypesDirectiveConfiguration()
            {
                Enabled    = false,
                MediaTypes = new[] { "application/pdf" }
            };
            var firstConfig = new CspConfiguration(false)
            {
                PluginTypesDirective = firstDirective
            };

            var secondDirective = new CspPluginTypesDirectiveConfiguration()
            {
                Enabled    = true,
                MediaTypes = new[] { "image/png", "application/pdf" }
            };
            var secondConfig = new CspConfiguration(false)
            {
                PluginTypesDirective = secondDirective
            };
            var mapper = new CspConfigMapper();

            var firstResult  = mapper.GetCspPluginTypesConfigCloned(firstConfig);
            var secondResult = mapper.GetCspPluginTypesConfigCloned(secondConfig);

            Assert.That(firstResult, Is.EqualTo(firstDirective).Using(new CspPluginTypesDirectiveConfigurationComparer()));
            Assert.That(secondResult, Is.EqualTo(secondDirective).Using(new CspPluginTypesDirectiveConfigurationComparer()));
        }
Example #2
0
        public void GetCspPluginTypesConfigCloned_NoConfig_ReturnsNull()
        {
            var mapper = new CspConfigMapper();

            var clone = mapper.GetCspPluginTypesConfigCloned(null);

            Assert.Null(clone);
        }
        public void GetCspPluginTypesConfigCloned_NoDirective_ReturnsNull()
        {
            var config = new CspConfiguration(false);
            var mapper = new CspConfigMapper();

            var clone = mapper.GetCspPluginTypesConfigCloned(config);

            Assert.IsNull(clone);
        }