Skip to content

Commit 8794cce

Browse files
committed
Add unit test for [ObservableProperty] on _UpperCamel field
1 parent 8e06c7f commit 8794cce

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/CommunityToolkit.Mvvm.UnitTests/Test_ObservablePropertyAttribute.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,20 @@ public void Test_ObservableProperty_CommandNamesThatCantBeLowered()
969969
Assert.AreSame(model.c中文Command, fieldInfo?.GetValue(model));
970970
}
971971

972+
// See https://github.com/CommunityToolkit/dotnet/issues/375
973+
[TestMethod]
974+
public void Test_ObservableProperty_ModelWithObservablePropertyWithUnderscoreAndUppercase()
975+
{
976+
ModelWithObservablePropertyWithUnderscoreAndUppercase model = new();
977+
978+
Assert.IsFalse(model.IsReadOnly);
979+
980+
// Just ensures this builds and the property is generated with the expected name
981+
model.IsReadOnly = true;
982+
983+
Assert.IsTrue(model.IsReadOnly);
984+
}
985+
972986
public abstract partial class BaseViewModel : ObservableObject
973987
{
974988
public string? Content { get; set; }
@@ -1553,4 +1567,10 @@ public void c中文()
15531567
{
15541568
}
15551569
}
1570+
1571+
private partial class ModelWithObservablePropertyWithUnderscoreAndUppercase : ObservableObject
1572+
{
1573+
[ObservableProperty]
1574+
private bool _IsReadOnly;
1575+
}
15561576
}

0 commit comments

Comments
 (0)