public void Given_ValidAESKeyPOCO_When_SerializeAndDeserialize_Then_POCOContentIsTheSame()
        {
            // Arrange
            var aesKeyXmlPoco = new EnvCryptKey()
            {
                Name = "My AES Key",
                Aes  = new[]
                {
                    new EnvCryptKeyAes()
                    {
                        Iv  = "aesIV",
                        Key = "aesKey"
                    }
                },
                Encryption = "Aes",
                Type       = null
            };

            // Act
            var xmlUtil      = new XmlSerializationUtils <EnvCryptKey>();
            var serialized   = xmlUtil.Serialize(aesKeyXmlPoco);
            var deserialized = xmlUtil.Deserialize(serialized);

            // Assert
            deserialized.Should().NotBeNull();
            deserialized.Name.Should().Be(aesKeyXmlPoco.Name);
            deserialized.Encryption.Should().Be(aesKeyXmlPoco.Encryption);
            deserialized.Type.Should().BeNull();
            deserialized.Aes.Should().HaveCount(1);
            deserialized.Aes[0].Iv.Should().Be("aesIV");
            deserialized.Aes[0].Key.Should().Be("aesKey");
        }
Esempio n. 2
0
        public TasksResponse Execute()
        {
            var xml = XmlSerializationUtils.Serialize(this._Wrapper);
            var url = this.MakeUrl();

            if (_boolSwitch.Enabled)
            {
                Trace.WriteLine("Post URL:");
                Trace.WriteLine(url);
                Trace.WriteLine("Request XML:");
                Trace.WriteLine(xml);
            }

            var result = HttpUtils.Post(this.MakeUrl(), xml);

            if (_boolSwitch.Enabled)
            {
                Trace.WriteLine("Response XML:");
                Trace.WriteLine(result);
            }

            var tasksResponse = (TasksResponse)XmlSerializationUtils.Deserialize(typeof(TasksResponse), result);

            CheckErrors(tasksResponse.Errors);

            return(tasksResponse);
        }