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.
PropertyInfoTests.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="PropertyInfoTests.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;
9#if !NUNIT
10using System.Diagnostics;
11using Csla.TestHelpers;
12using Microsoft.VisualStudio.TestTools.UnitTesting;
13#else
14using NUnit.Framework;
15using TestClass = NUnit.Framework.TestFixtureAttribute;
16using TestInitialize = NUnit.Framework.SetUpAttribute;
17using TestCleanup = NUnit.Framework.TearDownAttribute;
18using TestMethod = NUnit.Framework.TestAttribute;
19#endif
20
22{
23 [TestClass]
24 public class PropertyInfoTests
25 {
26 private static TestDIContext _testDIContext;
27
29 public static void ClassInitialize(TestContext context)
30 {
31 _testDIContext = TestDIContextFactory.CreateDefaultContext();
32 }
33
34 [TestMethod]
35 public void TestName()
36 {
37 Assert.AreEqual(PropertyInfoRoot._nameProperty.Name, PropertyInfoRoot._nameProperty.FriendlyName);
38 }
39
40 [TestMethod]
42 {
43 Assert.AreEqual("Name: DataAnnotations", PropertyInfoRoot._nameDataAnnotationsProperty.FriendlyName);
44 }
45
46 [TestMethod]
48 {
49 Assert.AreEqual("Name: ComponentModel", PropertyInfoRoot._nameComponentModelProperty.FriendlyName);
50 }
51
52 [TestMethod]
54 {
55 Assert.AreEqual("Name: Friendly Name", PropertyInfoRoot._nameFriendlyNameProperty.FriendlyName);
56 }
57
58 [TestMethod]
59 public void TestDefaultValue()
60 {
61 IDataPortal<PropertyInfoRoot> dataPortal = _testDIContext.CreateDataPortal<PropertyInfoRoot>();
62
63 Assert.AreEqual("x", PropertyInfoRoot.NameDefaultValueProperty.DefaultValue);
64 Assert.AreEqual("x", PropertyInfoRoot.NewPropertyInfoRoot(dataPortal).NameDefaultValue);
65 }
66
67 [TestMethod]
69 {
70 IDataPortal<PropertyInfoRoot> dataPortal = _testDIContext.CreateDataPortal<PropertyInfoRoot>();
71
72 Assert.AreEqual(null, PropertyInfoRoot.StringNullDefaultValueProperty.DefaultValue);
73 Assert.AreEqual(null, PropertyInfoRoot.NewPropertyInfoRoot(dataPortal).StringNullDefaultValue);
74 }
75 }
76}
static readonly PropertyInfo< System.String > _nameComponentModelProperty
static readonly PropertyInfo< System.String > _nameProperty
Note: We exposed the PropertyInfo's so we can test it...
static readonly PropertyInfo< string > StringNullDefaultValueProperty
static readonly PropertyInfo< string > NameDefaultValueProperty
static readonly PropertyInfo< System.String > _nameFriendlyNameProperty
static readonly PropertyInfo< System.String > _nameDataAnnotationsProperty
static PropertyInfoRoot NewPropertyInfoRoot(IDataPortal< PropertyInfoRoot > dataPortal)
static void ClassInitialize(TestContext context)
Type to carry context information for DI in unit tests
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17