Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit cb755ce

Browse files
committed
Merge pull request #2005 from stephentoub/annotation_tests
Add tests for EditableAttribute and ScaffoldColumnAttribute
2 parents 8b7bdf6 + 01bd403 commit cb755ce

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

src/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/EditableAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace System.ComponentModel.DataAnnotations
1010
/// <remarks>
1111
/// This attribute neither enforces nor guarantees editability; the underlying data
1212
/// store might allow changing the data regardless of this attribute. The presence
13-
/// of this attribute signals intent to the consumer of the attribute whethere or not
13+
/// of this attribute signals intent to the consumer of the attribute whether or not
1414
/// the end user should be allowed to change the value via the client application.
1515
/// </remarks>
1616
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Xunit;
2+
3+
namespace System.ComponentModel.DataAnnotations
4+
{
5+
public class EditableAttributeTests
6+
{
7+
[Theory]
8+
[InlineData(true)]
9+
[InlineData(false)]
10+
public void Can_construct_and_both_AllowEdit_and_AllowInitialValue_are_set(bool value)
11+
{
12+
var attribute = new EditableAttribute(value);
13+
Assert.Equal(value, attribute.AllowEdit);
14+
Assert.Equal(value, attribute.AllowInitialValue);
15+
}
16+
17+
[Theory]
18+
[InlineData(true)]
19+
[InlineData(false)]
20+
public void Properties_are_independent(bool value)
21+
{
22+
var attribute = new EditableAttribute(value);
23+
Assert.Equal(value, attribute.AllowEdit);
24+
Assert.Equal(value, attribute.AllowInitialValue);
25+
26+
attribute.AllowInitialValue = !value;
27+
Assert.Equal(value, attribute.AllowEdit);
28+
Assert.Equal(!value, attribute.AllowInitialValue);
29+
}
30+
}
31+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Xunit;
2+
3+
namespace System.ComponentModel.DataAnnotations
4+
{
5+
public class ScaffoldColumnAttributeTests
6+
{
7+
[Theory]
8+
[InlineData(true)]
9+
[InlineData(false)]
10+
public void Can_construct_and_get_Scaffold(bool value)
11+
{
12+
var attribute = new ScaffoldColumnAttribute(value);
13+
Assert.Equal(value, attribute.Scaffold);
14+
}
15+
}
16+
}

src/System.ComponentModel.Annotations/tests/System.ComponentModel.Annotations.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<Compile Include="CreditCardAttributeTests.cs" />
2121
<Compile Include="CustomValidationAttributeTests.cs" />
2222
<Compile Include="DataTypeAttributeTests.cs" />
23+
<Compile Include="EditableAttributeTests.cs" />
2324
<Compile Include="EmailAddressAttributeTests.cs" />
2425
<Compile Include="EnumDataTypeAttributeTests.cs" />
2526
<Compile Include="FileExtensionsAttributeTests.cs" />
@@ -29,6 +30,7 @@
2930
<Compile Include="RangeAttributeTests.cs" />
3031
<Compile Include="RegularExpressionAttributeTests.cs" />
3132
<Compile Include="RequiredAttributeTests.cs" />
33+
<Compile Include="ScaffoldColumnAttributeTests.cs" />
3234
<Compile Include="Schema\ColumnAttributeTests.cs" />
3335
<Compile Include="Schema\DatabaseGeneratedAttributeTests.cs" />
3436
<Compile Include="Schema\ForeignKeyAttributeTests.cs" />

0 commit comments

Comments
 (0)