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.
BindingListTests.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="BindingListTests.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8using Csla.Core;
10using UnitDriven;
11
12#if NUNIT
13using NUnit.Framework;
14using TestClass = NUnit.Framework.TestFixtureAttribute;
15using TestInitialize = NUnit.Framework.SetUpAttribute;
16using TestCleanup = NUnit.Framework.TearDownAttribute;
17using TestMethod = NUnit.Framework.TestAttribute;
18#elif MSTEST
19using Microsoft.VisualStudio.TestTools.UnitTesting;
20#endif
21
22
24{
25 [TestClass]
26 public class BindingListTests
27 {
28 [TestMethod]
29 public void VerifyAllowEdit()
30 {
31 var expected = new MobileBindingList<MockReadOnly>();
32 expected.AllowEdit = true;
33 byte[] buffer = MobileFormatter.Serialize(expected);
34
36
37 Assert.AreEqual(expected.AllowEdit, actual.AllowEdit);
38 }
39
40 [TestMethod]
41 public void VerifyAllowRemove()
42 {
43 var expected = new MobileBindingList<MockReadOnly>();
44 expected.AllowRemove = true;
45 byte[] buffer = MobileFormatter.Serialize(expected);
46
48
49 Assert.AreEqual(expected.AllowRemove, actual.AllowRemove);
50 }
51
52 [TestMethod]
53 public void VerifyAllowNew()
54 {
55 var expected = new MobileBindingList<MockReadOnly>();
56 expected.AllowNew = true;
57 byte[] buffer = MobileFormatter.Serialize(expected);
58
60
61 Assert.AreEqual(expected.AllowNew, actual.AllowNew);
62 }
63
64 [TestMethod]
66 {
67 var expected = new MobileBindingList<MockReadOnly>();
68 expected.RaiseListChangedEvents = false;
69 byte[] buffer = MobileFormatter.Serialize(expected);
70
72
73 Assert.AreEqual(expected.RaiseListChangedEvents, actual.RaiseListChangedEvents);
74 }
75
76 [TestMethod]
78 {
79 var original = new MockMobileList();
80 original.RaiseListChangedEvents = true;
81 original.Add(new MockReadOnly(0));
82 original.Add(new MockReadOnly(1));
83 original.Add(new MockReadOnly(2));
84
85 Assert.IsTrue(original.HasRaisedOnListChanged, "ListChanged event should have been raised.");
86
87 byte[] buffer = MobileFormatter.Serialize(original);
88 var deserialized = (MockMobileList)MobileFormatter.Deserialize(buffer);
89
90 Assert.IsTrue(deserialized.Count > 0);
91 Assert.IsTrue(deserialized.RaiseListChangedEvents, "Deserializing list should leave RaiseListChangedEvents unchanged.");
92 Assert.IsFalse(deserialized.HasRaisedOnListChanged, "Deserializing list should not have raised ListChanged event.");
93
94 original.RaiseListChangedEvents = false;
95 byte[] buffer2 = MobileFormatter.Serialize(original);
96 var deserialized2 = (MockMobileList)MobileFormatter.Deserialize(buffer2);
97
98 Assert.IsTrue(deserialized2.Count > 0);
99 Assert.IsFalse(deserialized2.RaiseListChangedEvents, "Deserializing list should leave RaiseListChangedEvents unchanged 2.");
100 Assert.IsFalse(deserialized2.HasRaisedOnListChanged, "Deserializing list should not have raised ListChanged event 2.");
101 }
102 }
103}
Serializes and deserializes objects at the field level.
object Deserialize(Stream serializationStream)
Deserialize an object from XML.
void Serialize(Stream serializationStream, object graph)
Serialize an object graph into XML.