Skip to content

Commit

Permalink
Merge pull request #36 from KinsonDigital/preview/v1.0.0-preview.7
Browse files Browse the repository at this point in the history
🚀Preview Release
  • Loading branch information
CalvinWilkinson authored Dec 26, 2022
2 parents d583e68 + 12353ba commit 7f4b4c3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Carbonate/Carbonate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<Nullable>enable</Nullable>

<!--Update this for production and preview releases-->
<Version>1.0.0-preview.6</Version>
<Version>1.0.0-preview.7</Version>

<!--Update this for production and preview releases-->
<FileVersion>1.0.0-preview.6</FileVersion>
<FileVersion>1.0.0-preview.7</FileVersion>

<!--
DO NOT UPDATE THIS FOR PREVIEW RELEASES!!
Expand Down
16 changes: 13 additions & 3 deletions Carbonate/Reactable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public void Unsubscribe(Guid eventId)
return;
}

// ReSharper disable ForCanBeConvertedToForeach
/* Keep this loop as a for-loop. Do not convert to for-each.
* This is due to the Dispose() method possibly being called during
* iteration of the reactors list which will cause an exception.
Expand All @@ -97,12 +96,23 @@ public void Unsubscribe(Guid eventId)
}
}

// ReSharper restore ForCanBeConvertedToForeach
this.notificationsEnded = this.reactors.All(r => r.Unsubscribed);
}

/// <inheritdoc/>
public void UnsubscribeAll() => this.reactors.Clear();
public void UnsubscribeAll()
{
/* Keep this loop as a for-loop. Do not convert to for-each.
* This is due to the Dispose() method possibly being called during
* iteration of the reactors list which will cause an exception.
*/
for (var i = this.reactors.Count - 1; i >= 0; i--)
{
this.reactors[i].OnComplete();
}

this.reactors.Clear();
}

/// <inheritdoc cref="IDisposable.Dispose"/>
public void Dispose() => Dispose(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1 align="center" style='color:mediumseagreen;font-weight:bold'>
Carbonate Preview Release Notes - v1.0.0-preview.7
</h1>

<h2 align="center" style='font-weight:bold'>Quick Reminder</h2>

<div align="center">

As with all software, there is always a chance for issues and bugs, especially for preview releases, which is why your input is greatly appreciated. 🙏🏼
</div>

---

<h2 style="font-weight:bold" align="center">Bug Fixes 🐛</h2>

1. [#33](https://github.com/KinsonDigital/Carbonate/issues/33) - Fixed a bug where the `Reactable.UnsubscribeAll()` method was not unsubscribing all of the `IReactor` subscriptions.
22 changes: 19 additions & 3 deletions Testing/CarbonateTests/ReactableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,30 @@ public void Unsubscribe_WhenUnsubscribingAllEvents_UnsubscribesCorrectReactors()
public void UnsubscribeAll_WhenInvoked_UnsubscribesFromAll()
{
// Arrange
var sut = CreateSystemUnderTest();
sut.Subscribe(Substitute.For<IReactor>());
var eventToUnsubscribeFrom = Guid.NewGuid();
var eventNotToUnsubscribeFrom = Guid.NewGuid();

var mockReactorA = Substitute.For<IReactor>();
mockReactorA.EventId.Returns(eventToUnsubscribeFrom);

var mockReactorB = Substitute.For<IReactor>();
mockReactorB.EventId.Returns(eventNotToUnsubscribeFrom);

var mockReactorC = Substitute.For<IReactor>();
mockReactorC.EventId.Returns(eventToUnsubscribeFrom);

// Act
var sut = CreateSystemUnderTest();
sut.Subscribe(mockReactorC);
sut.Subscribe(mockReactorB);
sut.Subscribe(mockReactorA);

sut.UnsubscribeAll();

// Assert
sut.Reactors.Should().BeEmpty();
mockReactorA.Received(1).OnComplete();
mockReactorB.Received(1).OnComplete();
mockReactorC.Received(1).OnComplete();
}

[Fact]
Expand Down

0 comments on commit 7f4b4c3

Please sign in to comment.