Beispiel #1
48
 public override int GetHashCode()
 {
     unchecked
     {
         return(Trivial.GetHashCode() ^ Minor.GetHashCode() ^ Major.GetHashCode() ^ Critical.GetHashCode() ^ Blocker.GetHashCode());
     }
 }
Beispiel #2
0
 public static void TestBadFeedbackSize(int size)
 {
     using (var t = new Trivial { BlockSize = 40 })
     {
         Assert.Throws<CryptographicException>(() => t.FeedbackSize = size);
     }
 }
        public void insertarTrivial(Trivial trivial, SqliteConnection db)
        {
            String cadenainsert = String.Format("Insert into {0} ({1},{2},{3},{4}) Values ({5},'{6}','{7}','{8}')",
                                                CONTRATO_DB.Trivial_DB.TABLE_NAME,
                                                CONTRATO_DB.Trivial_DB.ID,
                                                CONTRATO_DB.Trivial_DB.IDIOMA,
                                                CONTRATO_DB.Trivial_DB.VERSION,
                                                CONTRATO_DB.Trivial_DB.DESCRIPCION,
                                                trivial.Id,
                                                trivial.Idioma,
                                                trivial.Version,
                                                trivial.Descripcion);

            //  using (db = new SqliteConnection(PATH_DB))
            //  {
            //     db.Open();
            SqliteCommand insertTrivialCommand = new SqliteCommand(cadenainsert, db, miTransaccion);

            try
            {
                insertTrivialCommand.ExecuteNonQuery();
            }
            catch (SqliteException e)
            {
                throw e;
            }
        }
Beispiel #4
0
 public static void ClearCallsDispose()
 {
     Trivial s = new Trivial();
     Assert.False(s.IsDisposed);
     s.Clear();
     Assert.True(s.IsDisposed);
 }
Beispiel #5
0
        public static void TestIv()
        {
            using (Trivial s = new Trivial())
            {
                Assert.Throws <ArgumentNullException>(() => s.IV = null);

                {
                    // Testing automatic generation of Iv.

                    Trivial t = new Trivial();
                    t.BlockSize = 5 * 8;
                    byte[] generatedIv = t.IV;
                    Assert.Equal(generatedIv, Trivial.GeneratedIV);
                    Assert.False(Object.ReferenceEquals(generatedIv, Trivial.GeneratedIV));
                }

                // Testing IV property setter
                {
                    s.BlockSize = 5 * 8;
                    {
                        byte[] iv = GenerateRandom(5);
                        s.IV = iv;
                        byte[] copyOfIv = s.IV;
                        Assert.Equal(iv, copyOfIv);
                        Assert.False(Object.ReferenceEquals(iv, copyOfIv));
                    }

                    {
                        byte[] iv = GenerateRandom(6);
                        Assert.Throws <CryptographicException>(() => s.IV = iv);
                    }
                }
            }
            return;
        }
Beispiel #6
0
        public static void TestKeySize()
        {
            using (Trivial s = new Trivial())
            {
                Assert.Equal(0, s.KeySize);

                // Testing KeySize.
                int[] validKeySizes = { 40, 104, 152, 808, 809, 810, 816, 824, 832 };
                for (int keySize = -10; keySize < 200 * 8; keySize++)
                {
                    if (validKeySizes.Contains(keySize))
                    {
                        s.KeySize = keySize;
                        Assert.Equal(keySize, s.KeySize);
                    }
                    else
                    {
                        Assert.Throws <CryptographicException>(() => s.KeySize = keySize);
                    }
                }

                const int UnusualKeySize = 37;
                Assert.Throws <CryptographicException>(() => s.KeySize = UnusualKeySize);
                s.SetKeySize(37);
                Assert.Equal(UnusualKeySize, s.KeySize);

                // The value is illegal.
                Assert.Throws <CryptographicException>(() => s.KeySize = s.KeySize);
            }
        }
