Skip to content

Commit

Permalink
feat: do some refactoring (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoBaSs84 authored Dec 12, 2024
2 parents 2b691ae + 0162c15 commit 4a18dc3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
runs-on: windows-latest
runs-on: ubuntu-latest

steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions src/BB84.Notifications/NotifiableObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ private void FillCaches()
foreach (PropertyInfo propertyInfo in propertiesInfos)
{
NotifyChangedAttribute? changedAttribute =
propertyInfo.GetCustomAttribute(typeof(NotifyChangedAttribute), false) as NotifyChangedAttribute;
propertyInfo.GetCustomAttribute<NotifyChangedAttribute>(false);

if (changedAttribute is not null)
_propertiesToNotifyOnChange.Add(propertyInfo.Name, changedAttribute.Properties);

NotifyChangingAttribute? changingAttribute =
propertyInfo.GetCustomAttribute(typeof(NotifyChangingAttribute), false) as NotifyChangingAttribute;
propertyInfo.GetCustomAttribute<NotifyChangingAttribute>(false);

if (changingAttribute is not null)
_propertiesToNotifyOnChanging.Add(propertyInfo.Name, changingAttribute.Properties);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BB84.Notifications;
using BB84.Notifications.Interfaces;

namespace BB84.NotificationsTests;

Expand All @@ -16,7 +15,7 @@ public sealed partial class NotifiablePropertyTests
[DataRow(default, true)]
public void IsDefault(object value, bool expected)
{
INotifiableProperty<object> bindableProperty = new NotifiableProperty<object>(value);
NotifiableProperty<object> bindableProperty = new(value);

Assert.AreEqual(expected, bindableProperty.IsDefault);
}
Expand All @@ -27,7 +26,7 @@ public void IsDefault(object value, bool expected)
[DataRow(default, true)]
public void IsDefaultInteger(int value, bool expected)
{
INotifiableProperty<int> bindableProperty = new NotifiableProperty<int>(value);
NotifiableProperty<int> bindableProperty = new(value);

Assert.AreEqual(expected, bindableProperty.IsDefault);
}
Expand All @@ -38,7 +37,7 @@ public void IsDefaultInteger(int value, bool expected)
[DataRow(default, true)]
public void IsDefaultNullableInteger(int? value, bool expected)
{
INotifiableProperty<int?> bindableProperty = new NotifiableProperty<int?>(value);
NotifiableProperty<int?> bindableProperty = new(value);

Assert.AreEqual(expected, bindableProperty.IsDefault);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed partial class NotifiablePropertyTests
[DataRow(null, true)]
public void IsNull(object? value, bool expected)
{
INotifiableProperty<object?> bindableProperty = new NotifiableProperty<object?>(value);
NotifiableProperty<object?> bindableProperty = new(value);

Assert.AreEqual(expected, bindableProperty.IsNull);
}
Expand Down
7 changes: 6 additions & 1 deletion tests/BB84.NotificationsTests/NotifiablePropertyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ namespace BB84.NotificationsTests;
[TestClass]
public sealed partial class NotifiablePropertyTests
{
private sealed class TestClass(int bindableProperty)
private sealed class TestClass(int bindableProperty) : ITestClass
{
public INotifiableProperty<int> BindableProperty { get; set; } = new NotifiableProperty<int>(bindableProperty);
}

private interface ITestClass
{
INotifiableProperty<int> BindableProperty { get; set; }
}
}
7 changes: 6 additions & 1 deletion tests/BB84.NotificationsTests/ReversiblePropertyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ public void ReversiblePropertyTest()
Assert.AreEqual(default, testClass.Property.Value);
}

private sealed class TestClass(int propertyValue)
private sealed class TestClass(int propertyValue) : ITestClass
{
public TestClass() : this(default)
{ }

public IReversibleProperty<int> Property { get; set; } = new ReversibleProperty<int>(propertyValue);
}

private interface ITestClass
{
IReversibleProperty<int> Property { get; set; }
}
}

0 comments on commit 4a18dc3

Please sign in to comment.