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.
RuleURITests.cs
Go to the documentation of this file.
1using System;
2using System.Diagnostics;
3using System.Text;
4using System.Collections.Generic;
5using System.Linq;
6
7using Csla.Rules;
8using Microsoft.VisualStudio.TestTools.UnitTesting;
9using Csla.TestHelpers;
10
12{
13 public class AddressEdit : Csla.BusinessBase<AddressEdit>
14 {
15
16 }
17
18 public class GenericRule<T> : ObjectRule
19 {
20
21 }
22
23
24 [TestClass]
25 public class RuleURITests
26 {
27
28 private static TestDIContext _testDIContext;
29
31 public static void ClassInitialize(TestContext context)
32 {
33 _testDIContext = TestDIContextFactory.CreateDefaultContext();
34 }
35
36 [TestMethod]
38 {
39 var rule = new GenericRule<AddressEdit>();
40 Assert.AreEqual("rule://csla.test.validationrules.genericrule-csla.test.validationrules/.AddressEdit-/(object)", rule.RuleName);
41 }
42
43 [TestMethod]
45 {
46 var property = new PropertyInfo<string>("test1");
47 var rule = new Csla.Rules.CommonRules.MaxLength(property, 30);
48 Assert.AreEqual("rule://csla.rules.commonrules.maxlength/test1?max=30", rule.RuleName);
49 }
50
51 [TestMethod]
53 {
54 var property = new PropertyInfo<int>("test1");
55 var rule = new Csla.Rules.CommonRules.MaxValue<int>(property, 30);
56 Assert.AreEqual("rule://csla.rules.commonrules.maxvalue-system.int32-/test1?max=30", rule.RuleName);
57 }
58
59 [TestMethod]
61 {
62 var rule = new Csla.Rules.CommonRules.Required(null);
63 Assert.AreEqual("rule://csla.rules.commonrules.required/(object)", rule.RuleName);
64 }
65
66 [TestMethod]
68 {
69 IDataPortal<HasLambdaRules> dataPortal = _testDIContext.CreateDataPortal<HasLambdaRules>();
70
71 var root = HasLambdaRules.New(dataPortal);
72 var ruleUris = root.GetRuleDescriptions();
73
74 var distinctUris = ruleUris.Distinct().ToArray();
75 // must have same length
76 Assert.AreEqual(ruleUris.Length, distinctUris.Length);
77 }
78
79 [TestMethod]
81 {
82 var prop = new PropertyInfo<string>("Изилдр");
83 var rule = new ИзилдрRule(prop);
84 Assert.IsTrue(true);
85 }
86 }
87}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Maintains metadata about a property.
Business rule for a maximum length string.
Definition: CommonRules.cs:168
Business rule for a maximum value.
Definition: CommonRules.cs:399
Business rule for a required string.
Definition: CommonRules.cs:106
Base class for object level rules.
Definition: ObjectRule.cs:18
static HasLambdaRules New(IDataPortal< HasLambdaRules > dataPortal)
static void ClassInitialize(TestContext context)
Definition: RuleURITests.cs:31
Type to carry context information for DI in unit tests
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17