public void TestSturctWithAttributedConstuctor(String a, int b) { StructWithConstructor obj1 = new StructWithConstructor(a, b); ThriftSerializer ser = new ThriftSerializer(); byte[] objectBytes = ser.Serialize(obj1); StructWithConstructor obj2 = ser.Deserialize <StructWithConstructor>(objectBytes); Assert.False(Object.ReferenceEquals(obj1, obj2)); Assert.Equal(obj1, obj2); }
public void SupportsStructInstanceMethods() { var instance = new StructWithConstructor(); var pureSource = typeof(StructWithConstructor).GetMethod(nameof(StructWithConstructor.PureInstanceMethod)); var pureShim = Shim.Create <RefFunc <StructWithConstructor, bool, bool> >(pureSource); Assert.True(pureShim(ref instance, true)); var mutatingSource = typeof(StructWithConstructor).GetMethod(nameof(StructWithConstructor.MutatingInstanceMethod)); var mutatingShim = Shim.Create <RefAction <StructWithConstructor> >(mutatingSource); mutatingShim(ref instance); Assert.True(instance.HasBeenMutated); }