Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
53e8df9
fixed Error message of StringLengthRule
h0lg Mar 25, 2011
92741b5
renamed ConcernOfComparingComplexModelMetadata to ConcernOfComparingM…
h0lg Mar 29, 2011
bab4892
changed reference to System.Web.Mvc from relative HintPath to GAC pre…
h0lg Mar 29, 2011
aa44a44
fixing psake by running tests using xunit.console.clr4.exe
h0lg Apr 4, 2011
86dee29
skipping test requiring EF to be installed
h0lg Apr 4, 2011
bd9cf4b
remove unused variable
h0lg Apr 4, 2011
2353877
corrected ErrorMessageFormat of RangeRule and parameter order of exce…
h0lg Apr 18, 2011
4508bad
updated gitignore with UpgradeReport files & *.orig files from KDiff3…
h0lg Apr 18, 2011
9a36a8f
fixed ClassRuleModelValidator.Validate method to use Metadata.Model a…
h0lg Apr 19, 2011
9874f1a
fixed comments
h0lg Apr 23, 2011
3d71c46
added ConvertEmptyStringToNull property to Metadata
h0lg Mar 28, 2011
491810a
just clarified tasks
h0lg Mar 29, 2011
8e05e47
task for writing missing Metadata.CopyMetaDataFrom tests
h0lg Apr 4, 2011
06baf71
added Custom DataType to IAsProperty
h0lg Apr 4, 2011
895b232
refactored RangeRule to accept IComparables
h0lg Apr 18, 2011
6dcf254
made RangeRule accessible to configuration API via Range(min,max) on …
h0lg Apr 18, 2011
7f0a573
refactored duplicated StringLength information into Getter function o…
h0lg Apr 18, 2011
e903680
added support for minimum string length in rule & configuration API
h0lg Apr 18, 2011
34c1f14
made PropertyMustMatchRule available in API throgh Class.PropertiesSh…
h0lg Apr 18, 2011
83e5b05
added task for System.Web.Mvc.IClientValidatable support
h0lg Apr 18, 2011
99e72f6
commented untested property mappings in Metadata.CopyMetaDataFrom
h0lg Apr 23, 2011
17806f9
copying DataTypeName on CopyMetadataFrom
h0lg Apr 23, 2011
29ef2f8
copying Description on CopyMetadataFrom
h0lg Apr 23, 2011
b1bce04
copying DisplayFormat on CopyMetadataFrom
h0lg Apr 23, 2011
2ccb7bf
copying EditorFormat on CopyMetadataFrom
h0lg Apr 23, 2011
e6636ee
copying HideSurroundingHtml on CopyMetadataFrom
h0lg Apr 23, 2011
a64a170
copying Readonly on CopyMetadataFrom
h0lg Apr 23, 2011
8b748ac
copying NullDisplayText on CopyMetadataFrom
h0lg Apr 23, 2011
b7ac31b
copying ShowDisplay on CopyMetadataFrom
h0lg Apr 23, 2011
4008eb9
copying ShowEditor on CopyMetadataFrom
h0lg Apr 23, 2011
47f0104
copying TemplateHint on CopyMetadataFrom
h0lg Apr 23, 2011
35bde53
copying Watermark on CopyMetadataFrom
h0lg Apr 23, 2011
4f312d0
copying ConvertEmptyStringToNull on CopyMetadataFrom
h0lg Apr 23, 2011
96e77b7
copying Hidden on CopyMetadataFrom
h0lg Apr 23, 2011
42922a7
copying Rules on CopyMetadataFrom
h0lg Apr 23, 2011
3650e3a
added XML docs for Metadata.Hidden
h0lg Apr 23, 2011
7ff2971
updated tasks
h0lg Apr 23, 2011
48495b8
tested for ContainerType being correct on copied metadata
h0lg Apr 23, 2011
80f5ea5
deleted tasks for Metadata properties that don't need to be copied
h0lg Apr 23, 2011
f1d0d89
wrote task for mapping missing Metadata properties in FluentMetadata.…
h0lg Apr 25, 2011
c608d16
added tasks for mapping to ModelMetadata.Description in MVC3
h0lg Apr 25, 2011
c9ad039
DisplayFormat is copied to ModelMetadata
h0lg Apr 25, 2011
2bdf8cb
EditorFormat is copied to ModelMetadata
h0lg Apr 25, 2011
f86ccd6
fixed mapping of DataTypeName to ModelMetadata
h0lg Apr 25, 2011
2b79b63
HideSurroundingHtml is copied to ModelMetadata
h0lg Apr 25, 2011
73d99ca
Readonly is copied to ModelMetadata
h0lg Apr 25, 2011
9cbcacf
refactored validation tests to use ComplexModel
h0lg Apr 25, 2011
bedb704
removed unneeded tests
h0lg Apr 25, 2011
bb2801a
Required is copied to ModelMetadata
h0lg Apr 25, 2011
09b0927
added test for ModelType being correct on ModelMetadata
h0lg Apr 25, 2011
d1fdd8a
NullDisplayText is copied to ModelMetadata
h0lg Apr 25, 2011
6280e94
ShowDisplay is copied to ModelMetadata
h0lg Apr 25, 2011
751a93a
ShowEditor is copied to ModelMetadata
h0lg Apr 25, 2011
147605d
TemplateHint is copied to ModelMetadata respecting HiddenInput as well
h0lg Apr 25, 2011
97ec385
added task for mapping ModelMetadata.Watermark in MVC3
h0lg Apr 25, 2011
f9eded1
added a class diagram giving an overview over the inheritance of the …
h0lg Mar 29, 2011
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
_ReSharper*/
*.vs10x
Source/Gallio Reports
Source/TestResults
Source/TestResults
Source/_UpgradeReport_Files/
*.orig
Source/UpgradeLog*
25 changes: 21 additions & 4 deletions Source/FluentMetadata.Core.Specs/ClassMetadata_with_Person.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Linq;
using FluentMetadata.Rules;
using FluentMetadata.Specs.SampleClasses;
using Xunit;

