protected override void Check() { var c = new C { A = 3, B = -17, S = { A = 3 }, T = new[] { new S { A = 99 }, new S { A = 81 } } }; var a = new[] { E.A, E.B }; GenerateCode(SerializationMode.Optimized, a, c); StateSlotCount.ShouldBe(3); Serialize(); c.B = 2; c.A = 1; a[0] = 0; a[1] = 0; c.S = new S(); c.T[0] = new S(); c.T[1] = new S(); Deserialize(); c.B.ShouldBe((sbyte)-17); c.A.ShouldBe((byte)3); a.ShouldBe(new[] { E.A, E.B }); c.S.A.ShouldBe((byte)3); c.T[0].A.ShouldBe((byte)99); c.T[1].A.ShouldBe((byte)81); }
protected override void Check() { var c = new C { A = 3, B = -17, D = 99, E = 77, F = 9234, G = 48483 }; var a = new byte[] { 1, 2 }; GenerateCode(SerializationMode.Optimized, a, c); StateSlotCount.ShouldBe(5); Serialize(); c.A = 1; c.B = 2; c.D = 1; c.E = 9; c.F = 4; c.G = 9; a[0] = 0; a[1] = 0; Deserialize(); c.A.ShouldBe((sbyte)3); c.B.ShouldBe((sbyte)-17); c.D.ShouldBe((short)99); c.E.ShouldBe((short)77); c.F.ShouldBe(9234); c.G.ShouldBe(48483); a.ShouldBe(new byte[] { 1, 2 }); }
protected override void Check() { var a = new[] { E8.A, E8.B }; var b = new[] { E16.A, E16.B }; var c = new[] { E32.A, E32.B }; var d = new C { A = E8.A, B = E8.B }; GenerateCode(SerializationMode.Optimized, a, b, c, d); StateSlotCount.ShouldBe(4); Serialize(); a[0] = 0; a[1] = 0; b[0] = 0; b[1] = 0; c[0] = 0; c[1] = 0; d.A = E8.A; d.B = E8.B; Deserialize(); a.ShouldBe(new[] { E8.A, E8.B }); b.ShouldBe(new[] { E16.A, E16.B }); c.ShouldBe(new[] { E32.A, E32.B }); d.A.ShouldBe(E8.A); d.B.ShouldBe(E8.B); }
protected override void Check() { var x = new X { A = true, B = false, C = true, D = true, E = 129, F = 3293, G = 49493 }; GenerateCode(SerializationMode.Optimized, x); StateSlotCount.ShouldBe(2); Serialize(); x.A = false; x.B = false; x.C = false; x.D = false; x.E = 0; x.F = 0; x.G = 0; Deserialize(); x.A.ShouldBe(true); x.B.ShouldBe(false); x.C.ShouldBe(true); x.D.ShouldBe(true); x.E.ShouldBe((byte)129); x.F.ShouldBe((short)3293); x.G.ShouldBe(49493); }
protected override void Check() { var o = new object(); var c = new C { D = 17, E = o, F = true, G = E.B, H = -1247 }; GenerateCode(SerializationMode.Full, c, o); StateSlotCount.ShouldBe(5); Serialize(); c.D = 0; c.E = null; c.F = false; c.G = E.C; c.H = 3; Deserialize(); c.D.ShouldBe((ushort)17); c.E.ShouldBe(o); c.F.ShouldBe(true); c.G.ShouldBe(E.B); c.H.ShouldBe(-1247); c.E = null; Serialize(); c.E = o; Deserialize(); c.D.ShouldBe((ushort)17); c.E.ShouldBe(null); c.F.ShouldBe(true); c.G.ShouldBe(E.B); c.H.ShouldBe(-1247); }
protected override void Check() { var c = new C { A = true, B = false, D = true, E = false, F = true, G = false, H = true, I = true, X = 99 }; GenerateCode(SerializationMode.Optimized, c); StateSlotCount.ShouldBe(2); Serialize(); c.A = false; c.B = false; c.D = false; c.E = false; c.F = false; c.G = false; c.H = false; c.I = false; c.X = 0; Deserialize(); c.A.ShouldBe(true); c.B.ShouldBe(false); c.D.ShouldBe(true); c.E.ShouldBe(false); c.F.ShouldBe(true); c.G.ShouldBe(false); c.H.ShouldBe(true); c.I.ShouldBe(true); c.X.ShouldBe(99); }
protected override void Check() { var c1 = new C { A = true }; var c2 = new C { A = false }; var d = new D { A = 99, B = 3 }; GenerateCode(SerializationMode.Optimized, c1, c2, d); StateSlotCount.ShouldBe(1); Serialize(); c1.A = false; c2.A = false; d.A = 292; d.B = 9; Deserialize(); c1.A.ShouldBe(true); c2.A.ShouldBe(false); d.A.ShouldBe((short)99); d.B.ShouldBe((byte)3); }
protected override void Check() { var c = new C { F = E.B }; GenerateCode(SerializationMode.Full, c); StateSlotCount.ShouldBe(2); Serialize(); c.F = E.C; Deserialize(); c.F.ShouldBe(E.B); c.F = E.D; Serialize(); c.F = E.C; Deserialize(); c.F.ShouldBe(E.D); c.F = E.E; Serialize(); c.F = E.C; Deserialize(); c.F.ShouldBe(E.E); c.F = E.F; Serialize(); c.F = E.C; Deserialize(); c.F.ShouldBe(E.F); }
protected override void Check() { var c = new C { F = 77 }; GenerateCode(SerializationMode.Full, c); StateSlotCount.ShouldBe(2); Serialize(); c.F = 31; Deserialize(); c.F.ShouldBe(77); c.F = -17; Serialize(); c.F = 31; Deserialize(); c.F.ShouldBe(-17); c.F = System.Int64.MaxValue; Serialize(); c.F = 31; Deserialize(); c.F.ShouldBe(System.Int64.MaxValue); c.F = System.Int64.MinValue; Serialize(); c.F = 31; Deserialize(); c.F.ShouldBe(System.Int64.MinValue); }
protected override void Check() { var c = new C { F = true, G = -1247, H = E.B, I = 33, D = new D { T = 77 }, T = new F { T = 12 } }; GenerateCode(SerializationMode.Optimized, c); StateSlotCount.ShouldBe(1); Serialize(); c.F = false; c.G = 3; c.H = E.C; c.I = 88; c.D.T = 0; c.T.T = 0; Deserialize(); c.F.ShouldBe(false); c.G.ShouldBe(-1247); c.H.ShouldBe(E.C); c.I.ShouldBe(88); c.J.ShouldBe(333); c.K.ShouldBe(11); c.D.T.ShouldBe(0); c.T.ShouldNotBeNull(); }
protected override void Check() { var c = new C(); GenerateCode(SerializationMode.Full, c); StateSlotCount.ShouldBe(1); GenerateCode(SerializationMode.Optimized, c); StateSlotCount.ShouldBe(1); }
protected override void Check() { var c = new C { X = new X { A = 3, B = 6, C = new Y { A = 1, B = 2, C = true }, }, Y = new Y { A = 17, B = 44, C = true } }; GenerateCode(SerializationMode.Optimized, c); StateSlotCount.ShouldBe(4); Serialize(); c.X = new X(); c.Y = new Y(); Deserialize(); c.X.ShouldNotBeNull(); c.Y.ShouldNotBeNull(); c.X.Value.C.ShouldNotBeNull(); c.X.Value.A.ShouldBe(3); c.X.Value.B.ShouldBe((ushort)6); c.X.Value.C.Value.A.ShouldBe((byte)1); c.X.Value.C.Value.B.ShouldBe((ushort)2); c.Y.Value.A.ShouldBe((byte)17); c.Y.Value.B.ShouldBe((ushort)44); c.Y.Value.C.ShouldBe(true); c.X = new X(); c.Y = new Y(); Serialize(); Deserialize(); c.X.ShouldNotBeNull(); c.Y.ShouldNotBeNull(); c.X.Value.A.ShouldBeNull(); c.X.Value.B.ShouldBeNull(); c.X.Value.C.ShouldBeNull(); c.Y.Value.A.ShouldBeNull(); c.Y.Value.B.ShouldBeNull(); c.Y.Value.C.ShouldBeNull(); }
protected override void Check() { var d1 = new D { X = 5 }; var d2 = new D { X = 77 }; var c = new C { A = new[] { -17, 2, 12 }, B = new[] { 9, 3 }, E = new[] { d1, d2 } }; GenerateCode(SerializationMode.Optimized, c); StateSlotCount.ShouldBe(7); Serialize(); c.A[0] = -3331; c.B[0] = 9999; c.D[0] = 73929; d1.X = 72893; d2.X = 9932; c.F[0].X = 293945; Deserialize(); c.A.ShouldBe(new[] { -3331, 2, 12 }); c.B.ShouldBe(new[] { 9, 3 }); c.D.ShouldBe(new[] { 333, 444 }); d1.X.ShouldBe(5); d2.X.ShouldBe(77); c.F[0].X.ShouldBe(99); GenerateCode(SerializationMode.Full, c); Serialize(); c.A[0] = -332531; c.B[0] = 99399; c.D[0] = 735929; d1.X = 722893; d2.X = 93932; c.F[0].X = 2935945; Deserialize(); c.A.ShouldBe(new[] { -3331, 2, 12 }); c.B.ShouldBe(new[] { 9, 3 }); c.D.ShouldBe(new[] { 333, 444 }); d1.X.ShouldBe(5); d2.X.ShouldBe(77); c.F[0].X.ShouldBe(99); }
protected override void Check() { var c = new C { F = 'A' }; GenerateCode(SerializationMode.Full, c); StateSlotCount.ShouldBe(1); Serialize(); c.F = 'B'; Deserialize(); c.F.ShouldBe('A'); }
protected override void Check() { var c = new C { F = 77 }; GenerateCode(SerializationMode.Full, c); StateSlotCount.ShouldBe(1); Serialize(); c.F = 31; Deserialize(); c.F.ShouldBe((byte)77); }
protected override void Check() { var c = new C { G = 7 }; GenerateCode(SerializationMode.Full, c); StateSlotCount.ShouldBe(1); Serialize(); c.G = 3; Deserialize(); c.G.ShouldBe(7); }
protected override void Check() { var c = new C { F = true }; GenerateCode(SerializationMode.Full, c); StateSlotCount.ShouldBe(1); Serialize(); c.F = false; Deserialize(); c.F.ShouldBe(true); }
protected override unsafe void Check() { var c = new C { F = (int *)77 }; GenerateCode(SerializationMode.Full, c); StateSlotCount.ShouldBe(sizeof(int *) / sizeof(int)); Serialize(); c.F = (int *)31; Deserialize(); ((ulong)c.F).ShouldBe((ulong)77); }
protected override void Check() { var c = new C(1) { F = true, G = -1247, H = E.B, I = 33, D = new D { T = 77 }, T = new F { T = 12 } }; var x = new X { C = c, H = c }; GenerateCode(SerializationMode.Optimized, x); StateSlotCount.ShouldBe(1); Serialize(); x.C.F = false; x.C.G = 3; x.C.H = E.C; x.C.I = 88; x.C.D.T = 0; x.C.T.T = 0; x.H.F = false; x.H.G = 3; x.H.H = E.C; x.H.I = 88; x.H.D.T = 0; x.H.T.T = 0; Deserialize(); x.C.F.ShouldBe(false); x.C.G.ShouldBe(-1247); x.C.H.ShouldBe(E.C); x.C.I.ShouldBe(88); x.C.J.ShouldBe(333); x.C.K.ShouldBe(11); x.C.D.T.ShouldBe(0); x.C.T.T.ShouldBe(0); x.H.F.ShouldBe(false); x.H.G.ShouldBe(3); x.H.H.ShouldBe(E.C); x.H.I.ShouldBe(88); x.H.J.ShouldBe(333); x.H.K.ShouldBe(11); x.H.D.T.ShouldBe(0); x.H.T.T.ShouldBe(0); }
protected override void Check() { var o = new object(); var c = new C { O = o }; GenerateCode(SerializationMode.Optimized, c, o); StateSlotCount.ShouldBe(1); Serialize(); c.O = null; Deserialize(); c.O.ShouldBe(o); }
protected override void Check() { var c = new C { H = E.B }; GenerateCode(SerializationMode.Optimized, c); StateSlotCount.ShouldBe(2); Serialize(); c.H = E.C; Deserialize(); c.F.ShouldBe(true); c.G.ShouldBe(-4); c.H.ShouldBe(E.B); }
protected override void Check() { var o1 = new object(); var o2 = new object(); var c = new C { I = new[] { -17, 2, 12 }, D = new[] { Int64.MaxValue, Int64.MinValue }, B = new[] { true, false, true }, P = new[] { (int *)17, (int *)19 }, O = new[] { o1, o2 }, E = new[] { E.A, E.C }, S = new short[] { 33, 77, 29292, -22923 } }; GenerateCode(SerializationMode.Optimized, c); StateSlotCount.ShouldBe(19 - (IntPtr.Size == 8 ? 0 : 2)); Serialize(); c.I[1] = 33; c.D[0] = Int64.MinValue; c.B[2] = false; c.P[0] = (int *)-1; c.O[1] = null; c.E[1] = E.C; c.S[0] = -3595; c.S[3] = 9923; c.I = null; c.D = null; c.B = null; c.P = null; c.O = null; c.E = null; c.S = null; Deserialize(); c.I.ShouldBe(new[] { -17, 2, 12 }); c.D.ShouldBe(new[] { Int64.MaxValue, Int64.MinValue }); c.B.ShouldBe(new[] { true, false, true }); c.O.ShouldBe(new[] { o1, o2 }); c.E.ShouldBe(new[] { E.A, E.C }); c.S.ShouldBe(new short[] { 33, 77, 29292, -22923 }); c.P.Length.ShouldBe(2); ((ulong)c.P[0]).ShouldBe((ulong)17); ((ulong)c.P[1]).ShouldBe((ulong)19); }
protected override void Check() { var o1 = new object(); var o2 = new object(); var o3 = new object(); var c = new C { O1 = o1, O2 = null, O3 = o1 }; GenerateCode(SerializationMode.Full, c, o1, o2, o3); StateSlotCount.ShouldBe(2); Serialize(); c.O1 = null; c.O2 = o3; c.O3 = null; Deserialize(); c.O1.ShouldBe(o1); c.O2.ShouldBe(null); c.O3.ShouldBe(o1); c.O1 = null; c.O2 = o2; c.O3 = o3; Serialize(); c.O1 = null; c.O2 = o3; c.O3 = null; Deserialize(); c.O1.ShouldBe(null); c.O2.ShouldBe(o2); c.O3.ShouldBe(o3); c.O1 = o3; c.O2 = o1; c.O3 = o2; Serialize(); c.O1 = null; c.O2 = null; c.O3 = null; Deserialize(); c.O1.ShouldBe(o3); c.O2.ShouldBe(o1); c.O3.ShouldBe(o2); }
protected override void Check() { var c = new C { F = true, G = E.B, H = -1247 }; GenerateCode(SerializationMode.Full, c); StateSlotCount.ShouldBe(4); Serialize(); c.F = false; c.G = E.C; c.H = 3; Deserialize(); c.F.ShouldBe(true); c.G.ShouldBe(E.B); c.H.ShouldBe(-1247); }
protected override void Check() { var c = new C(); GenerateCode(SerializationMode.Full, c); StateSlotCount.ShouldBe(2); Serialize(); c.X = 3; Deserialize(); c.X.ShouldBe(null); c.X = 7; Serialize(); c.X = 3; Deserialize(); c.X.ShouldBe(7); }
protected override void Check() { var s1 = new StateMachine <E>(E.B); var s2 = new StateMachine <E>(E.C); var s3 = new StateMachine <E>(E.G); GenerateCode(SerializationMode.Optimized, s1, s2, s3); StateSlotCount.ShouldBe(1); Serialize(); s1.ChangeState(E.A); s2.ChangeState(E.A); s3.ChangeState(E.A); Deserialize(); s1.State.ShouldBe(E.B); s2.State.ShouldBe(E.C); s3.State.ShouldBe(E.G); }
protected override void Check() { var d = new D { S = "Hello" }; var m = InitializeModel(d); Create(m); StateFormulas.ShouldBeEmpty(); RootComponents.Length.ShouldBe(1); StateSlotCount.ShouldBe(1); var root = RootComponents[0]; root.ShouldBeOfType <D>(); ((D)root).S.ShouldBe("Hello"); }
protected override void Check() { var d = new D { T = typeof(object) }; var m = InitializeModel(d); Create(m); ExecutableStateFormulas.ShouldBeEmpty(); RootComponents.Length.ShouldBe(1); StateSlotCount.ShouldBe(1); var root = RootComponents[0]; root.ShouldBeOfType <D>(); ((D)root).T.ShouldBe(typeof(object)); }
protected override void Check() { var c = new C { B = false }; GenerateCode(SerializationMode.Optimized, c); StateSlotCount.ShouldBe(1); StateVectorLayout.Groups.Length.ShouldBe(1); StateVectorLayout.Groups[0].ElementSizeInBits.ShouldBe(1); StateVectorLayout.Groups[0].OffsetInBytes.ShouldBe(0); StateVectorLayout.Groups[0].Slots.Length.ShouldBe(2); StateVectorLayout.Groups[0].Slots[1].Object.ShouldBe(c.F2); StateVectorLayout.Groups[0].Slots[1].Field.ShouldBe( typeof(PermanentFault).GetField("_isActive", BindingFlags.Instance | BindingFlags.NonPublic)); StateVectorLayout.Groups[0].Slots[0].Object.ShouldBe(c); StateVectorLayout.Groups[0].Slots[0].Field.ShouldBe(typeof(C).GetField("B")); StateVectorLayout.Groups[0].GroupSizeInBytes.ShouldBe(1); }
protected override void Check() { var d = new D { A = 7, C = 3 }; var r = new PortReference(d, typeof(D), "M", new[] { typeof(bool), typeof(int) }, typeof(bool), false); var p = new PortReference(d, typeof(D), "Q", new[] { typeof(bool), typeof(int) }, typeof(bool), true); d.B = new PortBinding(r, p); var m = InitializeModel(d); Create(m); ExecutableStateFormulas.ShouldBeEmpty(); RootComponents.Length.ShouldBe(1); StateSlotCount.ShouldBe(2); var root = RootComponents[0]; root.ShouldBeOfType <D>(); r = ((D)root).B.RequiredPort; p = ((D)root).B.ProvidedPort; r.TargetObject.ShouldBe(root); r.DeclaringType.ShouldBe(typeof(D)); r.PortName.ShouldBe("M"); r.ArgumentTypes.ShouldBe(new[] { typeof(bool), typeof(int) }); r.ReturnType.ShouldBe(typeof(bool)); r.IsVirtualCall.ShouldBe(false); p.TargetObject.ShouldBe(root); p.DeclaringType.ShouldBe(typeof(D)); p.PortName.ShouldBe("Q"); p.ArgumentTypes.ShouldBe(new[] { typeof(bool), typeof(int) }); p.ReturnType.ShouldBe(typeof(bool)); p.IsVirtualCall.ShouldBe(true); ((D)root).A.ShouldBe(7); ((D)root).C.ShouldBe(3); }