public void GetCspSandboxConfigCloned_Configured_ClonesDirective()
        {
            var firstDirective = new CspSandboxDirectiveConfiguration
            {
                AllowForms       = true,
                AllowPointerLock = true,
                AllowPopups      = true
            };
            var firstConfig = new CspConfiguration(false)
            {
                SandboxDirective = firstDirective
            };
            var secondDirective = new CspSandboxDirectiveConfiguration()
            {
                AllowSameOrigin    = true,
                AllowScripts       = true,
                AllowTopNavigation = true,
                Enabled            = true
            };
            var secondConfig = new CspConfiguration(false)
            {
                SandboxDirective = secondDirective
            };
            var mapper = new CspConfigMapper();

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

            Assert.That(firstResult, Is.EqualTo(firstDirective).Using(new CspSandboxDirectiveConfigurationComparer()));
            Assert.That(secondResult, Is.EqualTo(secondDirective).Using(new CspSandboxDirectiveConfigurationComparer()));
        }
        public void GetCspSandboxConfigCloned_Configured_ClonesDirective()
        {
            var firstDirective = new CspSandboxDirectiveConfiguration
            {
                AllowForms           = true,
                AllowModals          = true,
                AllowOrientationLock = true,
                AllowPointerLock     = true,
                AllowPopups          = true
            };
            var firstConfig = new CspConfiguration(false)
            {
                SandboxDirective = firstDirective
            };
            var secondDirective = new CspSandboxDirectiveConfiguration()
            {
                AllowPopupsToEscapeSandbox = true,
                AllowPresentation          = true,
                AllowSameOrigin            = true,
                AllowScripts       = true,
                AllowTopNavigation = true,
                Enabled            = true
            };
            var secondConfig = new CspConfiguration(false)
            {
                SandboxDirective = secondDirective
            };
            var mapper = new CspConfigMapper();

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

            Assert.Equal(firstResult, firstDirective, new CspSandboxDirectiveConfigurationEqualityComparer());
            Assert.Equal(secondResult, secondDirective, new CspSandboxDirectiveConfigurationEqualityComparer());
        }
        public void GetCspSandboxConfigCloned_NoConfig_ReturnsNull()
        {
            var mapper = new CspConfigMapper();

            var clone = mapper.GetCspSandboxConfigCloned(null);

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

            var clone = mapper.GetCspSandboxConfigCloned(config);

            Assert.IsNull(clone);
        }