Beispiel #1
0
        public void ConstructorByAttribute(string hexBuffer, int expectedId, string expectedName, int expectedAge)
        {
            ObjectWithConstructor2 obj = Helper.Read <ObjectWithConstructor2>(hexBuffer);

            Assert.NotNull(obj);
            Assert.Equal(expectedId, obj.Id);
            Assert.Equal(expectedName, obj.Name);
            Assert.Equal(expectedAge, obj.Age);
        }
Beispiel #2
0
        public void ConstructorByAttribute(string json, int expectedId, string expectedName, int expectedAge)
        {
            JsonSerializerOptions options = new JsonSerializerOptions();

            options.SetupExtensions();

            ObjectWithConstructor2 obj = Helper.Read <ObjectWithConstructor2>(json, options);

            Assert.NotNull(obj);
            Assert.Equal(expectedId, obj.Id);
            Assert.Equal(expectedName, obj.Name);
            Assert.Equal(expectedAge, obj.Age);
        }