示例#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 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);
        }