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.
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Events
Macros
Pages
RuleURITests.cs
Go to the documentation of this file.
1
using
System;
2
using
System.Diagnostics;
3
using
System.Text;
4
using
System.Collections.Generic;
5
using
System.Linq;
6
7
using
Csla
.
Rules
;
8
using
Microsoft
.VisualStudio.TestTools.UnitTesting;
9
using
Csla
.
TestHelpers
;
10
11
namespace
Csla.Test.ValidationRules
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
30
[
ClassInitialize
]
31
public
static
void
ClassInitialize
(TestContext context)
32
{
33
_testDIContext = TestDIContextFactory.CreateDefaultContext();
34
}
35
36
[TestMethod]
37
public
void
RuleURIWithGenericObjectRule
()
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]
44
public
void
RuleURIWithNonGenericType
()
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]
52
public
void
RuleURIWithGenericType
()
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]
60
public
void
RuleURIWithObjectRule
()
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]
67
public
void
LambdaRuleExtensionsAddUniueURIs
()
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]
80
public
void
RuleWithCyrillicNameMustHaveValidURI
()
81
{
82
var prop =
new
PropertyInfo<string>
(
"Изилдр"
);
83
var rule =
new
ИзилдрRule
(prop);
84
Assert.IsTrue(
true
);
85
}
86
}
87
}
Csla.BusinessBase
This is the base class from which most business objects will be derived.
Definition:
BusinessBase.cs:38
Csla.PropertyInfo
Maintains metadata about a property.
Definition:
Csla/PropertyInfo.cs:22
Csla.Rules.CommonRules.MaxLength
Business rule for a maximum length string.
Definition:
CommonRules.cs:168
Csla.Rules.CommonRules.MaxValue
Business rule for a maximum value.
Definition:
CommonRules.cs:399
Csla.Rules.CommonRules.Required
Business rule for a required string.
Definition:
CommonRules.cs:106
Csla.Rules.ObjectRule
Base class for object level rules.
Definition:
ObjectRule.cs:18
Csla.Test.ValidationRules.AddressEdit
Definition:
RuleURITests.cs:14
Csla.Test.ValidationRules.GenericRule
Definition:
RuleURITests.cs:19
Csla.Test.ValidationRules.HasLambdaRules
Definition:
HasLambdaRules.cs:11
Csla.Test.ValidationRules.HasLambdaRules.New
static HasLambdaRules New(IDataPortal< HasLambdaRules > dataPortal)
Definition:
HasLambdaRules.cs:28
Csla.Test.ValidationRules.HasLambdaRules.GetRuleDescriptions
string[] GetRuleDescriptions()
Definition:
HasLambdaRules.cs:42
Csla.Test.ValidationRules.RuleURITests
Definition:
RuleURITests.cs:26
Csla.Test.ValidationRules.RuleURITests.RuleWithCyrillicNameMustHaveValidURI
void RuleWithCyrillicNameMustHaveValidURI()
Definition:
RuleURITests.cs:80
Csla.Test.ValidationRules.RuleURITests.RuleURIWithGenericObjectRule
void RuleURIWithGenericObjectRule()
Definition:
RuleURITests.cs:37
Csla.Test.ValidationRules.RuleURITests.RuleURIWithGenericType
void RuleURIWithGenericType()
Definition:
RuleURITests.cs:52
Csla.Test.ValidationRules.RuleURITests.ClassInitialize
static void ClassInitialize(TestContext context)
Definition:
RuleURITests.cs:31
Csla.Test.ValidationRules.RuleURITests.RuleURIWithNonGenericType
void RuleURIWithNonGenericType()
Definition:
RuleURITests.cs:44
Csla.Test.ValidationRules.RuleURITests.LambdaRuleExtensionsAddUniueURIs
void LambdaRuleExtensionsAddUniueURIs()
Definition:
RuleURITests.cs:67
Csla.Test.ValidationRules.RuleURITests.RuleURIWithObjectRule
void RuleURIWithObjectRule()
Definition:
RuleURITests.cs:60
Csla.Test.ValidationRules.ИзилдрRule
Definition:
ValidationRules/RuleWithCyrillic.cs:11
Csla.TestHelpers.TestDIContext
Type to carry context information for DI in unit tests
Definition:
TestDIContext.cs:19
Csla.IDataPortal
Interface defining the members of the data portal type.
Definition:
IDataPortalT.cs:17
Csla.Rules.CommonRules
Definition:
AuthorizationRules.cs:14
Csla.Rules
Definition:
AddObjectAuthorizationRulesContext.cs:11
Csla.Test.ValidationRules
Definition:
Fakes/Server/Validation/RootThrowsException.cs:9
Csla.TestHelpers
Definition:
ApplicationContextFactory.cs:14
Csla
Definition:
BusinessRuleCases.cs:5
Microsoft
Definition:
ServiceCollectionExtensions.cs:17
Generated by
1.9.2