Beispiel #7
0
        public static void TestIv()
        {
            using (Trivial s = new Trivial())
            {
                Assert.Throws<ArgumentNullException>(() => s.IV = null);

                {
                    // Testing automatic generation of Iv.

                    Trivial t = new Trivial();
                    t.BlockSize = 5 * 8;
                    byte[] generatedIv = t.IV;
                    Assert.Equal(generatedIv, Trivial.GeneratedIV);
                    Assert.False(Object.ReferenceEquals(generatedIv, Trivial.GeneratedIV));
                }

                // Testing IV property setter
                {
                    s.BlockSize = 5 * 8;
                    {
                        byte[] iv = GenerateRandom(5);
                        s.IV = iv;
                        byte[] copyOfIv = s.IV;
                        Assert.Equal(iv, copyOfIv);
                        Assert.False(Object.ReferenceEquals(iv, copyOfIv));
                    }

                    {
                        byte[] iv = GenerateRandom(6);
                        Assert.Throws<CryptographicException>(() => s.IV = iv);
                    }
                }
            }
            return;
        }
Beispiel #8
0
        public static void TestKeySize()
        {
            using (Trivial s = new Trivial())
            {
                Assert.Equal(0, s.KeySize);

                // Testing KeySize.
                int[] validKeySizes = { 40, 104, 152, 808, 809, 810, 816, 824, 832 };
                for (int keySize = -10; keySize < 200 * 8; keySize++)
                {
                    if (validKeySizes.Contains(keySize))
                    {
                        s.KeySize = keySize;
                        Assert.Equal(keySize, s.KeySize);
                    }
                    else
                    {
                        Assert.Throws<CryptographicException>(() => s.KeySize = keySize);
                    }
                }

                const int UnusualKeySize = 37;
                Assert.Throws<CryptographicException>(() => s.KeySize = UnusualKeySize);
                s.SetKeySize(37);
                Assert.Equal(UnusualKeySize, s.KeySize);

                // The value is illegal.
                Assert.Throws<CryptographicException>(() => s.KeySize = s.KeySize);
            }
        }
Beispiel #9
0
        public static void TestKey()
        {
            using (Trivial s = new Trivial())
            {
                Assert.Equal(0, s.KeySize);

                Assert.Throws <ArgumentNullException>(() => s.Key = null);

                // Testing KeySize and Key setter.
                int[] validKeySizes = { 40, 104, 152, 808, 816, 824, 832 };
                for (int keySize = -10; keySize < 200 * 8; keySize++)
                {
                    if (validKeySizes.Contains(keySize))
                    {
                        s.KeySize = keySize;
                        Assert.Equal(keySize, s.KeySize);
                    }
                    else
                    {
                        Assert.Throws <CryptographicException>(() => s.KeySize = keySize);
                    }

                    if (keySize >= 0)
                    {
                        int    keySizeInBytes = keySize / 8;
                        byte[] key            = GenerateRandom(keySizeInBytes);
                        if (validKeySizes.Contains(keySizeInBytes * 8))
                        {
                            s.SetKeySize(-1);
                            s.Key = key;
                            byte[] copyOfKey = s.Key;
                            Assert.Equal(key, copyOfKey);
                            Assert.Equal(key.Length * 8, s.KeySize);
                            Assert.NotSame(key, copyOfKey);
                        }
                        else
                        {
                            Assert.Throws <CryptographicException>(() => s.Key = key);
                        }
                    }
                }

                // Test overflow
                try
                {
                    byte[] hugeKey = new byte[536870917]; // value chosen so that when multiplied by 8 (bits) it overflows to the value 40
                    if (PlatformDetection.IsFullFramework)
                    {
                        // This change should be ported to netfx
                        s.Key = hugeKey;
                    }
                    else
                    {
                        Assert.Throws <CryptographicException>(() => s.Key = hugeKey);
                    }
                }
                catch (OutOfMemoryException) { } // in case there isn't enough memory at test-time to allocate the large array
            }
        }
        public async Task descargarYGrabarTrivial()
        {
            SQLiteManejadora manejadoraSqlite = new SQLiteManejadora();

            trivial = await descargarTrivial();

            manejadoraSqlite.grabarTrivial(trivial);
        }
        private async void obtenerTrivial()
        {
            SQLiteManejadora manejadoraSQLite = new SQLiteManejadora();
            Trivial          trivial          = await listado.gettrivial();

            manejadoraSQLite.CreateDatabase(DB_PATH);
            manejadoraSQLite.Insert(trivial);
        }
