public void When_adding_a_keyword_multiple_times_it_should_return_it_only_once_in_header_value()
 {
     var list = new CspSourceList();
     list.AddKeyword(SourceListKeyword.Self);
     list.AddKeyword(SourceListKeyword.Self);
     list.AddKeyword(SourceListKeyword.Self);
     list.AddKeyword(SourceListKeyword.Self);
     list.ToDirectiveValue().Trim().ShouldEqual("'self'");
 }
        public void When_adding_a_keyword_multiple_times_it_should_return_it_only_once_in_header_value()
        {
            var list = new CspSourceList();

            list.AddKeyword(SourceListKeyword.Self);
            list.AddKeyword(SourceListKeyword.Self);
            list.AddKeyword(SourceListKeyword.Self);
            list.AddKeyword(SourceListKeyword.Self);
            list.ToDirectiveValue().Trim().ShouldEqual("'self'");
        }
        public void When_addin_mutliple_keywords_it_should_create_the_keywords_whiteSpace_separated()
        {
            var list = new CspSourceList();

            list.AddKeyword(SourceListKeyword.Self);
            list.AddKeyword(SourceListKeyword.UnsafeEval);
            list.AddKeyword(SourceListKeyword.Self);
            list.AddKeyword(SourceListKeyword.UnsafeInline);
            list.AddKeyword(SourceListKeyword.UnsafeRedirect);
            list.ToDirectiveValue().Trim().ShouldEqual("'self' 'unsafe-eval' 'unsafe-inline' 'unsafe-redirect'");
        }
        public void When_adding_a_keyword_it_should_create_the_correct_value_for_the_header()
        {
            var list = new CspSourceList();

            list.AddKeyword(SourceListKeyword.Self);
            list.ToDirectiveValue().Trim().ShouldEqual("'self'");
        }
        public void When_set_list_to_none_adding_a_keyWord_should_throw_an_invalidOperationException()
        {
            var list = new CspSourceList();

            list.SetToNone();
            Assert.Throws <InvalidOperationException>(() => list.AddKeyword(SourceListKeyword.Self));
        }
        public void When_adding_keyword_unsafeinline_it_should_create_the_correct_header_value()
        {
            var list = new CspSourceList();

            list.AddKeyword(SourceListKeyword.UnsafeInline);
            list.ToDirectiveValue().Trim().ShouldEqual("'unsafe-inline'");
        }
        public void When_adding_scheme_host_and_keyword_it_should_create_correct_header_value()
        {
            var list = new CspSourceList();

            list.AddScheme("https");
            list.AddKeyword(SourceListKeyword.Self);
            list.AddHost("https://www.example.com/");
            list.ToDirectiveValue().Trim().ShouldEqual("https:  https://www.example.com/  'self'");
        }
 public void When_adding_keyword_unsafeinline_it_should_create_the_correct_header_value()
 {
     var list = new CspSourceList();
     list.AddKeyword(SourceListKeyword.UnsafeInline);
     list.ToDirectiveValue().Trim().ShouldEqual("'unsafe-inline'");
 }
 public void When_adding_a_keyword_it_should_create_the_correct_value_for_the_header()
 {
     var list = new CspSourceList();
     list.AddKeyword(SourceListKeyword.Self);
     list.ToDirectiveValue().Trim().ShouldEqual("'self'");
 }
 public void When_set_list_to_none_adding_a_keyWord_should_throw_an_invalidOperationException()
 {
     var list = new CspSourceList();
     list.SetToNone();
     Assert.Throws<InvalidOperationException>(() => list.AddKeyword(SourceListKeyword.Self));
 }
 public void When_addin_mutliple_keywords_it_should_create_the_keywords_whiteSpace_separated()
 {
     var list = new CspSourceList();
     list.AddKeyword(SourceListKeyword.Self);
     list.AddKeyword(SourceListKeyword.UnsafeEval);
     list.AddKeyword(SourceListKeyword.Self);
     list.AddKeyword(SourceListKeyword.UnsafeInline);
     list.AddKeyword(SourceListKeyword.UnsafeRedirect);
     list.ToDirectiveValue().Trim().ShouldEqual("'self' 'unsafe-eval' 'unsafe-inline' 'unsafe-redirect'");
 }
 public void When_adding_scheme_host_and_keyword_it_should_create_correct_header_value()
 {
     var list = new CspSourceList();
     list.AddScheme("https");
     list.AddKeyword(SourceListKeyword.Self);
     list.AddHost("https://www.example.com/");
     list.ToDirectiveValue().Trim().ShouldEqual("https:  https://www.example.com/  'self'");
 }