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.
PropertyTests.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="PropertyTests.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.Collections.Generic;
10using System.Linq;
11using System.Text;
12using UnitDriven;
13#if !NUNIT
14using Microsoft.VisualStudio.TestTools.UnitTesting;
15using System.IO;
16using Csla.Reflection;
17#else
18using NUnit.Framework;
19using TestClass = NUnit.Framework.TestFixtureAttribute;
20using TestInitialize = NUnit.Framework.SetUpAttribute;
21using TestCleanup = NUnit.Framework.TearDownAttribute;
22using TestMethod = NUnit.Framework.TestAttribute;
23#endif
24
26{
27 [TestClass]
28 public class PropertyTests
29 {
30 private string one;
31 private string three;
32
33 public string Test1 { get { return "one"; } }
34
35 public string Test2 { get { return "two"; } set { one = value; } }
36
37 public string Test3 { set { three = value; } }
38
39 [TestMethod]
41 {
42 var expected = "one";
43 var actual = Csla.Reflection.MethodCaller.CallPropertyGetter(this, "Test1");
44 Assert.AreEqual(expected, actual);
45 }
46
47 [TestMethod]
49 {
50 var expected = "two";
51 var actual = Csla.Reflection.MethodCaller.CallPropertyGetter(this, "Test2");
52 Assert.AreEqual(expected, actual);
53 }
54
55 [TestMethod]
56 [ExpectedException(typeof(NotSupportedException))]
58 {
59 Csla.Reflection.MethodCaller.CallPropertyGetter(this, "Test3");
60 }
61
62 [TestMethod]
63 [ExpectedException(typeof(NotSupportedException))]
65 {
66 Csla.Reflection.MethodCaller.CallPropertySetter(this, "Test1", "fail");
67 }
68
69 [TestMethod]
71 {
72 var expected = "two";
73 Csla.Reflection.MethodCaller.CallPropertySetter(this, "Test2", expected);
74 Assert.AreEqual(expected, this.one);
75 }
76
77 [TestMethod]
79 {
80 var expected = "three";
81 Csla.Reflection.MethodCaller.CallPropertySetter(this, "Test3", expected);
82 Assert.AreEqual(expected, this.three);
83 }
84
85 }
86}