[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Runtime/Seriali
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Runtime/Serialization Makefile,NONE,1.1 SuiteSerialization.cs,NONE,1.1 TestObjectIDGenerator.cs,NONE,1.1 TestObjectManager.cs,NONE,1.1 TestSerializationException.cs,NONE,1.1 code-review.txt,NONE,1.1 |
Date: |
Wed, 04 Jun 2003 19:32:23 -0400 |
Update of
/cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/Runtime/Serialization
In directory
subversions:/tmp/cvs-serv25580/tests/runtime/System/Runtime/Serialization
Added Files:
Makefile SuiteSerialization.cs TestObjectIDGenerator.cs
TestObjectManager.cs TestSerializationException.cs
code-review.txt
Log Message:
Make fixups more efficient in "ObjectManager"; add some test cases
for "System.Runtime.Serialization".
--- NEW FILE ---
all:
(cd ../../..; make)
check:
(cd ../../..; make check)
--- NEW FILE ---
/*
* SuiteSerialization.cs - Tests for "System.Runtime.Serialization".
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using CSUnit;
using System;
public class SuiteSerialization
{
public static TestSuite Suite()
{
TestSuite suite = new TestSuite("Serialization
Tests");
suite.AddTests(typeof(TestSerializationException));
suite.AddTests(typeof(TestObjectIDGenerator));
suite.AddTests(typeof(TestObjectManager));
return suite;
}
}; // class SuiteSerialization
--- NEW FILE ---
/*
* TestObjectIDGenerator.cs - Test the "ObjectIDGenerator" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using CSUnit;
using System;
using System.Runtime.Serialization;
public class TestObjectIDGenerator : TestCase
{
// Constructor.
public TestObjectIDGenerator(String name)
: base(name)
{
// Nothing to do here.
}
// Set up for the tests.
protected override void Setup()
{
// Nothing to do here.
}
// Clean up after the tests.
protected override void Cleanup()
{
// Nothing to do here.
}
#if CONFIG_SERIALIZATION
// Test simple object identifier generation.
public void TestObjectIDGeneratorSimple()
{
ObjectIDGenerator gen = new ObjectIDGenerator();
Object obj1 = new Object();
Object obj2 = new Object();
Object obj3 = new Object();
bool firstTime;
AssertEquals("Simple (1)", 1, gen.GetId(obj1,
out firstTime));
Assert("Simple (2)", firstTime);
AssertEquals("Simple (3)", 2, gen.GetId(obj2,
out firstTime));
Assert("Simple (4)", firstTime);
AssertEquals("Simple (5)", 2, gen.GetId(obj2,
out firstTime));
Assert("Simple (6)", !firstTime);
AssertEquals("Simple (7)", 1, gen.HasId(obj1,
out firstTime));
Assert("Simple (8)", !firstTime);
AssertEquals("Simple (9)", 0, gen.HasId(obj3,
out firstTime));
Assert("Simple (10)", firstTime);
AssertEquals("Simple (11)", 3, gen.GetId(obj3,
out firstTime));
Assert("Simple (12)", firstTime);
}
// Add large numbers of objects to an ObjectIDGenerator.
public void TestObjectIDGeneratorMany()
{
ObjectIDGenerator gen = new ObjectIDGenerator();
Object[] list = new Object [1024];
bool firstTime;
int posn;
for(posn = 0; posn < 1024; ++posn)
{
list[posn] = new Object();
AssertEquals("Many (1)", posn + 1,
gen.GetId(list[posn], out firstTime));
Assert("Many (2)", firstTime);
AssertEquals("Many (3)", (posn / 2) + 1,
gen.GetId(list[posn / 2], out firstTime));
Assert("Many (4)", !firstTime);
AssertEquals("Many (5)", (posn / 2) + 1,
gen.HasId(list[posn / 2], out firstTime));
Assert("Many (6)", !firstTime);
}
}
// Check that value-equal objects are given distinct object identifiers.
public void TestObjectIDGeneratorDistinct()
{
ObjectIDGenerator gen = new ObjectIDGenerator();
Object obj1 = (Object)3;
Object obj2 = (Object)3;
long id1;
long id2;
bool firstTime;
id1 = gen.GetId(obj1, out firstTime);
id2 = gen.GetId(obj2, out firstTime);
Assert("Distinct (1)", (id1 != id2));
}
// Test exception cases.
public void TestObjectIDGeneratorExceptions()
{
ObjectIDGenerator gen = new ObjectIDGenerator();
bool firstTime;
try
{
gen.GetId(null, out firstTime);
Fail("Exceptions (1)");
}
catch(ArgumentNullException)
{
// Success.
}
try
{
gen.HasId(null, out firstTime);
Fail("Exceptions (1)");
}
catch(ArgumentNullException)
{
// Success.
}
}
#endif // CONFIG_SERIALIZATION
}; // class TestObjectIDGenerator
--- NEW FILE ---
/*
* TestObjectManager.cs - Test the "ObjectManager" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using CSUnit;
using System;
using System.Runtime.Serialization;
public class TestObjectManager : TestCase
{
// Constructor.
public TestObjectManager(String name)
: base(name)
{
// Nothing to do here.
}
// Set up for the tests.
protected override void Setup()
{
// Nothing to do here.
}
// Clean up after the tests.
protected override void Cleanup()
{
// Nothing to do here.
}
#if CONFIG_SERIALIZATION
// Test object retrieval.
public void TestObjectManagerGetObject()
{
ObjectManager mgr = new ObjectManager
(null, new
StreamingContext(StreamingContextStates.All));
// Register a particular object and then look
for it.
Object obj = new Object();
mgr.RegisterObject(obj, 1234);
AssertSame("GetObject (1)", obj,
mgr.GetObject(1234));
// Look for a non-existent object.
AssertNull("GetObject (2)",
mgr.GetObject(1235));
// Record a delayed fixup for some other object.
mgr.RecordDelayedFixup(1236, "x", 1234);
// Object 1236 shouldn't exist yet.
AssertNull("GetObject (3)",
mgr.GetObject(1236));
}
// Test object registration.
public void TestObjectManagerRegisterObject()
{
ObjectManager mgr = new ObjectManager
(null, new
StreamingContext(StreamingContextStates.All));
// Test error cases.
try
{
mgr.RegisterObject(null, 0);
Fail("RegisterObject (1)");
}
catch(ArgumentNullException)
{
// Success.
}
try
{
mgr.RegisterObject(new Object(), 0);
Fail("RegisterObject (2)");
}
catch(ArgumentOutOfRangeException)
{
// Success.
}
try
{
mgr.RegisterObject(new Object(), -1);
Fail("RegisterObject (3)");
}
catch(ArgumentOutOfRangeException)
{
// Success.
}
mgr.RegisterObject(new Object(), 1);
try
{
// Register a different object with the
same ID.
mgr.RegisterObject(new Object(), 1);
Fail("RegisterObject (4)");
}
catch(SerializationException)
{
// Success.
}
}
#endif // CONFIG_SERIALIZATION
}; // class TestObjectManager
--- NEW FILE ---
/*
* TestSerializationException.cs - Test the "SerializationException" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using CSUnit;
using System;
using System.Runtime.Serialization;
public class TestSerializationException : TestCase
{
// Constructor.
public TestSerializationException(String name)
: base(name)
{
// Nothing to do here.
}
// Set up for the tests.
protected override void Setup()
{
// Nothing to do here.
}
// Clean up after the tests.
protected override void Cleanup()
{
// Nothing to do here.
}
#if CONFIG_SERIALIZATION
// Test the serialization exception constructors.
public void TestSerializationExceptionConstructors()
{
ExceptionTester.CheckMain(typeof(SerializationException),
unchecked((int)0x8013150c));
}
#endif
}; // class TestSerializationException
--- NEW FILE ---
Code review for System.Runtime.Serialization
============================================
Last updated: 4 June 2003
Classes that need tests
-----------------------
Formatter
FormatterConverter
FormatterServices
ObjectIDGenerator (done)
ObjectManager
SerializationException (done)
SerializationInfo
SerializationInfoEnumerator
SurrogateSelector
Formatters.SoapFault
Formatters.Binary.BinaryFormatter
Classes that were validated using manual inspection and csdocvalil
------------------------------------------------------------------
IDeserializationCallback
IFormatter
IFormatterConverter
IObjectReference
ISerializable
ISerializationSurrogate
ISurrogateSelector
SerializationBinder
SerializationEntry
StreamingContext
StreamingContextStates
Formatters.FormatterAssemblyStyle
Formatters.FormatterTypeStyle
Formatters.IFieldInfo
Formatters.ISoapMessage
Formatters.ServerFault
Formatters.SoapMessage
Formatters.TypeFilterLevel
Classes that are deliberately not implemented and don't need testing
--------------------------------------------------------------------
Formatters.InternalRM
Formatters.InternalST
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Runtime/Serialization Makefile,NONE,1.1 SuiteSerialization.cs,NONE,1.1 TestObjectIDGenerator.cs,NONE,1.1 TestObjectManager.cs,NONE,1.1 TestSerializationException.cs,NONE,1.1 code-review.txt,NONE,1.1,
Rhys Weatherley <address@hidden> <=