19using TestClass = NUnit.Framework.TestFixtureAttribute;
20using TestInitialize = NUnit.Framework.SetUpAttribute;
21using TestCleanup = NUnit.Framework.TearDownAttribute;
22using TestMethod = NUnit.Framework.TestAttribute;
24using Microsoft.VisualStudio.TestTools.UnitTesting;
30 [System.Diagnostics.DebuggerStepThrough]
43 context.
Assert.IsNotNull(actual);
44 context.
Assert.IsNull(result);
69 context.
Assert.AreEqual(criteria.Value, actual.Value);
81 expected.
Name =
"test";
89 context.
Assert.AreEqual(expected.
Name, actual.Name);
92 context.
Assert.AreEqual(expected.
Age, actual.Age);
94 context.
Assert.AreEqual(actual.Unserialized,
string.Empty);
95 context.
Assert.IsNull(actual.Addresses);
96 context.
Assert.IsNull(actual.PrimaryAddress);
112 expectedPerson.
Name =
"test";
117 expectedPerson.
Addresses = expectedAddressList;
120 expectedA1.
City =
"Minneapolis";
124 expectedA2.
City =
"Eden Prairie";
127 expectedAddressList.Add(expectedA1);
128 expectedAddressList.Add(expectedA2);
134 context.
Assert.AreEqual(expectedPerson.
Name, actualPerson.Name);
135 context.
Assert.AreEqual(expectedPerson.
Birthdate, actualPerson.Birthdate);
136 context.
Assert.AreEqual(expectedPerson.
Age, actualPerson.Age);
137 context.
Assert.AreEqual(actualPerson.Unserialized,
string.Empty);
141 var actualAddressList = actualPerson.Addresses;
142 context.
Assert.IsNotNull(actualAddressList);
143 context.
Assert.AreEqual(expectedAddressList.Count, actualAddressList.Count);
145 context.
Assert.AreEqual(expectedAddressList[0].City, actualAddressList[0].City);
146 context.
Assert.AreEqual(expectedAddressList[0].ZipCode, actualAddressList[0].ZipCode);
148 context.
Assert.AreEqual(expectedAddressList[1].City, actualAddressList[1].City);
149 context.
Assert.AreEqual(expectedAddressList[1].ZipCode, actualAddressList[1].ZipCode);
151 context.
Assert.AreSame(actualPerson.PrimaryAddress, actualAddressList[1]);
169 context.
Assert.AreEqual(expected.Count, actual.Count);
170 context.
Assert.AreEqual(expected[0].Id, actual[0].Id);
176 [ExpectedException(typeof(InvalidOperationException))]
189 [ExpectedException(typeof(InvalidOperationException))]
223 context.
Assert.AreEqual(expected.Count, actual.Count);
224 context.
Assert.AreEqual(expected[1].Name, actual[1].Name);
225 context.
Assert.AreEqual(expected[0].Birthdate, actual[0].Birthdate);
241 context.
Assert.AreEqual(expected.Count, actual.Count);
242 context.
Assert.AreEqual(expected[0], actual[0]);
243 context.
Assert.AreEqual(expected[1], actual[1]);
257 context.
Assert.AreEqual(expected.Count, actual.Count);
273 context.
Assert.AreEqual(expected.Count, actual.Count);
274 context.
Assert.AreEqual(expected[0].Id, actual[0].Id);
275 context.
Assert.AreEqual(expected[1].Id, actual[1].Id);
300 context.
Assert.AreEqual(d[
"a"], r[
"a"]);
301 context.
Assert.AreEqual(d[
"z"], r[
"z"]);
302 context.
Assert.AreEqual(d[
"b"], r[
"b"]);
303 context.
Assert.AreEqual(d[
"x"], r[
"x"]);
304 context.
Assert.AreEqual(d[
"r"], r[
"r"]);
320 var formatter =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
321 var buffer =
new System.IO.MemoryStream();
322 formatter.Serialize(buffer, d);
332 context.
Assert.AreEqual(d[
"a"], r[
"a"]);
333 context.
Assert.AreEqual(d[
"z"], r[
"z"]);
334 context.
Assert.AreEqual(d[
"b"], r[
"b"]);
335 context.
Assert.AreEqual(d[
"x"], r[
"x"]);
336 context.
Assert.AreEqual(d[
"r"], r[
"r"]);
361 context.
Assert.AreEqual(d[
"a"].Id, r[
"a"].Id);
362 context.
Assert.AreEqual(d[
"z"].Id, r[
"z"].Id);
363 context.
Assert.AreEqual(d[
"b"].Id, r[
"b"].Id);
364 context.
Assert.AreEqual(d[
"x"].Id, r[
"x"].Id);
365 context.
Assert.AreEqual(d[
"r"].Id, r[
"r"].Id);
384 foreach (var key
in r.Keys)
385 context.Assert.AreEqual(key.Id, Convert.ToInt32(r[key].Substring(1)));
386 context.Assert.Success();
404 foreach (var key
in r.Keys)
405 context.Assert.AreEqual(key.Id, r[key].Id + 20);
406 context.Assert.Success();
424 customer.
Name =
"Test Customer";
435 context.
Assert.AreEqual(customer.
Name, deserializedCustomer.Name);
447 context.
Assert.
IsFalse(Object.ReferenceEquals(deserializedCustomer.PrimaryContact, deserializedCustomer.AccountsPayableContact));
466 customer.
Name =
"Test Customer";
476 context.
Assert.AreEqual(customer.
Name, deserializedCustomer.Name);
479 context.
Assert.IsNull(deserializedCustomer.AccountsPayableContact);
497 customer.
Name =
"Test Customer";
505 context.
Assert.AreEqual(customer.
Name, deserializedCustomer.Name);
506 context.
Assert.AreEqual(customer.
Quality, deserializedCustomer.Quality);
522 using (var stream =
new MemoryStream())
524 writer.
Write(stream, serialized);
525 data = stream.ToArray();
529 using (var stream =
new MemoryStream(data))
531 var deserialized = reader.
Read(stream);
535 context.
Assert.AreEqual(test.Count, result.Count);
536 for (
int i = 0; i < test.Count; i++)
538 context.
Assert.AreEqual(test[i].CharTest, result[i].CharTest);
539 context.
Assert.AreEqual(test[i].DateTimeOffsetTest, result[i].DateTimeOffsetTest);
540 context.
Assert.AreEqual(test[i].DateTimeTest, result[i].DateTimeTest);
541 context.
Assert.AreEqual(test[i].DecimalTest, result[i].DecimalTest);
542 context.
Assert.AreEqual(test[i].DoubleTest, result[i].DoubleTest);
543 context.
Assert.AreEqual(test[i].EnumTest, result[i].EnumTest);
544 context.
Assert.AreEqual(test[i].GuidTest, result[i].GuidTest);
545 context.
Assert.AreEqual(test[i].Int16Test, result[i].Int16Test);
546 context.
Assert.AreEqual(test[i].Int32Test, result[i].Int32Test);
547 context.
Assert.AreEqual(test[i].Int64Test, result[i].Int64Test);
548 context.
Assert.AreEqual(test[i].SByteTest, result[i].SByteTest);
549 context.
Assert.AreEqual(test[i].SingleTest, result[i].SingleTest);
550 context.
Assert.AreEqual(test[i].StringTest, result[i].StringTest);
551 context.
Assert.AreEqual(test[i].TimeSpanTest, result[i].TimeSpanTest);
552 context.
Assert.AreEqual(test[i].UInt16Test, result[i].UInt16Test);
553 context.
Assert.AreEqual(test[i].UInt32Test, result[i].UInt32Test);
554 context.
Assert.AreEqual(test[i].UInt64Test, result[i].UInt64Test);
555 context.
Assert.AreEqual(test[i].NullableButSetInt, result[i].NullableButSetInt);
556 context.
Assert.IsNull(test[i].NullableInt);
557 context.
Assert.IsNull(result[i].NullableInt);
559 context.
Assert.AreEqual(test[i].EmptySmartDateTest, result[i].EmptySmartDateTest);
560 context.
Assert.AreEqual(test[i].EmptySmartDateTest.FormatString, result[i].EmptySmartDateTest.FormatString);
561 context.
Assert.AreEqual(test[i].EmptySmartDateTest.EmptyIsMin, result[i].EmptySmartDateTest.EmptyIsMin);
562 context.
Assert.AreEqual(test[i].EmptySmartDateTest.IsEmpty, result[i].EmptySmartDateTest.IsEmpty);
563 context.
Assert.AreEqual(test[i].EmptySmartDateTest.Date, result[i].EmptySmartDateTest.Date);
564 context.
Assert.AreEqual(test[i].FilledSmartDateTest, result[i].FilledSmartDateTest);
565 context.
Assert.AreEqual(test[i].FilledSmartDateTest.FormatString, result[i].FilledSmartDateTest.FormatString);
566 context.
Assert.AreEqual(test[i].FilledSmartDateTest.EmptyIsMin, result[i].FilledSmartDateTest.EmptyIsMin);
567 context.
Assert.AreEqual(test[i].FilledSmartDateTest.IsEmpty, result[i].FilledSmartDateTest.IsEmpty);
568 context.
Assert.AreEqual(test[i].FilledSmartDateTest.Date, result[i].FilledSmartDateTest.Date);
587 using (var stream =
new MemoryStream())
589 writer.
Write(stream, serialized);
590 data = stream.ToArray();
594 using (var stream =
new MemoryStream(data))
596 var deserialized = reader.
Read(stream);
601 for (
int i = 0; i < test.ByteArrayTest.Length; i++)
608 for (
int i = 0; i < test.CharArrayTest.Length; i++)
631 context.
Assert.IsNull(test.NullableInt);
Inherit from this base class to easily create a serializable list class.
Defines a dictionary that can be serialized through the SerializationFormatterFactory....
Implements a list that is serializable using the SerializationFormatterFactory.GetFormatter().
Base type from which Criteria classes can be derived in a business class.
Maintains metadata about a property.
This is a class that is responsible for deserializing SerializationInfo objects for receiving the dat...
List< SerializationInfo > Read(Stream serializationStream)
Read a data from a stream, typically MemoryStream, and convert it into a list of SerializationInfo ob...
This is a class that is responsible for serializing SerializationInfo objects into a Stream for sendi...
void Write(Stream serializationStream, List< SerializationInfo > objectData)
Write a list of SerializationInfo objects into stream, typically MemoryStream.
Int16 Int16Test
Gets or sets the Int16Test value.
int? NullableButSetInt
Gets or sets the NullableButSetInt value.
Csla.SmartDate FilledSmartDateTest
Gets or sets the EmptySmartDateTest value.
bool BoolTest
Gets or sets the BoolTest value.
byte[] ByteArrayTest
Gets or sets the ByteArrayTest value.
UInt64 UInt64Test
Gets or sets the UInt64Test value.
UInt16 UInt16Test
Gets or sets the UInt16Test value.
char CharTest
Gets or sets the CharTest value.
decimal DecimalTest
Gets or sets the DecimalTest value.
UInt32 UInt32Test
Gets or sets the UInt32Test value.
RandomEnum EnumTest
Gets or sets the EnumTest value.
TimeSpan TimeSpanTest
Gets or sets the TimeSpanTest value.
char[] CharArrayTest
Gets or sets the CharArrayTest value.
Int32 Int32Test
Gets or sets the IntTest value.
Guid GuidTest
Gets or sets the GuidTest value.
Csla.SmartDate EmptySmartDateTest
Gets or sets the EmptySmartDateTest value.
byte ByteTest
Gets or sets the ByteTest value.
Single SingleTest
Gets or sets the SingleTest value.
string StringTest
Gets or sets the StringTest value.
DateTimeOffset DateTimeOffsetTest
Gets or sets the DateTimeOffsetTest value.
int? NullableInt
Gets or sets the NullableInt value.
DateTime DateTimeTest
Gets or sets the DateTimeTest value.
Int64 Int64Test
Gets or sets the Int64Test value.
double DoubleTest
Gets or sets the DoubleTest value.
SByte SByteTest
Gets or sets the SByteTest value.
void IsFalse(bool condition)
void IsTrue(bool condition)
UnitTestContext GetContext()
Implementation of a test business object using CSLA managed properties backed by fields,...
string Name
Gets or sets the name of the customer.
CustomerContact PrimaryContact
Gets or sets the primary customer contact.
CustomerContact AccountsPayableContact
Gets or sets the accounts payable contact for the customer.
Implementation of a test business object with an enum.
string Name
Gets or sets the name of the CustomerWithEnum.
CustomerQuality Quality
Gets or sets the quality of the customer.
static ReadOnlyPerson GetReadOnlyPerson(string personName, int year)
static ReadOnlyPersonList GetReadOnlyPersonList()
static readonly PropertyInfo< string > ValueProperty
void TestSerializationCslaBinaryReaderWriter()
void SerializeWithNullArgumentShouldNotThrowException()
void MobileDictionary_PrimitiveKey_MobileValue()
void NullChildObject()
Verifies that serializing/deserializing an object graph with null references of a type that is comple...
void MobileListSerializationSuccess()
void MobileListWithNonBusinessObjectReferenceType()
void MobileDictionary_PrimitiveKey_PrimitiveValue()
void MobileDictionary_MobileKey_MobileValue()
void MobileListOfMobileObjectsSerializationSuccess()
void SerializeAndDeserializeReadOnly()
void BusinessObjectWithoutChildList()
void MobileDictionary_MobileKey_PrimitiveValue()
void MobileListEmptySerializationSuccess()
void BusinessObjectWithEnum()
Verifies that serialization/deserialization works for business objects that have an property storing ...
void LogicallyIdenticalChildObjects()
Verifies that serializing an object graph with sibling complex objects that implement Equals and are ...
void MobileDictionary_PrimitiveKey_PrimitiveValue_BF()
void ReadOnlyListBaseTest()
void BusinessObjectWithChildList()
void TestSerializationCslaBinaryReaderWriterList()
void SerializeMobileListWithPrimitiveTypes()
void SerializeCriteriaSuccess()
@ DateTimeOffset
Date/time plus time zone / DateTimeOffset
@ Serializable
Prevents updating or inserting until the transaction is complete.
bool IsEmpty
Gets a value indicating whether this object contains an empty date.
DateTime? Date
Gets or sets the date value.
bool EmptyIsMin
Gets a value indicating whether an empty date is the min or max possible date value.
string FormatString
Gets or sets the format string used to format a date value when it is returned as text.