CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Csla.test/Silverlight/Serialization/SerializationTests.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="SerializationTests.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Same test as above only uses one of the mobile formatter overloads to verify that</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Text;
10using System.IO;
11using Csla;
12using Csla.Core;
15using UnitDriven;
16
17#if NUNIT
18using NUnit.Framework;
19using TestClass = NUnit.Framework.TestFixtureAttribute;
20using TestInitialize = NUnit.Framework.SetUpAttribute;
21using TestCleanup = NUnit.Framework.TearDownAttribute;
22using TestMethod = NUnit.Framework.TestAttribute;
23#elif MSTEST
24using Microsoft.VisualStudio.TestTools.UnitTesting;
25#endif
26
28{
29#if TESTING
30 [System.Diagnostics.DebuggerStepThrough]
31#endif
32 [TestClass]
34 {
35 [TestMethod]
37 {
38 UnitTestContext context = GetContext();
39
40 var actual = MobileFormatter.Serialize(null);
41 object result = MobileFormatter.Deserialize(actual);
42
43 context.Assert.IsNotNull(actual);
44 context.Assert.IsNull(result);
45 context.Assert.Success();
46 context.Complete();
47 }
48
50 public class StringCriteria : CriteriaBase<StringCriteria>
51 {
52 public static readonly PropertyInfo<string> ValueProperty = RegisterProperty<string>(c => c.Value);
53 public string Value
54 {
55 get { return ReadProperty(ValueProperty); }
56 set { LoadProperty(ValueProperty, value); }
57 }
58 }
59
60 [TestMethod]
62 {
63 UnitTestContext context = GetContext();
64 var criteria = new StringCriteria { Value = "success" };
65 var buffer = MobileFormatter.Serialize(criteria);
66
67 var actual = (StringCriteria)MobileFormatter.Deserialize(buffer);
68
69 context.Assert.AreEqual(criteria.Value, actual.Value);
70 context.Assert.Success();
71 context.Complete();
72 }
73
74 [TestMethod]
76 {
77 UnitTestContext context = GetContext();
78 DateTime birthdate = new DateTime(1980, 2, 3);
79
80 Person expected = new Person();
81 expected.Name = "test";
82 expected.Unserialized = "should be null";
83 expected.Birthdate = birthdate;
84 expected.DtoDate = DateTimeOffset.Parse("1/1/2000");
85
86 var buffer = MobileFormatter.Serialize(expected);
87 var actual = (Person)MobileFormatter.Deserialize(buffer);
88
89 context.Assert.AreEqual(expected.Name, actual.Name);
90 context.Assert.AreEqual(expected.Birthdate, actual.Birthdate);
91 context.Assert.AreEqual(expected.DtoDate, actual.DtoDate);
92 context.Assert.AreEqual(expected.Age, actual.Age);
93
94 context.Assert.AreEqual(actual.Unserialized, string.Empty);
95 context.Assert.IsNull(actual.Addresses);
96 context.Assert.IsNull(actual.PrimaryAddress);
97
98 context.Assert.IsNotNull(expected.Unserialized);
99 context.Assert.IsNull(expected.Addresses);
100 context.Assert.IsNull(expected.PrimaryAddress);
101 context.Assert.Success();
102 context.Complete();
103 }
104
105 [TestMethod]
107 {
108 UnitTestContext context = GetContext();
109 DateTime birthdate = new DateTime(1980, 2, 3);
110
111 Person expectedPerson = new Person();
112 expectedPerson.Name = "test";
113 expectedPerson.Unserialized = "should be null";
114 expectedPerson.Birthdate = birthdate;
115
116 AddressList expectedAddressList = new AddressList();
117 expectedPerson.Addresses = expectedAddressList;
118
119 Address expectedA1 = new Address();
120 expectedA1.City = "Minneapolis";
121 expectedA1.ZipCode = "55414";
122
123 Address expectedA2 = new Address();
124 expectedA2.City = "Eden Prairie";
125 expectedA2.ZipCode = "55403";
126
127 expectedAddressList.Add(expectedA1);
128 expectedAddressList.Add(expectedA2);
129 expectedPerson.PrimaryAddress = expectedAddressList[1];
130
131 var buffer = MobileFormatter.Serialize(expectedPerson);
132 var actualPerson = (Person)MobileFormatter.Deserialize(buffer);
133
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);
138 context.Assert.IsNotNull(expectedPerson.Unserialized);
139 context.Assert.AreSame(expectedPerson.PrimaryAddress, expectedAddressList[1]);
140
141 var actualAddressList = actualPerson.Addresses;
142 context.Assert.IsNotNull(actualAddressList);
143 context.Assert.AreEqual(expectedAddressList.Count, actualAddressList.Count);
144
145 context.Assert.AreEqual(expectedAddressList[0].City, actualAddressList[0].City);
146 context.Assert.AreEqual(expectedAddressList[0].ZipCode, actualAddressList[0].ZipCode);
147
148 context.Assert.AreEqual(expectedAddressList[1].City, actualAddressList[1].City);
149 context.Assert.AreEqual(expectedAddressList[1].ZipCode, actualAddressList[1].ZipCode);
150
151 context.Assert.AreSame(actualPerson.PrimaryAddress, actualAddressList[1]);
152 context.Assert.Success();
153 context.Complete();
154 }
155
156 [TestMethod]
158 {
159 UnitTestContext context = GetContext();
160 MockReadOnly ro = new MockReadOnly(1);
161 MockReadOnlyList expected = new MockReadOnlyList(ro);
162
163 byte[] serialized = MobileFormatter.Serialize(expected);
164
165 // Deserialization should not throw an exception when adding
166 // deserialized items back into the list.
168
169 context.Assert.AreEqual(expected.Count, actual.Count);
170 context.Assert.AreEqual(expected[0].Id, actual[0].Id);
171 context.Assert.Success();
172 context.Complete();
173 }
174
175 [TestMethod]
176 [ExpectedException(typeof(InvalidOperationException))]
178 {
179 UnitTestContext context = GetContext();
180
181 var expected = new MobileBindingList<int>();
182 expected.Add(1);
183 context.Assert.Try(() => MobileFormatter.Serialize(expected));
184 context.Assert.Fail();
185 context.Complete();
186 }
187
188 [TestMethod]
189 [ExpectedException(typeof(InvalidOperationException))]
191 {
192 UnitTestContext context = GetContext();
193 var expected = new MobileBindingList<MockNonBusinessObject>();
194 expected.Add(new MockNonBusinessObject { Member = "xyz" });
195
196 context.Assert.Try((Func<object, byte[]>)MobileFormatter.Serialize, expected );
197 context.Assert.Fail();
198 context.Complete();
199 }
200
201 [TestMethod]
202 public void ReadOnlyBaseTest()
203 {
204 UnitTestContext context = GetContext();
205 ReadOnlyPerson expected = ReadOnlyPerson.GetReadOnlyPerson("John Does", 1980);
206 byte[] buffer = MobileFormatter.Serialize(expected);
208
209 context.Assert.AreEqual(expected.Birthdate, actual.Birthdate);
210 context.Assert.AreEqual(expected.Name, actual.Name);
211 context.Assert.Success();
212 context.Complete();
213 }
214
215 [TestMethod]
217 {
218 UnitTestContext context = GetContext();
220 byte[] buffer = MobileFormatter.Serialize(expected);
222
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);
226 context.Assert.Success();
227 context.Complete();
228 }
229
230 [TestMethod]
232 {
233 UnitTestContext context = GetContext();
234 MobileList<string> expected = new MobileList<string>();
235 expected.Add("one");
236 expected.Add("two");
237
238 byte[] buffer = MobileFormatter.Serialize(expected);
240
241 context.Assert.AreEqual(expected.Count, actual.Count);
242 context.Assert.AreEqual(expected[0], actual[0]);
243 context.Assert.AreEqual(expected[1], actual[1]);
244 context.Assert.Success();
245 context.Complete();
246 }
247
248 [TestMethod]
250 {
251 UnitTestContext context = GetContext();
252 MobileList<string> expected = new MobileList<string>();
253
254 byte[] buffer = MobileFormatter.Serialize(expected);
256
257 context.Assert.AreEqual(expected.Count, actual.Count);
258 context.Assert.Success();
259 context.Complete();
260 }
261
262 [TestMethod]
264 {
265 UnitTestContext context = GetContext();
267 expected.Add(new MockReadOnly(1));
268 expected.Add(new MockReadOnly(2));
269
270 byte[] buffer = MobileFormatter.Serialize(expected);
272
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);
276 context.Assert.Success();
277 context.Complete();
278 }
279
280 [TestMethod]
282 {
283 UnitTestContext context = GetContext();
284 var d = new MobileDictionary<string, int>();
285 d.Add("a", 12343);
286 d.Add("z", 943204);
287 d.Add("b", 77878);
288 d.Add("x", 42343);
289 d.Add("r", 45345);
290
291 byte[] buffer = MobileFormatter.Serialize(d);
293
294 context.Assert.IsTrue(r.ContainsKey("a"));
295 context.Assert.IsTrue(r.ContainsKey("z"));
296 context.Assert.IsTrue(r.ContainsKey("b"));
297 context.Assert.IsTrue(r.ContainsKey("x"));
298 context.Assert.IsTrue(r.ContainsKey("r"));
299
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"]);
305 context.Assert.Success();
306 context.Complete();
307 }
308
309 [TestMethod]
311 {
312 UnitTestContext context = GetContext();
313 var d = new MobileDictionary<string, int>();
314 d.Add("a", 12343);
315 d.Add("z", 943204);
316 d.Add("b", 77878);
317 d.Add("x", 42343);
318 d.Add("r", 45345);
319
320 var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
321 var buffer = new System.IO.MemoryStream();
322 formatter.Serialize(buffer, d);
323 buffer.Position = 0;
324 var r = (MobileDictionary<string, int>)formatter.Deserialize(buffer);
325
326 context.Assert.IsTrue(r.ContainsKey("a"));
327 context.Assert.IsTrue(r.ContainsKey("z"));
328 context.Assert.IsTrue(r.ContainsKey("b"));
329 context.Assert.IsTrue(r.ContainsKey("x"));
330 context.Assert.IsTrue(r.ContainsKey("r"));
331
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"]);
337 context.Assert.Success();
338 context.Complete();
339 }
340
341 [TestMethod]
343 {
344 UnitTestContext context = GetContext();
346 d.Add("a", new MockReadOnly(1));
347 d.Add("z", new MockReadOnly(2));
348 d.Add("b", new MockReadOnly(3));
349 d.Add("x", new MockReadOnly(4));
350 d.Add("r", new MockReadOnly(5));
351
352 byte[] buffer = MobileFormatter.Serialize(d);
354
355 context.Assert.IsTrue(r.ContainsKey("a"));
356 context.Assert.IsTrue(r.ContainsKey("z"));
357 context.Assert.IsTrue(r.ContainsKey("b"));
358 context.Assert.IsTrue(r.ContainsKey("x"));
359 context.Assert.IsTrue(r.ContainsKey("r"));
360
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);
366 context.Assert.Success();
367 context.Complete();
368 }
369
370 [TestMethod]
372 {
373 UnitTestContext context = GetContext();
375 d.Add(new MockReadOnly(1), "v1");
376 d.Add(new MockReadOnly(2), "v2");
377 d.Add(new MockReadOnly(3), "v3");
378 d.Add(new MockReadOnly(4), "v4");
379 d.Add(new MockReadOnly(5), "v5");
380
381 byte[] buffer = MobileFormatter.Serialize(d);
383
384 foreach (var key in r.Keys)
385 context.Assert.AreEqual(key.Id, Convert.ToInt32(r[key].Substring(1)));
386 context.Assert.Success();
387 context.Complete();
388 }
389
390 [TestMethod]
392 {
393 UnitTestContext context = GetContext();
395 d.Add(new MockReadOnly(21), new MockReadOnly(1));
396 d.Add(new MockReadOnly(22), new MockReadOnly(2));
397 d.Add(new MockReadOnly(23), new MockReadOnly(3));
398 d.Add(new MockReadOnly(24), new MockReadOnly(4));
399 d.Add(new MockReadOnly(25), new MockReadOnly(5));
400
401 byte[] buffer = MobileFormatter.Serialize(d);
403
404 foreach (var key in r.Keys)
405 context.Assert.AreEqual(key.Id, r[key].Id + 20);
406 context.Assert.Success();
407 context.Complete();
408 }
409
416 [TestMethod]
418 {
419 UnitTestContext context = GetContext();
420
421 // Setup the customer w/ logically identical contacts
422 Customer customer = new Customer();
423
424 customer.Name = "Test Customer";
425 customer.PrimaryContact.FirstName = "John";
426 customer.PrimaryContact.LastName = "Smith";
427 customer.AccountsPayableContact.FirstName = "John";
428 customer.AccountsPayableContact.LastName = "Smith";
429
430 // Serialize and deserialize the customer
431 var buffer = MobileFormatter.Serialize(customer);
432 var deserializedCustomer = (Customer)MobileFormatter.Deserialize(buffer);
433
434 // Verify the deserialized customer is identical to the original object
435 context.Assert.AreEqual(customer.Name, deserializedCustomer.Name);
436 context.Assert.AreEqual(customer.PrimaryContact.FirstName, deserializedCustomer.PrimaryContact.FirstName);
437 context.Assert.AreEqual(customer.PrimaryContact.LastName, deserializedCustomer.PrimaryContact.LastName);
438 context.Assert.AreEqual(customer.AccountsPayableContact.FirstName, deserializedCustomer.AccountsPayableContact.FirstName);
439 context.Assert.AreEqual(customer.AccountsPayableContact.LastName, deserializedCustomer.AccountsPayableContact.LastName);
440
441 //
442 // The two CustomerContact objects (PrimaryContact and AccountsPayableContact) should not
443 // point to the same CustomerContact instance after deserialization, even though they
444 // are logically identical. They start as different objects prior to serialization and
445 // they should end as different objects after.
446 //
447 context.Assert.IsFalse(Object.ReferenceEquals(deserializedCustomer.PrimaryContact, deserializedCustomer.AccountsPayableContact));
448
449 context.Assert.Success();
450 context.Complete();
451 }
452
458 [TestMethod]
459 public void NullChildObject()
460 {
461 UnitTestContext context = GetContext();
462
463 // Setup the customer w/ a null child object
464 Customer customer = new Customer();
465
466 customer.Name = "Test Customer";
467 customer.PrimaryContact.FirstName = "John";
468 customer.PrimaryContact.LastName = "Smith";
469 customer.AccountsPayableContact = null;
470
471 // Serialize and deserialize the customer
472 var buffer = MobileFormatter.Serialize(customer);
473 var deserializedCustomer = (Customer)MobileFormatter.Deserialize(buffer);
474
475 // Verify the deserialized customer is identical to the original object
476 context.Assert.AreEqual(customer.Name, deserializedCustomer.Name);
477 context.Assert.AreEqual(customer.PrimaryContact.FirstName, deserializedCustomer.PrimaryContact.FirstName);
478 context.Assert.AreEqual(customer.PrimaryContact.LastName, deserializedCustomer.PrimaryContact.LastName);
479 context.Assert.IsNull(deserializedCustomer.AccountsPayableContact);
480
481 context.Assert.Success();
482 context.Complete();
483 }
484
489 [TestMethod]
491 {
492 UnitTestContext context = GetContext();
493
494 // Setup the customer w/ logically identical contacts
495 CustomerWithEnum customer = new CustomerWithEnum();
496
497 customer.Name = "Test Customer";
498 customer.Quality = CustomerQuality.Good;
499
500 // Serialize and deserialize the customer
501 var buffer = MobileFormatter.Serialize(customer);
502 var deserializedCustomer = (CustomerWithEnum)MobileFormatter.Deserialize(buffer);
503
504 // Verify the deserialized customer is identical to the original object
505 context.Assert.AreEqual(customer.Name, deserializedCustomer.Name);
506 context.Assert.AreEqual(customer.Quality, deserializedCustomer.Quality);
507 context.Assert.Success();
508 context.Complete();
509 }
510
511 [TestMethod()]
513 {
514 UnitTestContext context = GetContext();
515
516 var test = new BinaryReaderWriterTestClassList();
518 test.Setup();
519 var serialized = MobileFormatter.SerializeToDTO(test);
520 CslaBinaryWriter writer = new CslaBinaryWriter();
521 byte[] data;
522 using (var stream = new MemoryStream())
523 {
524 writer.Write(stream, serialized);
525 data = stream.ToArray();
526 }
527
528 CslaBinaryReader reader = new CslaBinaryReader();
529 using (var stream = new MemoryStream(data))
530 {
531 var deserialized = reader.Read(stream);
533 }
534
535 context.Assert.AreEqual(test.Count, result.Count);
536 for (int i = 0; i < test.Count; i++)
537 {
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);
558
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);
569
570 }
571 context.Assert.Success();
572 context.Complete();
573 }
574
575
576 [TestMethod()]
578 {
579 UnitTestContext context = GetContext();
580
581 var test = new BinaryReaderWriterTestClass();
583 test.Setup();
584 var serialized = MobileFormatter.SerializeToDTO(test);
585 CslaBinaryWriter writer = new CslaBinaryWriter();
586 byte[] data;
587 using (var stream = new MemoryStream())
588 {
589 writer.Write(stream, serialized);
590 data = stream.ToArray();
591 }
592
593 CslaBinaryReader reader = new CslaBinaryReader();
594 using (var stream = new MemoryStream(data))
595 {
596 var deserialized = reader.Read(stream);
598 }
599 context.Assert.AreEqual(test.BoolTest, result.BoolTest);
600 context.Assert.AreEqual(test.ByteArrayTest.Length, result.ByteArrayTest.Length);
601 for (int i = 0; i < test.ByteArrayTest.Length; i++)
602 {
603 context.Assert.AreEqual(test.ByteArrayTest[i], result.ByteArrayTest[i]);
604 }
605
606 context.Assert.AreEqual(test.ByteTest, result.ByteTest);
607 context.Assert.AreEqual(test.CharArrayTest.Length, result.CharArrayTest.Length);
608 for (int i = 0; i < test.CharArrayTest.Length; i++)
609 {
610 context.Assert.AreEqual(test.CharArrayTest[i], result.CharArrayTest[i]);
611 }
612
613 context.Assert.AreEqual(test.CharTest, result.CharTest);
614 context.Assert.AreEqual(test.DateTimeOffsetTest, result.DateTimeOffsetTest);
615 context.Assert.AreEqual(test.DateTimeTest, result.DateTimeTest);
616 context.Assert.AreEqual(test.DecimalTest, result.DecimalTest);
617 context.Assert.AreEqual(test.DoubleTest, result.DoubleTest);
618 context.Assert.AreEqual(test.EnumTest, result.EnumTest);
619 context.Assert.AreEqual(test.GuidTest, result.GuidTest);
620 context.Assert.AreEqual(test.Int16Test, result.Int16Test);
621 context.Assert.AreEqual(test.Int32Test, result.Int32Test);
622 context.Assert.AreEqual(test.Int64Test, result.Int64Test);
623 context.Assert.AreEqual(test.SByteTest, result.SByteTest);
624 context.Assert.AreEqual(test.SingleTest, result.SingleTest);
625 context.Assert.AreEqual(test.StringTest, result.StringTest);
626 context.Assert.AreEqual(test.TimeSpanTest, result.TimeSpanTest);
627 context.Assert.AreEqual(test.UInt16Test, result.UInt16Test);
628 context.Assert.AreEqual(test.UInt32Test, result.UInt32Test);
629 context.Assert.AreEqual(test.UInt64Test, result.UInt64Test);
630 context.Assert.AreEqual(test.NullableButSetInt, result.NullableButSetInt);
631 context.Assert.IsNull(test.NullableInt);
632 context.Assert.IsNull(result.NullableInt);
633
634 context.Assert.AreEqual(test.EmptySmartDateTest, result.EmptySmartDateTest);
635 context.Assert.AreEqual(test.EmptySmartDateTest.FormatString, result.EmptySmartDateTest.FormatString);
636 context.Assert.AreEqual(test.EmptySmartDateTest.EmptyIsMin, result.EmptySmartDateTest.EmptyIsMin);
637 context.Assert.AreEqual(test.EmptySmartDateTest.IsEmpty, result.EmptySmartDateTest.IsEmpty);
638 context.Assert.AreEqual(test.EmptySmartDateTest.Date, result.EmptySmartDateTest.Date);
639
640 context.Assert.AreEqual(test.FilledSmartDateTest, result.FilledSmartDateTest);
641 context.Assert.AreEqual(test.FilledSmartDateTest.FormatString, result.FilledSmartDateTest.FormatString);
642 context.Assert.AreEqual(test.FilledSmartDateTest.EmptyIsMin, result.FilledSmartDateTest.EmptyIsMin);
643 context.Assert.AreEqual(test.FilledSmartDateTest.IsEmpty, result.FilledSmartDateTest.IsEmpty);
644 context.Assert.AreEqual(test.FilledSmartDateTest.Date, result.FilledSmartDateTest.Date);
645
646 context.Assert.Success();
647 context.Complete();
648 }
649 }
650}
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().
Definition: MobileList.cs:29
Base type from which Criteria classes can be derived in a business class.
Definition: CriteriaBase.cs:25
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.
Serializes and deserializes objects at the field level.
object DeserializeFromDTO(List< SerializationInfo > serialized)
Serializes an object from a DTO graph
object Deserialize(Stream serializationStream)
Deserialize an object from XML.
List< SerializationInfo > SerializeToDTO(object obj)
Serializes the object into a DTO.
void Serialize(Stream serializationStream, object graph)
Serialize an object graph into XML.
int? NullableButSetInt
Gets or sets the NullableButSetInt value.
Csla.SmartDate FilledSmartDateTest
Gets or sets the EmptySmartDateTest value.
byte[] ByteArrayTest
Gets or sets the ByteArrayTest value.
decimal DecimalTest
Gets or sets the DecimalTest 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.
Csla.SmartDate EmptySmartDateTest
Gets or sets the EmptySmartDateTest value.
DateTimeOffset DateTimeOffsetTest
Gets or sets the DateTimeOffsetTest value.
DateTime DateTimeTest
Gets or sets the DateTimeTest value.
void IsFalse(bool condition)
Definition: Asserter.cs:40
void Try(Action p)
Definition: Asserter.cs:60
void IsTrue(bool condition)
Definition: Asserter.cs:30
UnitTestContext GetContext()
Definition: TestBase.cs:12
string FirstName
Gets or sets the first name of the contact.
string LastName
Gets or sets the last name of the contact.
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)
void NullChildObject()
Verifies that serializing/deserializing an object graph with null references of a type that is comple...
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 ...
@ 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.
Definition: SmartDate.cs:548
DateTime? Date
Gets or sets the date value.
Definition: SmartDate.cs:413
bool EmptyIsMin
Gets a value indicating whether an empty date is the min or max possible date value.
Definition: SmartDate.cs:568
string FormatString
Gets or sets the format string used to format a date value when it is returned as text.
Definition: SmartDate.cs:371