Exemple #1
0
        public void StampDTOJsonMarshalTest()
        {
            DateTime time = new DateTime(2020, 12, 31);

            StampDTO dtoStart = new StampDTO(
                Misc.PublicIdG,
                Misc.PublicIdH,
                time,
                Misc.PublicIdI,
                Misc.PublicIdJ,
                Misc.PublicIdK
                );

            MemoryStream ms = new MemoryStream();

            using (TinkarJsonOutput output = new TinkarJsonOutput(ms, true))
            {
                dtoStart.Marshal(output);
            }

            ms.Position = 0;
            TinkarJsonInput input   = new TinkarJsonInput(ms);
            StampDTO        dtoRead = StampDTO.Make(input.ReadJsonObject());

            Assert.True(dtoStart.CompareTo(dtoRead) == 0);
        }
Exemple #2
0
        public static void JsonDump(IJsonMarshalable m)
        {
            MemoryStream ms = new MemoryStream();

            using (TinkarJsonOutput output = new TinkarJsonOutput(ms, true))
            {
                m.Marshal(output);
            }
            ms.Dump();
        }
        public void ConceptChronologyDTOJsonMarshal()
        {
            ConceptChronologyDTO dtoStart = Misc.CreateConceptChronologyDTO;
            MemoryStream         ms       = new MemoryStream();

            using (TinkarJsonOutput output = new TinkarJsonOutput(ms, true))
            {
                dtoStart.Marshal(output);
            }

            ms.Dump();
            ms.Position = 0;
            using (TinkarJsonInput input = new TinkarJsonInput(ms))
            {
                ConceptChronologyDTO dtoEnd = ConceptChronologyDTO.Make(input.ReadJsonObject());
                Assert.True(dtoStart.CompareTo(dtoEnd) == 0);
            }
        }
Exemple #4
0
        public void A_JsonWriteObjects()
        {
            guidNumber = 0xfedd;
            String outputPath = TestFile("TinkarExport.json");

            List <ComponentDTO> items = new List <ComponentDTO>();

            foreach (ComponentDTO dto in this.CreateComponents())
            {
                items.Add(dto);
            }

            using FileStream fs           = new FileStream(outputPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
            using TinkarJsonOutput output = new TinkarJsonOutput(fs, true);
            output.WriteStartObject();
            output.Put("root", items);
            output.WriteEndObject();
        }
        public void ConceptVersionDTOJsonMarshalTest()
        {
            ConceptVersionDTO dtoStart = Misc.CreateConceptVersionDTO;

            MemoryStream ms = new MemoryStream();

            using (TinkarJsonOutput output = new TinkarJsonOutput(ms, true))
            {
                dtoStart.Marshal(output);
            }

            ms.Dump();
            ms.Position = 0;
            TinkarJsonInput   input   = new TinkarJsonInput(ms);
            ConceptVersionDTO dtoRead = ConceptVersionDTO.Make(input.ReadJsonObject(),
                                                               new PublicId(Misc.g1, Misc.g2, Misc.g3, Misc.g4));

            Assert.True(dtoStart.CompareTo(dtoRead) == 0);
        }
Exemple #6
0
        public void SemanticVersionDTOJsonMarshal()
        {
            SemanticVersionDTO dtoStart = Misc.CreateSemanticVersionDTO;
            MemoryStream       ms       = new MemoryStream();

            using (TinkarJsonOutput output = new TinkarJsonOutput(ms, true))
            {
                dtoStart.Marshal(output);
            }

            ms.Dump();
            ms.Position = 0;
            using (TinkarJsonInput input = new TinkarJsonInput(ms))
            {
                SemanticVersionDTO dtoEnd = SemanticVersionDTO.Make(
                    input.ReadJsonObject(),
                    dtoStart.PublicId
                    );
                Assert.True(dtoStart.CompareTo(dtoEnd) == 0);
            }
        }