コード例 #1
0
 public static void TestAddSameKeyTwice()
 {
     KnownKeys knownKeys = new KnownKeys();
     AesKey key = new AesKey();
     knownKeys.Add(key);
     knownKeys.Add(key);
     Assert.That(knownKeys.Keys.Count(), Is.EqualTo(1), "Only one key should be in the collection even if added twice.");
     Assert.That(knownKeys.Keys.First(), Is.EqualTo(key), "The first and only key should be the one just added.");
 }
コード例 #2
0
 public static void TestAddTwoNewKnownKeys()
 {
     KnownKeys knownKeys = new KnownKeys();
     AesKey key1 = new AesKey();
     knownKeys.Add(key1);
     AesKey key2 = new AesKey();
     knownKeys.Add(key2);
     Assert.That(knownKeys.Keys.First(), Is.EqualTo(key2), "The first key should be the last one added.");
     Assert.That(knownKeys.Keys.Last(), Is.EqualTo(key1), "The last key should be the first one added.");
 }
コード例 #3
0
 public static void TestAddNewKnownKey()
 {
     KnownKeys knownKeys = new KnownKeys();
     AesKey key = new AesKey();
     knownKeys.Add(key);
     Assert.That(knownKeys.Keys.First(), Is.EqualTo(key), "The first and only key should be the one just added.");
 }
コード例 #4
0
 public static void TestChangedEvent()
 {
     bool wasChanged = false;
     KnownKeys knownKeys = new KnownKeys();
     knownKeys.Changed += (object sender, EventArgs e) =>
     {
         wasChanged = true;
     };
     AesKey key1 = new AesKey();
     knownKeys.Add(key1);
     Assert.That(wasChanged, Is.True, "A new key should trigger the Changed event.");
     wasChanged = false;
     knownKeys.Add(key1);
     Assert.That(wasChanged, Is.False, "Re-adding an existing key should not trigger the Changed event.");
 }
コード例 #5
0
        public static void TestSettingNullDefaultEncryptionKey()
        {
            KnownKeys knownKeys = new KnownKeys();
            AesKey key1 = new AesKey();
            knownKeys.Add(key1);
            AesKey key2 = new AesKey();
            knownKeys.DefaultEncryptionKey = key2;

            Assert.That(knownKeys.Keys.Count(), Is.EqualTo(2), "Setting the DefaultEncryptionKey should also add it as a known key.");

            knownKeys.DefaultEncryptionKey = null;
            Assert.That(knownKeys.Keys.Count(), Is.EqualTo(2), "Setting the DefaultEncryptionKey to null should not affect the known keys.");
        }
コード例 #6
0
        public static void TestClear()
        {
            KnownKeys knownKeys = new KnownKeys();
            AesKey key1 = new AesKey();
            knownKeys.Add(key1);
            AesKey key2 = new AesKey();
            knownKeys.Add(key2);
            Assert.That(knownKeys.Keys.Count(), Is.EqualTo(2), "There should be two keys in the collection.");

            knownKeys.Clear();
            Assert.That(knownKeys.Keys.Count(), Is.EqualTo(0), "There should be zero keys in the collection after Clear().");
        }