Beispiel #12
0
 public static void GetCipherMode_NoValidation()
 {
     using (Trivial t = new Trivial())
     {
         t.SetCipherMode(24601);
         Assert.Equal(24601, (int)t.Mode);
     }
 }
Beispiel #13
0
 public static void KeySize_CurrentValue_NotGrandfathered()
 {
     using (Trivial t = new Trivial())
     {
         t.SetKeySize(525600);
         Assert.Throws <CryptographicException>(() => t.KeySize = t.KeySize);
     }
 }
Beispiel #14
0
 public static void GetPaddingMode_NoValidation()
 {
     using (Trivial t = new Trivial())
     {
         t.SetPaddingMode(24601);
         Assert.Equal(24601, (int)t.Padding);
     }
 }
Beispiel #15
0
 public static void GetCipherMode_NoValidation()
 {
     using (Trivial t = new Trivial())
     {
         t.SetCipherMode(24601);
         Assert.Equal(24601, (int)t.Mode);
     }
 }
Beispiel #16
0
 public static void TestFeedbackSizeDoesntValidateFieldValue()
 {
     using (var t = new Trivial())
     {
         t.SetFeedbackSize(9);
         Assert.Equal(9, t.FeedbackSize);
     }
 }
Beispiel #17
0
 public static void GetPaddingMode_NoValidation()
 {
     using (Trivial t = new Trivial())
     {
         t.SetPaddingMode(24601);
         Assert.Equal(24601, (int)t.Padding);
     }
 }
Beispiel #18
0
        public static void ClearCallsDispose()
        {
            Trivial s = new Trivial();

            Assert.False(s.IsDisposed);
            s.Clear();
            Assert.True(s.IsDisposed);
        }
Beispiel #19
0
 public static void TestFeedbackSizeDoesntValidateFieldValue()
 {
     using (var t = new Trivial())
     {
         t.SetFeedbackSize(9);
         Assert.Equal(9, t.FeedbackSize);
     }
 }
Beispiel #20
0
        public static void TestKey()
        {
            using (Trivial s = new Trivial())
            {
                Assert.Equal(0, s.KeySize);

                Assert.Throws<ArgumentNullException>(() => s.Key = null);

                {
                    // Testing automatic generation of Key.

                    Trivial t = new Trivial();
                    byte[] generatedKey = t.Key;
                    Assert.Equal(generatedKey, Trivial.GeneratedKey);
                    Assert.False(Object.ReferenceEquals(generatedKey, Trivial.GeneratedKey));
                }

                // Testing KeySize and Key setter.
                int[] validKeySizes = { 40, 104, 152, 808, 816, 824, 832 };
                for (int keySize = -10; keySize < 200 * 8; keySize++)
                {
                    if (validKeySizes.Contains(keySize))
                    {
                        s.KeySize = keySize;
                        Assert.Equal(keySize, s.KeySize);
                    }
                    else
                    {
                        Assert.Throws<CryptographicException>(() => s.KeySize = keySize);
                    }

                    if (keySize >= 0)
                    {
                        int keySizeInBytes = keySize / 8;
                        byte[] key = GenerateRandom(keySizeInBytes);
                        if (validKeySizes.Contains(keySizeInBytes * 8))
                        {
                            s.Key = key;
                            byte[] copyOfKey = s.Key;
                            Assert.Equal(key, copyOfKey);
                            Assert.False(Object.ReferenceEquals(key, copyOfKey));
                        }
                        else
                        {
                            Assert.Throws<CryptographicException>(() => s.Key = key);
                        }
                    }
                }

                // Test overflow
                try
                {
                    byte[] hugeKey = new byte[536870917]; // value chosen so that when multiplied by 8 (bits) it overflows to the value 40
                    Assert.Throws<CryptographicException>(() => s.Key = hugeKey);
                }
                catch (OutOfMemoryException) { } // in case there isn't enough memory at test-time to allocate the large array
            }
        }
