public void ThrowsExceptionWhenSubjectConfirmationHasEmptyMethod()
            {
                // Arrange
                var subjectConfirmation = new SubjectConfirmation {
                    Method = " "
                };
                var validator = new Saml20SubjectConfirmationValidator();

                // Act
                validator.ValidateSubjectConfirmation(subjectConfirmation, false);
            }
            public void ThrowsExceptionWhenSubjectConfirmationHasWrongMethod()
            {
                // Arrange
                var subjectConfirmation = new SubjectConfirmation {
                    Method = "malformed uri"
                };
                var validator = new Saml20SubjectConfirmationValidator();

                // Act
                validator.ValidateSubjectConfirmation(subjectConfirmation);
            }
            public void ThrowsExceptionWhenSubjectConfirmationHasWrongMethod()
            {
                // Arrange
                var subjectConfirmation = new SubjectConfirmation {
                    Method = "malformed uri"
                };
                var validator = new Saml20SubjectConfirmationValidator();

                // Act
                Assert.Throws <Saml20FormatException>(() => validator.ValidateSubjectConfirmation(subjectConfirmation),
                                                      "SubjectConfirmation element has Method attribute which is not a wellformed absolute uri.");
            }
            public void ThrowsExceptionWhenSubjectConfirmationHasEmptyMethod()
            {
                // Arrange
                var subjectConfirmation = new SubjectConfirmation {
                    Method = " "
                };
                var validator = new Saml20SubjectConfirmationValidator();

                // Act
                Assert.Throws <Saml20FormatException>(() => validator.ValidateSubjectConfirmation(subjectConfirmation),
                                                      "Method attribute of SubjectConfirmation MUST contain at least one non-whitespace character");
            }
            public void ThrowsExceptionWhenSubjectConfirmationDataDoesNotContainKeyInfo()
            {
                // Arrange
                var subjectConfirmation = new SubjectConfirmation
                {
                    Method = Saml20Constants.SubjectConfirmationMethods.HolderOfKey,
                    SubjectConfirmationData = new SubjectConfirmationData()
                };

                var validator = new Saml20SubjectConfirmationValidator();

                // Act
                validator.ValidateSubjectConfirmation(subjectConfirmation);
            }
            //ExpectedMessage = "Method attribute of SubjectConfirmation MUST contain at least one non-whitespace character")]
            public void ThrowsExceptionWhenSubjectConfirmationHasEmptyMethod()
            {
                // Arrange
                var subjectConfirmation = new SubjectConfirmation {
                    Method = " "
                };
                var validator = new Saml20SubjectConfirmationValidator();

                // Act
                Assert.Throws(typeof(Saml20FormatException), () =>
                {
                    validator.ValidateSubjectConfirmation(subjectConfirmation);
                });
            }
            public void ThrowsExceptionWhenSubjectConfirmationDataDoesNotContainKeyInfo()
            {
                // Arrange
                var subjectConfirmation = new SubjectConfirmation
                {
                    Method = Saml20Constants.SubjectConfirmationMethods.HolderOfKey,
                    SubjectConfirmationData = new SubjectConfirmationData()
                };

                var validator = new Saml20SubjectConfirmationValidator();

                // Act
                Assert.Throws <Saml20FormatException>(() => validator.ValidateSubjectConfirmation(subjectConfirmation),
                                                      "SubjectConfirmationData element MUST have at least one " + KeyInfo.ElementName + " subelement");
            }
            public void ValidatesSubjectConfirmationData_Method_HolderOfKey_Valid()
            {
                // Arrange
                var subjectConfirmation = new SubjectConfirmation
                {
                    Method = Saml20Constants.SubjectConfirmationMethods.HolderOfKey,
                    SubjectConfirmationData = new SubjectConfirmationData()
                };
                var doc  = new XmlDocument();
                var elem = doc.CreateElement("ds", "KeyInfo", Saml20Constants.Xmldsig);

                elem.AppendChild(doc.CreateElement("lalala"));

                subjectConfirmation.SubjectConfirmationData.AnyElements = new[] { elem };

                var validator = new Saml20SubjectConfirmationValidator();

                // Act
                validator.ValidateSubjectConfirmation(subjectConfirmation);
            }