Expand All @@ -10,26 +12,41 @@ public class ClassMetadata_with_Person : MetadataTestBase
public ClassMetadata_with_Person()
{
var query = new QueryFluentMetadata();
classMetadata = query.GetMetadataFor(typeof (Person));
classMetadata = query.GetMetadataFor(typeof(Person));
}

[Fact]
public void Metadata_ModelType_is_Person()
{
Assert.Equal(typeof (Person), classMetadata.ModelType);
Assert.Equal(typeof(Person), classMetadata.ModelType);
}

[Fact]
public void Metadata_ModelName_is_Null()
{
Assert.Null(classMetadata.ModelName);
// Assert.Equal("Person", classMetadata.ModelName);
Assert.Null(classMetadata.ModelName);
}

[Fact]
public void Metadata_Display_is_Benutzer()
{
Assert.Equal("Benutzer", classMetadata.DisplayName);
}

[Fact]
public void Instance_with_FirstName_different_from_LastName_is_invalid()
{
var rule = classMetadata.Rules.OfType<PropertyMustMatchRule<Person>>().Last();
var person = new Person { FirstName = "foo", LastName = "bar" };
Assert.False(rule.IsValid(person));
}

[Fact]
public void Instance_with_FirstName_equal_to_LastName_is_valid()
{
var rule = classMetadata.Rules.OfType<PropertyMustMatchRule<Person>>().Last();
var person = new Person { FirstName = "foo", LastName = "foo" };
Assert.True(rule.IsValid(person));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<Compile Include="MetadataSetup.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PropertyMedata_with_WebUser.cs" />
<Compile Include="Rules\PropertyMustMatchRuleSpecs.cs" />
<Compile Include="Rules\RangeRuleSpecs.cs" />
<Compile Include="Rules\RequiredRuleSpecs.cs" />
<Compile Include="Rules\StringLengthRuleSpecs.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class PropertyMedata_with_Person : MetadataTestBase
public PropertyMedata_with_Person()
{
var query = new QueryFluentMetadata();
firstName = query.GetMetadataFor(typeof (Person), "FirstName");
lastName = query.GetMetadataFor(typeof (Person), "LastName");
firstName = query.GetMetadataFor(typeof(Person), "FirstName");
lastName = query.GetMetadataFor(typeof(Person), "LastName");
}

[Fact]
Expand All @@ -24,7 +24,7 @@ public void FirstName_ModelName_is_FirstName()
[Fact]
public void FirstName_ModelType_is_string()
{
Assert.Equal(typeof (string), firstName.ModelType);
Assert.Equal(typeof(string), firstName.ModelType);
}

[Fact]
Expand All @@ -42,7 +42,7 @@ public void LastName_ModelName_is_LastName()
[Fact]
public void LastName_ModelType_is_string()
{
Assert.Equal(typeof (string), lastName.ModelType);
Assert.Equal(typeof(string), lastName.ModelType);
}

[Fact]
Expand Down
57 changes: 54 additions & 3 deletions Source/FluentMetadata.Core.Specs/PropertyMedata_with_WebUser.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
using FluentMetadata.Specs.SampleClasses;
using System;
using FluentMetadata.Specs.SampleClasses;
using Xunit;

namespace FluentMetadata.Specs
{
public class PropertyMedata_with_WebUser : MetadataTestBase
{
private Metadata username;
private Metadata id;
Metadata lastLogin, username, id, passWordHash, role;

public PropertyMedata_with_WebUser()
{
var query = new QueryFluentMetadata();
username = query.GetMetadataFor(typeof(WebUser), "Username");
id = query.GetMetadataFor(typeof(WebUser), "Id");
lastLogin = query.GetMetadataFor(typeof(WebUser), "LastLogin");
passWordHash = query.GetMetadataFor(typeof(WebUser), "PasswordHash");
role = query.GetMetadataFor(typeof(WebUser), "Role");
}

[Fact]
Expand All @@ -39,6 +42,42 @@ public void Username_Required_is_true()
Assert.True(username.Required.Value);
}

[Fact]
public void Username_MinLength_is_3()
{
Assert.Equal(3, username.GetMinimumLength());
}

[Fact]
public void Username_MaxLength_is_256()
{
Assert.Equal(256, username.GetMaximumLength());
}

[Fact]
public void PassWordHash_MinLength_is_32()
{
Assert.Equal(32, passWordHash.GetMinimumLength());
}

[Fact]
public void PassWordHash_MaxLength_is_null()
{
Assert.Null(passWordHash.GetMaximumLength());
}

[Fact]
public void Role_MinLength_is_null()
{
Assert.Null(role.GetMinimumLength());
}

[Fact]
public void Role_MaxLength_is_256()
{
Assert.Equal(256, role.GetMaximumLength());
}

[Fact]
public void Id_ModelName_is_Id()
{
Expand All @@ -56,5 +95,17 @@ public void Id_Required_is_false()
{
Assert.False(id.Required.HasValue);
}

[Fact]
public void Last_Login_Minimum_is_2010_1_23()
{
Assert.Equal(new DateTime(2010, 1, 23), lastLogin.GetRangeMinimum());
}

[Fact]
public void Last_Login_Maximum_is_DoomsDay()
{
Assert.Equal(DateTime.MaxValue, lastLogin.GetRangeMaximum());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ namespace FluentMetadata.Specs
{
public class PropertyMedata_with_WebUserIndexModel : MetadataTestBase
{
private Metadata username;
private Metadata id;
private Metadata autorName;
Metadata username, id, autorName, email, role;

public PropertyMedata_with_WebUserIndexModel()
{
var query = new QueryFluentMetadata();
username = query.GetMetadataFor(typeof(WebUserIndexModel), "Username");
id = query.GetMetadataFor(typeof(WebUserIndexModel), "Id");
email = query.GetMetadataFor(typeof(WebUserIndexModel), "EMail");
autorName = query.GetMetadataFor(typeof(WebUserIndexModel), "AutorName");
role = query.GetMetadataFor(typeof(WebUserIndexModel), "Role");
}

[Fact]
Expand Down Expand Up @@ -62,7 +62,101 @@ public void Id_Required_is_false()
[Fact]
public void AutorName_DisplayName_is_emaN()
{
Assert.Equal("emaN",autorName.DisplayName);
Assert.Equal("emaN", autorName.DisplayName);
}

[Fact]
public void EMail_DataTypeName_is_EmailAddress()
{
Assert.Equal("EmailAddress", email.DataTypeName);
}

[Fact]
public void Username_Description_is_Name_des_Benutzers()
{
Assert.Equal("Name des Benutzers", username.Description);
}

[Fact]
public void EMail_DisplayFormat_is_MailtoLink()
{
Assert.Equal("<a href='mailto:{0}'>{0}</a>", email.DisplayFormat);
}

[Fact]
public void EMail_EditorFormat_is_plain_value()
{
Assert.Equal("{0}", email.EditorFormat);
}

[Fact]
public void Id_HideSurroundingHtml_is_true()
{
Assert.True(id.HideSurroundingHtml.HasValue);
Assert.True(id.HideSurroundingHtml.Value);
}

[Fact]
public void Username_ReadOnly_is_true()
{
Assert.True(username.Readonly);
}

[Fact]
public void AutorName_NullDisplayText_is_Anonymous_Autor()
{
Assert.Equal("Anonymous Autor", autorName.NullDisplayText);
}

[Fact]
public void Id_ShowDisplay_is_false()
{
Assert.False(id.ShowDisplay);
}

[Fact]
public void Id_ShowEditor_is_false()
{
Assert.False(id.ShowEditor);
}

[Fact]
public void Role_TemplateHint_is_Roles()
{
Assert.Equal("Roles", role.TemplateHint);
}

[Fact]
public void EMail_Watermark_is_dummy_address()
{
Assert.Equal("john@doe.com", email.Watermark);
}

[Fact]
public void Username_ConvertEmptyStringToNull_is_false()
{
Assert.False(username.ConvertEmptyStringToNull);
}

[Fact]
public void Id_Hidden_is_true()
{
Assert.True(id.Hidden.HasValue);
Assert.True(id.Hidden.Value);
}

[Fact]
public void Username_GetMaximumLength_is_256()
{
var maxLength = username.GetMaximumLength();
Assert.True(maxLength.HasValue);
Assert.Equal(256, maxLength);
}

[Fact]
public void Username_ContainerType_is_WebUserIndexModel()
{
Assert.Equal(typeof(WebUserIndexModel), username.ContainerType);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using FluentMetadata.Rules;
using Xunit;

namespace FluentMetadata.Specs.Rules
{
public class ChangePasswordModel
{
public string OldPassword { get; set; }
public string NewPassword { get; set; }
public string ConfirmPassword { get; set; }
}

public class When_two_properties_should_be_equal : InstanceContextSpecification<PropertyMustMatchRule<ChangePasswordModel>>
{
protected override PropertyMustMatchRule<ChangePasswordModel> CreateSut()
{
return new PropertyMustMatchRule<ChangePasswordModel>(x => x.NewPassword, x => x.ConfirmPassword);
}

protected override void Because()
{
}

[Observation]
public void Should_be_valid_if_properties_match()
{
var model = new ChangePasswordModel { NewPassword = "asdf", ConfirmPassword = "asdf" };
Sut.IsValid(model).ShouldBeTrue();
}

[Observation]
public void Should_be_invalid_if_properties_do_not_match()
{
var model = new ChangePasswordModel { NewPassword = "qwer", ConfirmPassword = "asdf" };
Sut.IsValid(model).ShouldBeFalse();
}
}
}
Loading