Beispiel #21
0
        public static void TestKey()
        {
            using (Trivial s = new Trivial())
            {
                Assert.Equal(0, s.KeySize);

                Assert.Throws <ArgumentNullException>(() => s.Key = null);

                {
                    // Testing automatic generation of Key.

                    Trivial t            = new Trivial();
                    byte[]  generatedKey = t.Key;
                    Assert.Equal(generatedKey, Trivial.GeneratedKey);
                    Assert.False(Object.ReferenceEquals(generatedKey, Trivial.GeneratedKey));
                }

                // Testing KeySize and Key setter.
                int[] validKeySizes = { 40, 104, 152, 808, 816, 824, 832 };
                for (int keySize = -10; keySize < 200 * 8; keySize++)
                {
                    if (validKeySizes.Contains(keySize))
                    {
                        s.KeySize = keySize;
                        Assert.Equal(keySize, s.KeySize);
                    }
                    else
                    {
                        Assert.Throws <CryptographicException>(() => s.KeySize = keySize);
                    }

                    if (keySize >= 0)
                    {
                        int    keySizeInBytes = keySize / 8;
                        byte[] key            = GenerateRandom(keySizeInBytes);
                        if (validKeySizes.Contains(keySizeInBytes * 8))
                        {
                            s.Key = key;
                            byte[] copyOfKey = s.Key;
                            Assert.Equal(key, copyOfKey);
                            Assert.False(Object.ReferenceEquals(key, copyOfKey));
                        }
                        else
                        {
                            Assert.Throws <CryptographicException>(() => s.Key = key);
                        }
                    }
                }

                // Test overflow
                try
                {
                    byte[] hugeKey = new byte[536870917]; // value chosen so that when multiplied by 8 (bits) it overflows to the value 40
                    Assert.Throws <CryptographicException>(() => s.Key = hugeKey);
                }
                catch (OutOfMemoryException) { } // in case there isn't enough memory at test-time to allocate the large array
            }
        }
Beispiel #22
0
 public static void TestBadFeedbackSize(int size)
 {
     using (var t = new Trivial {
         BlockSize = 40
     })
     {
         Assert.Throws <CryptographicException>(() => t.FeedbackSize = size);
     }
 }
Beispiel #23
0
 public static void TestFeedbackSizeDoesntErrorWhenBlockSizeChanged()
 {
     using (var t = new Trivial { BlockSize = 104 })
     {
         t.FeedbackSize = 96;
         t.BlockSize = 40;
         Assert.Equal(96, t.FeedbackSize);
     }
 }
Beispiel #24
0
 public static void TestAutomaticKey()
 {
     using (Trivial t = new Trivial())
     {
         byte[] generatedKey = t.Key;
         Assert.Equal(generatedKey, Trivial.GeneratedKey);
         Assert.NotSame(generatedKey, Trivial.GeneratedKey);
     }
 }
Beispiel #25
0
 public static void TestAutomaticKey()
 {
     using (Trivial t = new Trivial())
     {
         byte[] generatedKey = t.Key;
         Assert.Equal(generatedKey, Trivial.GeneratedKey);
         Assert.NotSame(generatedKey, Trivial.GeneratedKey);
     }
 }
Beispiel #26
0
        public static void LegalKeySizes_CopiesData()
        {
            using (Trivial t = new Trivial())
            {
                KeySizes[] a = t.LegalKeySizes;
                KeySizes[] b = t.LegalKeySizes;

                Assert.NotSame(a, b);
            }
        }
Beispiel #27
0
 public void Insert(Trivial trivial)
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
     {
         conn.RunInTransaction(() =>
         {
             conn.Insert(objContact);
         });
     }
 }
