Ejemplo n.º 1
0
        public void TestWriteUserKeysIntoDB()
        {
            if (File.Exists(FullTestFilePath))
            {
                File.Delete(FullTestFilePath);
            }
            var lSaveManagerFactory = PandoraSaveManagerFactory.GetSaveMangerFactory();
            var lSaveManager        = lSaveManagerFactory.GetNewPandoraSaveManager(SavePlace.SQLiteDisk);

            lSaveManager.Initialize(DebugPath, FTestFileName, FUsername, FEmail);

            //Random GUIDs to test
            var lUserPublic   = "b687d248edb346f5a1c77bdd9747035d";
            var lUserPrivate  = "8a01640af9bf437dafcc235967fab6fb";
            var lUser2Public  = "14eed08178ba4eb986a700d84ea193df";
            var lUser2Private = "630debc3a3d54daf8efed5eeb6adc25d";

            lSaveManager.WriteKeyValue("EXCHANGE_PUBLIC", lUserPublic, 1);
            lSaveManager.WriteKeyValue("EXCHANGE_PRIVATE", lUserPrivate, 1);
            lSaveManager.WriteKeyValue("EXCHANGE_PUBLIC", lUser2Public, 2);
            lSaveManager.WriteKeyValue("EXCHANGE_PRIVATE", lUser2Private, 2);

            //Two times to check that actually got replaced
            lSaveManager.WriteKeyValue("EXCHANGE_PUBLIC", lUserPublic, 1);
            lSaveManager.WriteKeyValue("EXCHANGE_PRIVATE", lUserPrivate, 1);
            lSaveManager.WriteKeyValue("EXCHANGE_PUBLIC", lUser2Public, 2);
            lSaveManager.WriteKeyValue("EXCHANGE_PRIVATE", lUser2Private, 2);

            Assert.AreEqual(lSaveManager.ReadKeyValue("EXCHANGE_PUBLIC", 1), lUserPublic);
            Assert.AreEqual(lSaveManager.ReadKeyValue("EXCHANGE_PRIVATE", 1), lUserPrivate);
            Assert.AreEqual(lSaveManager.ReadKeyValue("EXCHANGE_PUBLIC", 2), lUser2Public);
            Assert.AreEqual(lSaveManager.ReadKeyValue("EXCHANGE_PRIVATE", 2), lUser2Private);
            Assert.IsNull(lSaveManager.ReadKeyValue("EXCHANGE_PRIVATE", 4));
            Assert.IsNull(lSaveManager.ReadKeyValue("EXCHANGE_PRIV", 4));
        }
Ejemplo n.º 2
0
        public void TestDBCreation()
        {
            var lSaveManagerFactory = PandoraSaveManagerFactory.GetSaveMangerFactory();
            var lSaveManager        = lSaveManagerFactory.GetNewPandoraSaveManager(SavePlace.SQLiteDisk);

            if (File.Exists(FullTestFilePath))
            {
                File.Delete(FullTestFilePath);
            }
            lSaveManager.Initialize(DebugPath, FTestFileName, FUsername, FEmail);
            Assert.IsTrue(File.Exists(FullTestFilePath));
            lSaveManager.Dispose();
            var lSaveManager2 = lSaveManagerFactory.GetNewPandoraSaveManager(SavePlace.SQLiteDisk);

            lSaveManager2.Initialize(DebugPath, FTestFileName, FUsername, FEmail);
            Assert.AreEqual(lSaveManager2.Version, 103);
            lSaveManager2.Dispose();
        }
Ejemplo n.º 3
0
        public void TestExchangeKeyValueHelper()
        {
            if (File.Exists(FullTestFilePath))
            {
                File.Delete(FullTestFilePath);
            }
            var lSaveManagerFactory = PandoraSaveManagerFactory.GetSaveMangerFactory();
            var lSaveManager        = lSaveManagerFactory.GetNewPandoraSaveManager(SavePlace.SQLiteDisk);

            lSaveManager.Initialize(DebugPath, FTestFileName, FUsername, FEmail);
            var lKeyValueHelper = new ExchangeKeyValueHelper <TestKeyValueObject>(lSaveManager);
            var lTestObjects    = new TestKeyValueObject[]
            {
                new TestKeyValueObject
                {
                    ProfileID  = 1,
                    PublicKey  = "b687d248edb346f5a1c77bdd9747035d",
                    PrivateKey = "8a01640af9bf437dafcc235967fab6fb",
                },
                new TestKeyValueObject
                {
                    ProfileID  = 2,
                    PublicKey  = "14eed08178ba4eb986a700d84ea193df",
                    PrivateKey = "630debc3a3d54daf8efed5eeb6adc25d"
                }
            };

            foreach (var lTestObject in lTestObjects)
            {
                lKeyValueHelper.SaveChanges(lTestObject);
            }
            var lObject = lKeyValueHelper.LoadKeyValues(2);

            Assert.AreEqual(lObject.PublicKey, "14eed08178ba4eb986a700d84ea193df");
            Assert.AreEqual(lObject.PrivateKey, "630debc3a3d54daf8efed5eeb6adc25d");

            Assert.ThrowsException <Exception>(() => lKeyValueHelper.WriteKey("exchange_secret", "testestest123123123", 3));

            lKeyValueHelper.WriteKey("exchange_private", "testestest123123123", 3);
            var lObject2 = lKeyValueHelper.LoadKeyValues(3);

            Assert.AreEqual(lObject2.PrivateKey, "testestest123123123");
        }