Exemple #1
0
        public void serializeConfigurationContract()
        {
            configuration c = new configuration()
            {
                logger = new winLoggerContract
                {
                    log       = "myLog",
                    source    = "mySource",
                    threshold = verbosity.high
                },
                ibEnvironment = new interactiveBroker
                {
                    application = @"my\Application\path.exe",
                    credentials = new credentials
                    {
                        accountType = accountType.live,
                        login       = new encryptedString("myLogin"),
                        password    = new encryptedString("myPassword"),
                        port        = 4001
                    }
                }
            };

            using (var s = new contractSerializer <configuration>())
            {
                using (MemoryStream ms = (MemoryStream)s.fromObject(c))
                {
                    using (StreamReader reader = new StreamReader(ms))
                    {
                        string res = reader.ReadToEnd();
                    }
                }
            }
        }
Exemple #2
0
        public void serializePassword()
        {
            Wotan.encrypter e = (new encrypterFactory()).create(encrypterType.AES);

            string          s       = "Hello World";
            encryptedString encrypt = new encryptedString(s);
            var             test    = encrypt.decrypted;

            using (var serializer = new contractSerializer <encryptedString>())
            {
                using (MemoryStream ms = (MemoryStream)serializer.fromObject(encrypt))
                {
                    using (StreamReader reader = new StreamReader(ms))
                    {
                        string res = reader.ReadToEnd();

                        Assert.AreEqual(res,
                                        "<encryptedString xmlns=\"http://schemas.datacontract.org/2004/07/Wotan\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">" +
                                        "<encrypt>true</encrypt>" +
                                        "<string>cybHxAg/UGmwBnuStAOaNA==</string>" +
                                        "<method>AES</method>" +
                                        "</encryptedString>");
                    }
                }
            }
        }