Esempio n. 1
0
        /// <summary>
        /// Creates a new option decriptor.
        /// </summary>
        /// <param name="option">Option to decscribe.</param>
        public OptionDescriptor(Option option)
        {
            if (option == null)
            throw new ArgumentException("option");

              this.text = option.Text;
              this.description = option.Description;
              this.url = option.Url;
        }
Esempio n. 2
0
        public void DecryptionTest()
        {
            Option option = new Option(new MultiLanguageString("Test"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty));

              Encrypted<Option> encryptedOption = new Encrypted<Option>(option, this.admin.OnlyPublicPart);

              Option other = encryptedOption.Decrypt(this.admin);

              Assert.IsTrue(other.ToBinary().Equal(option.ToBinary()));
        }
Esempio n. 3
0
        public void SecureDecryptionTest()
        {
            Option option = new Option(new MultiLanguageString("Test"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty));

              Secure<Option> encryptedOption = new Secure<Option>(option, this.admin.OnlyPublicPart, this.admin);

              Assert.IsTrue(encryptedOption.Verify(this.storage));

              Option other = encryptedOption.Value.Decrypt(this.admin);

              Assert.IsTrue(other.ToBinary().Equal(option.ToBinary()));
        }
Esempio n. 4
0
        public void SignedDontVerifyTest()
        {
            Option option = new Option(new MultiLanguageString("Test"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty));

              Signed<Option> signed = new Signed<Option>(option, this.admin);

              Assert.IsTrue(signed.VerifySimple());
              Assert.IsFalse(signed.Verify(this.storage, DateTime.Now.AddYears(5)));

              byte[] data = signed.ToBinary();
              data[data.Length / 8]++;
              Signed<Option> badSigned = Serializable.FromBinary<Signed<Option>>(data);

              Assert.IsFalse(badSigned.VerifySimple());
              Assert.IsFalse(badSigned.Verify(this.storage));
        }
Esempio n. 5
0
        public void NonDecryptionTest()
        {
            Option option = new Option(new MultiLanguageString("Test"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty));

              Encrypted<Option> encryptedOption = new Encrypted<Option>(option, this.admin.OnlyPublicPart);

              Option other = encryptedOption.Decrypt(this.eve);
        }
Esempio n. 6
0
        public void SecureNonDecryptionTest()
        {
            Option option = new Option(new MultiLanguageString("Test"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty));

              Secure<Option> encryptedOption = new Secure<Option>(option, this.admin.OnlyPublicPart, this.admin);

              Option other = encryptedOption.Value.Decrypt(this.eve);
        }
Esempio n. 7
0
        /// <summary>
        /// Add an option to this question.
        /// </summary>
        /// <param name="option">An selectable option.</param>
        public void AddOption(Option option)
        {
            if (option == null)
            throw new ArgumentNullException("option");

              this.options.Add(option);
        }
Esempio n. 8
0
        public void SignedVerifyTest()
        {
            Option option = new Option(new MultiLanguageString("Test"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty));

              Signed<Option> signed = new Signed<Option>(option, this.admin);

              Assert.IsTrue(signed.VerifySimple());
              Assert.IsTrue(signed.Verify(this.storage));

              Assert.IsTrue(signed.Value.ToBinary().Equal(option.ToBinary()));
        }