Beispiel #28
0
 public static void TestAutomaticIv()
 {
     using (Trivial t = new Trivial())
     {
         t.BlockSize = 5 * 8;
         byte[] generatedIv = t.IV;
         Assert.Equal(generatedIv, Trivial.GeneratedIV);
         Assert.NotSame(generatedIv, Trivial.GeneratedIV);
     }
 }
Beispiel #29
0
 public static void TestFeedbackSizeDoesntErrorWhenBlockSizeChanged()
 {
     using (var t = new Trivial {
         BlockSize = 104
     })
     {
         t.FeedbackSize = 96;
         t.BlockSize    = 40;
         Assert.Equal(96, t.FeedbackSize);
     }
 }
Beispiel #30
0
    static void Main()
    {
        Console.WriteLine("Init Value: {0}", Trivial.MyValue);

        Trivial.MyValue = 10;
        Console.WriteLine("New Value : {0}", Trivial.MyValue);

        Trivial tr = new Trivial();

        tr.PrintValue();
    }
Beispiel #31
0
 public static void TestClearIsDispose()
 {
     // The obvious test would have been to .Clear() and then check that
     // next time we get a different autogenerated Key and IV -- but
     // occasionally by chance they would be the same.
     using (Trivial t = new Trivial())
     {
         var k = t.Key; // Initialize
         Assert.False(t.IsDisposed);
         t.Clear();
         Assert.True(t.IsDisposed);
     }
 }
Beispiel #32
0
 public static void TestClearIsDispose()
 {
     // The obvious test would have been to .Clear() and then check that
     // next time we get a different autogenerated Key and IV -- but 
     // occasionally by chance they would be the same.
     using (Trivial t = new Trivial())
     {
         var k = t.Key; // Initialize
         Assert.False(t.IsDisposed);
         t.Clear();
         Assert.True(t.IsDisposed);
     }
 }
Beispiel #33
0
        public static void KeySize_Key_LooseCoupling()
        {
            using (Trivial t = new Trivial())
            {
                t.GenerateKey();

                // Set the KeySizeValue field, then confirm that get_Key doesn't check it at all.
                const int UnusualKeySize = 51;
                t.SetKeySize(UnusualKeySize);
                Assert.Equal(UnusualKeySize, t.KeySize);

                byte[] key = t.Key;
                // It doesn't equal it in bytes
                Assert.NotEqual(UnusualKeySize, key.Length);
                // It doesn't equal it in bits
                Assert.NotEqual(UnusualKeySize, key.Length * 8);
            }
        }
Beispiel #34
0
        public static void KeySize_Key_LooseCoupling()
        {
            using (Trivial t = new Trivial())
            {
                t.GenerateKey();

                // Set the KeySizeValue field, then confirm that get_Key doesn't check it at all.
                const int UnusualKeySize = 51;
                t.SetKeySize(UnusualKeySize);
                Assert.Equal(UnusualKeySize, t.KeySize);

                byte[] key = t.Key;
                // It doesn't equal it in bytes
                Assert.NotEqual(UnusualKeySize, key.Length);
                // It doesn't equal it in bits
                Assert.NotEqual(UnusualKeySize, key.Length * 8);
            }
        }
        public void grabarTrivial(Trivial trivial)
        {
            using (db = new SqliteConnection(PATH_DB))
            {
                db.Open();

                miTransaccion = db.BeginTransaction();
                try
                {
                    insertarTrivial(trivial, db);

                    List <Regla> reglas = trivial.Reglas;
                    for (int i = 0; i < reglas.Count; i++)
                    {
                        Regla regla = reglas[i];
                        insertarRegla(regla, db);

                        for (int j = 0; j < regla.Preguntas.Count; j++)
                        {
                            Pregunta pregunta = regla.Preguntas[j];
                            insertarPregunta(pregunta, db);

                            List <Respuesta> respuestas = pregunta.Respuestas;
                            for (int k = 0; k < respuestas.Count; k++)
                            {
                                Respuesta respuesta = respuestas[k];
                                insertarRespuesta(respuesta, db);
                            }
                        }
                    }

                    miTransaccion.Commit();
                }
                catch (Exception)
                {
                    miTransaccion.Rollback();
                    throw;
                }
            }
        }
