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.
ReadOnlyTests.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ReadOnlyTests.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 System;
9using System.Net;
10using System.Windows;
11#if !__ANDROID__
12using System.Windows.Controls;
13using System.Windows.Documents;
14using System.Windows.Ink;
15using System.Windows.Input;
16using System.Windows.Media;
17using System.Windows.Media.Animation;
18using System.Windows.Shapes;
19#endif
20using UnitDriven;
21using System.Diagnostics;
22
23#if NUNIT
24using NUnit.Framework;
25using TestClass = NUnit.Framework.TestFixtureAttribute;
26using TestInitialize = NUnit.Framework.SetUpAttribute;
27using TestCleanup = NUnit.Framework.TearDownAttribute;
28using TestMethod = NUnit.Framework.TestAttribute;
29#elif MSTEST
30using Microsoft.VisualStudio.TestTools.UnitTesting;
31#endif
32
34{
35#if TESTING
36 [DebuggerStepThrough]
37#endif
38 [TestClass]
39 public class ReadOnlyTests : TestBase
40 {
41 [TestMethod]
42 [ExpectedException(typeof(NotSupportedException))]
44 {
45 UnitTestContext context = GetContext();
47 MockReadOnly mock = new MockReadOnly();
48 context.Assert.Try(()=>list.Add(mock));
49 context.Complete();
50 }
51
52 [TestMethod]
53 [ExpectedException(typeof(NotSupportedException))]
55 {
56 UnitTestContext context = GetContext();
58 MockReadOnly mock = new MockReadOnly();
59 context.Assert.Try(() => list.Insert(0, mock));
60 context.Complete();
61 }
62
63 [TestMethod]
64 [ExpectedException(typeof(NotSupportedException))]
66 {
67 UnitTestContext context = GetContext();
69 context.Assert.Try(() => list[0] = new MockReadOnly());
70 context.Complete();
71 }
72
73 [TestMethod]
74 [ExpectedException(typeof(NotSupportedException))]
76 {
77 UnitTestContext context = GetContext();
79 context.Assert.Try(() => list.AddNew());
80 context.Complete();
81 }
82
83 [TestMethod]
84 [ExpectedException(typeof(NotSupportedException))]
85 public void ClearReadOnlyFail()
86 {
87 UnitTestContext context = GetContext();
89 context.Assert.Try(() => list.Clear());
90 context.Complete();
91 }
92 }
93}
void Try(Action p)
Definition: Asserter.cs:60
UnitTestContext GetContext()
Definition: TestBase.cs:12