Skip to content

Commit

Permalink
Merge pull request #551 from CommunityToolkit/dev/upper-camel-unit-test
Browse files Browse the repository at this point in the history
Add unit test for [ObservableProperty] on _UpperCamel field
  • Loading branch information
Sergio0694 committed Jan 2, 2023
2 parents 8e06c7f + 8794cce commit 40f7413
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,20 @@ public void Test_ObservableProperty_CommandNamesThatCantBeLowered()
Assert.AreSame(model.c中文Command, fieldInfo?.GetValue(model));
}

// See https://github.com/CommunityToolkit/dotnet/issues/375
[TestMethod]
public void Test_ObservableProperty_ModelWithObservablePropertyWithUnderscoreAndUppercase()
{
ModelWithObservablePropertyWithUnderscoreAndUppercase model = new();

Assert.IsFalse(model.IsReadOnly);

// Just ensures this builds and the property is generated with the expected name
model.IsReadOnly = true;

Assert.IsTrue(model.IsReadOnly);
}

public abstract partial class BaseViewModel : ObservableObject
{
public string? Content { get; set; }
Expand Down Expand Up @@ -1553,4 +1567,10 @@ public void c中文()
{
}
}

private partial class ModelWithObservablePropertyWithUnderscoreAndUppercase : ObservableObject
{
[ObservableProperty]
private bool _IsReadOnly;
}
}

0 comments on commit 40f7413

Please sign in to comment.