public void RoundTripValueNative <T>(T instance) { var schema = this.CreateSchema <T>(); var decoder = Linker.CreateDecoder(schema); var encoder = Linker.CreateEncoder(schema); SchemaTester.AssertRoundTrip(decoder, encoder, instance); }
public void RoundTripValueNullable() { var schema = this.CreateSchema <double?>(); var decoder = Linker.CreateDecoder(schema); var encoder = Linker.CreateEncoder(schema); SchemaTester.AssertRoundTrip(decoder, encoder, null); SchemaTester.AssertRoundTrip(decoder, encoder, 42); }
public void RoundTripFieldFlatten() { var schema = this.CreateSchema <int>(); schema.DecoderDescriptor.HasField("virtual").HasField("value", () => 0, (ref int target, int source) => target = source).HasValue(); schema.EncoderDescriptor.HasField("virtual").HasField("value", source => source).HasValue(); SchemaTester.AssertRoundTrip(schema.CreateDecoder(() => 0), schema.CreateEncoder(), 17); }
public void RoundTripMixedTypes() { var schema = this.CreateSchema <MixedContainer>(); var decoder = Linker.CreateDecoder(schema); var encoder = Linker.CreateEncoder(schema); SchemaTester.AssertRoundTrip(decoder, encoder, new MixedContainer { floats = new[] { 1.1f, 2.2f, 3.3f }, integer = 17, option = SomeEnum.B, pairs = new Dictionary <string, string> { { "a", "aaa" }, { "b", "bbb" } }, text = "Hello, World!" }); }
public void RoundTripNestedValue() { var schema = this.CreateSchema <NestedValue>(); var decoder = Linker.CreateDecoder(schema); var encoder = Linker.CreateEncoder(schema); SchemaTester.AssertRoundTrip(decoder, encoder, new NestedValue { child = new NestedValue { child = new NestedValue { child = null, value = 64 }, value = 42 }, value = 17 }); }
public void RoundTripNestedArray() { var schema = this.CreateSchema <NestedArray>(); var decoder = Linker.CreateDecoder(schema); var encoder = Linker.CreateEncoder(schema); SchemaTester.AssertRoundTrip(decoder, encoder, new NestedArray { children = new[] { new NestedArray { children = Array.Empty <NestedArray>(), value = "a" }, new NestedArray { children = new [] { new NestedArray { children = Array.Empty <NestedArray>(), value = "b" }, new NestedArray { children = Array.Empty <NestedArray>(), value = "c" } }, value = "d" }, new NestedArray { children = Array.Empty <NestedArray>(), value = "e" } }, value = "f" }); }