//[Ignore("This test failes as it uses a copy of the old, failing implementation. To be tested however with .NET 2.0 once")] public void Serialization99Test() { // Create and initialize formatter: Sfmt.Binary.BinaryFormatter formatter = new Sfmt.Binary.BinaryFormatter(); formatter.AssemblyFormat = Sfmt.FormatterAssemblyStyle.Simple; // Create DS: global::System.Data.DataSet ds = new global::System.Data.DataSet(); global::System.Data.DataTable dt = ds.Tables.Add("SomeTable"); global::System.Data.DataColumn dc1 = dt.Columns.Add("ID", typeof(global::System.Int32)); ds.AcceptChanges(); // Create MockableCall: Support.OldImplMockableCall call = new Support.OldImplMockableCall(); call.SetCallResult(ds); Assert.IsNotNull(call.ReturnValue, "Test setup failure, test could not even be run !"); // Serialize call: MemoryStream buffer = new MemoryStream(); formatter.Serialize(buffer, call); // Reset buffer: buffer.Flush(); buffer.Position = 0; // Deserialize call: call = (Support.OldImplMockableCall)formatter.Deserialize(buffer); // Verify results: Assert.IsNotNull(call); Assert.IsNotNull(call.ReturnValueFromHolder, "ReturnValue 'late-retrieved' from call failed, this is really unexpected !!!"); Assert.IsNull(call.ReturnValue, "ReturnValue 'early-retrieved 'should be null, which is a failure, but expected to be so !!!"); }
public void Serialization02Test() { // Create and initialize formatter: Sfmt.Binary.BinaryFormatter formatter = new Sfmt.Binary.BinaryFormatter(); formatter.AssemblyFormat = Sfmt.FormatterAssemblyStyle.Simple; // Create DS: global::System.Data.DataSet ds = new global::System.Data.DataSet(); global::System.Data.DataTable dt = ds.Tables.Add("SomeTable"); global::System.Data.DataColumn dc1 = dt.Columns.Add("ID", typeof(global::System.Int32)); ds.AcceptChanges(); // Create MockableCall: MockingProxy callee = new MockingProxy(typeof(Sample.FooBar), null, "m1"); MockableCall call = new MockableCall(callee, typeof(Sample.FooBar).GetMethod("SomeMethodWithInsAndOuts"), new object[] { 1, 2, null, 3 }); // Set dataset as callresult: call.SetCallResult(ds); Assert.IsNotNull(call.ReturnValue, "Test setup failure, test could not even be run !"); // Serialize call: MemoryStream buffer = new MemoryStream(); formatter.Serialize(buffer, call); // Reset buffer: buffer.Flush(); buffer.Position = 0; // Deserialize call: call = (MockableCall)formatter.Deserialize(buffer); // Verify results (expect returnValue to be non-null): Assert.IsNotNull(call); Assert.IsNotNull(call.ReturnValue, "ReturnValue is null, the old implementation issue has reoccured..."); Assert.IsTrue(call.ReturnValue is global::System.Data.DataSet, "What the heck ? returnValue should have been a dataset !"); }
public void Serialization03Test() { // Create and initialize formatter: Sfmt.Soap.SoapFormatter formatter = new Sfmt.Soap.SoapFormatter(); formatter.AssemblyFormat = Sfmt.FormatterAssemblyStyle.Simple; // Create DS: global::System.Data.DataSet ds = new global::System.Data.DataSet(); global::System.Data.DataTable dt = ds.Tables.Add("SomeTable"); global::System.Data.DataColumn dc1 = dt.Columns.Add("ID", typeof(global::System.Int32)); ds.AcceptChanges(); // Create MockableCall: MockingProxy callee = new MockingProxy(typeof(Sample.FooBar), null, "m1"); MockableCall call = new MockableCall(callee, typeof(Sample.FooBar).GetMethod("SomeMethodWithInsAndOuts"), new object[] { 1, 2, null, 3 }); // Set dataset as callresult: call.SetCallResult(ds); Assert.IsNotNull(call.ReturnValue, "Test setup failure, test could not even be run !"); // Serialize call: MemoryStream buffer = new MemoryStream(); formatter.Serialize(buffer, call); // Reset buffer: buffer.Flush(); buffer.Position = 0; // Deserialize call: call = (MockableCall)formatter.Deserialize(buffer); // Verify results (expect returnValue to be non-null): Assert.IsNotNull(call); Assert.IsNotNull(call.ReturnValue, "ReturnValue is null, the old implementation issue has reoccured..."); Assert.IsTrue(call.ReturnValue is global::System.Data.DataSet, "What the heck ? returnValue should have been a dataset !"); }