コード例 #1
0
        public void Write_ValidStructure_ShouldWriteToJson()
        {
            // Arrange
            var namedValueKeyPairsFrontend = new NamedKeyValuePairs("frontend");

            namedValueKeyPairsFrontend.Add("seres:elementtype", "Datakodeelement");
            namedValueKeyPairsFrontend.Add("seres:guid", "http://seres.no/guid/Kursdomene/Datakodeelement/other/784952");

            var namedValueKeyPairsBackend = new NamedKeyValuePairs("backend");

            namedValueKeyPairsBackend.Add("seres:elementtype", "Datakodeelement");
            namedValueKeyPairsBackend.Add("seres:guid", "http://seres.no/guid/Kursdomene/Datakodeelement/other/784951");

            var namedValueKeyPairsOther = new NamedKeyValuePairs("other");

            namedValueKeyPairsOther.Add("seres:elementtype", "Datakodeelement");
            namedValueKeyPairsOther.Add("seres:guid", "http://seres.no/guid/Kursdomene/Datakodeelement/other/784950");

            var keyword = new XsdUnhandledEnumAttributesKeyword(new NamedKeyValuePairs[] { namedValueKeyPairsFrontend, namedValueKeyPairsBackend, namedValueKeyPairsOther });

            // Act
            var keywordConverter = new XsdUnhandledEnumAttributesKeywordJsonConverter();
            var jsonStream       = new MemoryStream();
            var jsonWriter       = new Utf8JsonWriter(jsonStream);

            jsonWriter.WriteStartObject();
            keywordConverter.Write(jsonWriter, keyword, new JsonSerializerOptions());
            jsonWriter.WriteEndObject();
            jsonWriter.Flush();

            // Assert
            jsonStream.Seek(0, SeekOrigin.Begin);
            var streamReader = new StreamReader(jsonStream);
            var jsonText     = streamReader.ReadToEnd();

            jsonText.Should().Be(@"{""@xsdUnhandledEnumAttributes"":{""frontend"":{""seres:elementtype"":""Datakodeelement"",""seres:guid"":""http://seres.no/guid/Kursdomene/Datakodeelement/other/784952""},""backend"":{""seres:elementtype"":""Datakodeelement"",""seres:guid"":""http://seres.no/guid/Kursdomene/Datakodeelement/other/784951""},""other"":{""seres:elementtype"":""Datakodeelement"",""seres:guid"":""http://seres.no/guid/Kursdomene/Datakodeelement/other/784950""}}}");
        }
コード例 #2
0
 private static void KeywordEqual(XsdUnhandledEnumAttributesKeyword expected, XsdUnhandledEnumAttributesKeyword actual)
 {
     Assert.True(expected.Equals(actual));
 }