コード例 #1
0
        public void TestUnsuccessfulLoadFile()
        {
            IFactory   factory    = new TestingFactory(PASSWORD, IV, SALT);
            ActionList actionList = factory.GetActionList();
            IStorage   storage    = factory.GetStorage();

            AccountCollection collection = TestObjectBuilder.GetAccountCollection();
            string            serialized = actionList.DoActions(collection);

            storage.StoreData("test", serialized);

            string fromStorage = storage.RetrieveData("test");

            IFactory   factory2    = new TestingFactory("wrong", IV, SALT);
            ActionList actionList2 = factory2.GetActionList();

            try
            {
                AccountCollection deserialized = actionList2.ReverseActions <AccountCollection>(fromStorage);
            }
            catch (DeserializationException)
            {
                // Success
                return;
            }

            Assert.Fail("Exception should have been thrown because wrong password was used.");
        }
コード例 #2
0
        public void TestHashCodeInequality()
        {
            AccountCollection accountCol1 = TestObjectBuilder.GetAccountCollection();
            AccountCollection accountCol2 = TestObjectBuilder.GetAccountCollection2();

            Assert.AreNotEqual(accountCol1.GetHashCode(), accountCol2.GetHashCode());
        }
コード例 #3
0
        public void TestInequality()
        {
            AccountCollection accountCol1 = TestObjectBuilder.GetAccountCollection();
            AccountCollection accountCol2 = TestObjectBuilder.GetAccountCollection2();

            Assert.AreNotEqual(accountCol1, accountCol2);
        }
コード例 #4
0
        public void TestEqualityWithNoAccounts()
        {
            AccountCollection coll1 = TestObjectBuilder.GetAccountCollectionWithNoAccounts();
            AccountCollection coll2 = TestObjectBuilder.GetAccountCollection();

            try
            {
                bool isEqual = coll1.Equals(coll2);
                isEqual = coll2.Equals(coll1);
            }
            catch (Exception ex)
            {
                Assert.Fail("An exception was thrown when checking equality with a collection with no accounts:  " + ex.ToString());
            }
        }
コード例 #5
0
        public void TestSerializeAndDeserialize()
        {
            IFactory   factory    = new TestingFactory(PASSWORD, IV, SALT);
            ActionList actionList = factory.GetActionList();
            IStorage   storage    = factory.GetStorage();

            AccountCollection collection = TestObjectBuilder.GetAccountCollection();
            string            serialized = actionList.DoActions(collection);

            storage.StoreData("test", serialized);

            string            fromStorage  = storage.RetrieveData("test");
            AccountCollection deserialized = actionList.ReverseActions <AccountCollection>(fromStorage);

            Assert.AreEqual(collection, deserialized);
        }