Beispiel #36
0
        public static void TestBlockSize()
        {
            using (Trivial s = new Trivial())
            {
                Assert.Equal(0, s.BlockSize);

                // Testing BlockSizeSetter.
                int[] validBlockSizes = { 40, 104, 152, 808, 816, 824, 832 };
                for (int blockSize = -10; blockSize < 200 * 8; blockSize++)
                {
                    if (validBlockSizes.Contains(blockSize))
                    {
                        s.BlockSize = blockSize;
                        Assert.Equal(blockSize, s.BlockSize);
                    }
                    else
                    {
                        Assert.Throws <CryptographicException>(() => s.BlockSize = blockSize);
                    }
                }
            }
            return;
        }
Beispiel #37
0
        public static void TestKeySize()
        {
            using (Trivial s = new Trivial())
            {
                Assert.Equal(0, s.KeySize);

                // Testing KeySize.
                int[] validKeySizes = { 40, 104, 152, 808, 816, 824, 832 };
                for (int keySize = -10; keySize < 200 * 8; keySize++)
                {
                    if (validKeySizes.Contains(keySize))
                    {
                        s.KeySize = keySize;
                        Assert.Equal(keySize, s.KeySize);
                    }
                    else
                    {
                        Assert.Throws<CryptographicException>(() => s.KeySize = keySize);
                    }
                }
            }
            return;
        }
Beispiel #38
0
        public static void TestKeySize()
        {
            using (Trivial s = new Trivial())
            {
                Assert.Equal(0, s.KeySize);

                // Testing KeySize.
                int[] validKeySizes = { 40, 104, 152, 808, 809, 810, 816, 824, 832 };
                for (int keySize = -10; keySize < 200 * 8; keySize++)
                {
                    if (validKeySizes.Contains(keySize))
                    {
                        s.KeySize = keySize;
                        Assert.Equal(keySize, s.KeySize);
                    }
                    else
                    {
                        Assert.Throws <CryptographicException>(() => s.KeySize = keySize);
                    }
                }
            }
            return;
        }
Beispiel #39
0
        public static void TestIv()
        {
            using (Trivial s = new Trivial())
            {
                Assert.Throws <ArgumentNullException>(() => s.IV = null);

                // Testing IV property setter
                {
                    s.BlockSize = 5 * 8;
                    {
                        byte[] iv = GenerateRandom(5);
                        s.IV = iv;
                        byte[] copyOfIv = s.IV;
                        Assert.Equal(iv, copyOfIv);
                        Assert.False(object.ReferenceEquals(iv, copyOfIv));
                    }

                    {
                        byte[] iv = GenerateRandom(6);
                        Assert.Throws <CryptographicException>(() => s.IV = iv);
                    }
                }
            }
        }
