Beispiel #1
0
        public void Composition_Encodes()
        {
            var actual = ImaginationConfigCodec
                         .EncodeString(ImaginationConfig.Create(
                                           "http://www.google.com",
                                           Natural.Create(1).Match(x => x, _ => null),
                                           new[] { "url1" },
                                           Option <string> .Some("*****@*****.**"),
                                           AdvancedOptions.Create(
                                               false,
                                               SuperAdvancedOptions.Create(
                                                   ChildFieldType.Case1(1)
                                                   )
                                               )
                                           ));

            var expected =
                @"{
  ""url"": ""http://www.google.com"",
  ""connectionLimit"": 1,
  ""trustedUrls"": [
    ""url1""
  ],
  ""email"": ""*****@*****.**"",
  ""advanced"": {
    ""allowNonsecure"": false,
    ""superAdvanced"": {
      ""childField"": 1
    }
  }
}".Replace("\r\n", "\n");

            Assert.Equal(expected, actual);
        }
Beispiel #2
0
        public void Composition_AppropriateData_Decodes()
        {
            var actual = ImaginationConfigCodec
                         .DecodeString(@"{
                'url': 'http://www.google.com',
                'connectionLimit': 1,
                'trustedUrls': ['url1'],
                'email': '*****@*****.**',
                'advanced': {
                    'allowNonsecure': false,
                    'superAdvanced': { 'childField': 1 }
                }
            }")
                         .Match(
                v => v,
                e => null
                );

            var expected = ImaginationConfig.Create(
                "http://www.google.com",
                Natural.Create(1).Match(x => x, _ => null),
                new[] { "url1" },
                Option <string> .Some("*****@*****.**"),
                AdvancedOptions.Create(
                    false,
                    SuperAdvancedOptions.Create(
                        ChildFieldType.Case1(1)
                        )
                    )
                );

            Assert.Equal(expected, actual);
        }