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

Commit eb291ac

Browse files
ghuntleystephentoub
authored andcommitted
Add EditableAttributeTest construction test
Progresses issue #921
1 parent dc8151c commit eb291ac

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-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+
}

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

Lines changed: 1 addition & 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" />

0 commit comments

Comments
 (0)