Beispiel #40
0
		public void Find()
		{
			ISession s = OpenSession();
			ITransaction txn = s.BeginTransaction();

			// some code commented out in h2.0.3

			Bar bar = new Bar();
			s.Save(bar);
			bar.BarString = "bar bar";
			bar.String = "xxx";
			Foo foo = new Foo();
			s.Save(foo);
			foo.String = "foo bar";
			s.Save(new Foo());
			s.Save(new Bar());

			IList list1 =
				s.CreateQuery("select foo from foo in class NHibernate.DomainModel.Foo where foo.String='foo bar'").List();
			Assert.AreEqual(1, list1.Count, "find size");
			Assert.AreSame(foo, list1[0], "find ==");

			IList list2 = s.CreateQuery("from foo in class NHibernate.DomainModel.Foo order by foo.String, foo.Date").List();
			Assert.AreEqual(4, list2.Count, "find size");
			list1 = s.CreateQuery("from foo in class NHibernate.DomainModel.Foo where foo.class='B'").List();
			Assert.AreEqual(2, list1.Count, "class special property");
			list1 =
				s.CreateQuery("from foo in class NHibernate.DomainModel.Foo where foo.class=NHibernate.DomainModel.Bar").List();
			Assert.AreEqual(2, list1.Count, "class special property");
			list1 = s.CreateQuery("from foo in class NHibernate.DomainModel.Foo where foo.class=Bar").List();
			list2 =
				s.CreateQuery(
					"select bar from bar in class NHibernate.DomainModel.Bar, foo in class NHibernate.DomainModel.Foo where bar.String = foo.String and not bar=foo")
					.List();

			Assert.AreEqual(2, list1.Count, "class special property");
			Assert.AreEqual(1, list2.Count, "select from a subclass");

			Trivial t = new Trivial();
			s.Save(t);
			txn.Commit();
			s.Close();

			s = OpenSession();
			txn = s.BeginTransaction();
			list1 = s.CreateQuery("from foo in class NHibernate.DomainModel.Foo where foo.String='foo bar'").List();
			Assert.AreEqual(1, list1.Count, "find count");
			// There is an interbase bug that causes null integers to return as 0, also numeric precision is <=15 -h2.0.3 comment
			Assert.IsTrue(((Foo) list1[0]).EqualsFoo(foo), "find equals");
			list2 = s.CreateQuery("select foo from foo in class NHibernate.DomainModel.Foo").List();
			Assert.AreEqual(5, list2.Count, "find count");
			IList list3 = s.CreateQuery("from bar in class NHibernate.DomainModel.Bar where bar.BarString='bar bar'").List();
			Assert.AreEqual(1, list3.Count, "find count");
			Assert.IsTrue(list2.Contains(list1[0]) && list2.Contains(list2[0]), "find same instance");
			Assert.AreEqual(1, s.CreateQuery("from t in class NHibernate.DomainModel.Trivial").List().Count);
			s.Delete("from t in class NHibernate.DomainModel.Trivial");

			list2 =
				s.CreateQuery("from foo in class NHibernate.DomainModel.Foo where foo.Date = ?").SetDateTime(0,
				                                                                                             new DateTime(1970, 01,
				                                                                                                          01)).List();
			Assert.AreEqual(4, list2.Count, "find by date");
			IEnumerator enumer = list2.GetEnumerator();
			while (enumer.MoveNext())
			{
				s.Delete(enumer.Current);
			}

			list2 = s.CreateQuery("from foo in class NHibernate.DomainModel.Foo").List();
			Assert.AreEqual(0, list2.Count, "find deleted");
			txn.Commit();
			s.Close();
		}
Beispiel #41
0
 public static void KeySize_CurrentValue_NotGrandfathered()
 {
     using (Trivial t = new Trivial())
     {
         t.SetKeySize(525600);
         Assert.Throws<CryptographicException>(() => t.KeySize = t.KeySize);
     }
 }
Beispiel #42
0
 public static void TestAutomaticIv()
 {
     using (Trivial t = new Trivial())
     {
         t.BlockSize = 5 * 8;
         byte[] generatedIv = t.IV;
         Assert.Equal(generatedIv, Trivial.GeneratedIV);
         Assert.NotSame(generatedIv, Trivial.GeneratedIV);
     }
 }
Beispiel #43
0
        public static void TestBlockSize()
        {
            using (Trivial s = new Trivial())
            {
                Assert.Equal(0, s.BlockSize);

                // Testing BlockSizeSetter.
                int[] validBlockSizes = { 40, 104, 152, 808, 816, 824, 832 };
                for (int blockSize = -10; blockSize < 200 * 8; blockSize++)
                {
                    if (validBlockSizes.Contains(blockSize))
                    {
                        s.BlockSize = blockSize;
                        Assert.Equal(blockSize, s.BlockSize);
                    }
                    else
                    {
                        Assert.Throws<CryptographicException>(() => s.BlockSize = blockSize);
                    }
                }
            }
            return;
        }
Beispiel #44
0
        public static void LegalKeySizes_CopiesData()
        {
            using (Trivial t = new Trivial())
            {
                KeySizes[] a = t.LegalKeySizes;
                KeySizes[] b = t.LegalKeySizes;

                Assert.NotSame(a, b);
            }
        }