-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from BoBoBaSs84/feature/raise-collection-chang…
…ed-with-action feat: raise collection changed with action
- Loading branch information
Showing
11 changed files
with
284 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/BB84.NotificationsTests/NotifyCollectionBaseTests.Add.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using BB84.Notifications.Enumerators; | ||
|
||
namespace BB84.NotificationsTests; | ||
|
||
public sealed partial class NotifyCollectionBaseTests | ||
{ | ||
[TestMethod] | ||
public void Adding() | ||
{ | ||
CollectionChangeAction action = default!; | ||
string item = string.Empty; | ||
MyCollection strings = new(); | ||
strings.CollectionChanging += (sender, e) => { item = (string)e.Item!; action = e.Action; }; | ||
|
||
strings.Add(UnitTestString); | ||
|
||
Assert.AreEqual(CollectionChangeAction.Add, action); | ||
Assert.AreEqual(UnitTestString, item); | ||
} | ||
|
||
[TestMethod] | ||
public void Added() | ||
{ | ||
CollectionChangeAction action = default!; | ||
string item = string.Empty; | ||
MyCollection strings = new(); | ||
strings.CollectionChanged += (sender, e) => { item = (string)e.Item!; action = e.Action; }; | ||
|
||
strings.Add(UnitTestString); | ||
|
||
Assert.AreEqual(CollectionChangeAction.Add, action); | ||
Assert.AreEqual(UnitTestString, item); | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
tests/BB84.NotificationsTests/NotifyCollectionBaseTests.Changed.cs
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
tests/BB84.NotificationsTests/NotifyCollectionBaseTests.Changing.cs
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
tests/BB84.NotificationsTests/NotifyCollectionBaseTests.Clear.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using BB84.Notifications.Enumerators; | ||
|
||
namespace BB84.NotificationsTests; | ||
|
||
public sealed partial class NotifyCollectionBaseTests | ||
{ | ||
[TestMethod] | ||
public void Clearing() | ||
{ | ||
CollectionChangeAction action = default!; | ||
MyCollection strings = new() { UnitTestString }; | ||
strings.CollectionChanging += (sender, e) => action = e.Action; | ||
|
||
strings.Clear(); | ||
|
||
Assert.AreEqual(CollectionChangeAction.Clear, action); | ||
} | ||
|
||
[TestMethod] | ||
public void Cleared() | ||
{ | ||
CollectionChangeAction action = default!; | ||
MyCollection strings = new() { UnitTestString }; | ||
strings.CollectionChanged += (sender, e) => action = e.Action; | ||
|
||
strings.Clear(); | ||
|
||
Assert.AreEqual(CollectionChangeAction.Clear, action); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
tests/BB84.NotificationsTests/NotifyCollectionBaseTests.Move.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using BB84.Notifications.Enumerators; | ||
|
||
namespace BB84.NotificationsTests; | ||
|
||
public sealed partial class NotifyCollectionBaseTests | ||
{ | ||
[TestMethod] | ||
public void Moving() | ||
{ | ||
CollectionChangeAction action = default!; | ||
int item = default; | ||
MyCollection strings = new() { "A", "B", "C" }; | ||
strings.CollectionChanging += (sender, e) => { item = (int)e.Item!; action = e.Action; }; | ||
|
||
strings.Move(0, 1); | ||
|
||
Assert.AreEqual(CollectionChangeAction.Move, action); | ||
Assert.AreEqual(0, item); | ||
} | ||
|
||
[TestMethod] | ||
public void Moved() | ||
{ | ||
CollectionChangeAction action = default!; | ||
int item = default; | ||
MyCollection strings = new() { "A", "B", "C" }; | ||
strings.CollectionChanged += (sender, e) => { item = (int)e.Item!; action = e.Action; }; | ||
|
||
strings.Move(0, 1); | ||
|
||
Assert.AreEqual(CollectionChangeAction.Move, action); | ||
Assert.AreEqual(1, item); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
tests/BB84.NotificationsTests/NotifyCollectionBaseTests.Remove.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using BB84.Notifications.Enumerators; | ||
|
||
namespace BB84.NotificationsTests; | ||
|
||
public sealed partial class NotifyCollectionBaseTests | ||
{ | ||
[TestMethod] | ||
public void Removing() | ||
{ | ||
CollectionChangeAction action = default!; | ||
string item = string.Empty; | ||
MyCollection strings = new() { UnitTestString }; | ||
strings.CollectionChanging += (sender, e) => { item = (string)e.Item!; action = e.Action; }; | ||
|
||
_ = strings.Remove(UnitTestString); | ||
|
||
Assert.AreEqual(CollectionChangeAction.Remove, action); | ||
Assert.AreEqual(UnitTestString, item); | ||
} | ||
|
||
[TestMethod] | ||
public void Removed() | ||
{ | ||
CollectionChangeAction action = default!; | ||
string item = string.Empty; | ||
MyCollection strings = new() { UnitTestString }; | ||
strings.CollectionChanged += (sender, e) => { item = (string)e.Item!; action = e.Action; }; | ||
|
||
_ = strings.Remove(UnitTestString); | ||
|
||
Assert.AreEqual(CollectionChangeAction.Remove, action); | ||
Assert.AreEqual(UnitTestString, item); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
tests/BB84.NotificationsTests/NotifyCollectionBaseTests.Replace.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using BB84.Notifications.Enumerators; | ||
|
||
namespace BB84.NotificationsTests; | ||
|
||
public sealed partial class NotifyCollectionBaseTests | ||
{ | ||
[TestMethod] | ||
public void Replacing() | ||
{ | ||
CollectionChangeAction action = default!; | ||
string item = string.Empty; | ||
MyCollection strings = new() { UnitTestString }; | ||
strings.CollectionChanging += (sender, e) => { item = (string)e.Item!; action = e.Action; }; | ||
|
||
strings.Update(UnitTestString, "UnitTest"); | ||
|
||
Assert.AreEqual(CollectionChangeAction.Replace, action); | ||
Assert.AreEqual(UnitTestString, item); | ||
} | ||
|
||
[TestMethod] | ||
public void Replaced() | ||
{ | ||
CollectionChangeAction action = default!; | ||
string item = string.Empty; | ||
MyCollection strings = new() { UnitTestString }; | ||
strings.CollectionChanged += (sender, e) => { item = (string)e.Item!; action = e.Action; }; | ||
|
||
strings.Update(UnitTestString, "UnitTest"); | ||
|
||
Assert.AreEqual(CollectionChangeAction.Replace, action); | ||
Assert.AreEqual("UnitTest", item); | ||
} | ||
} |
Oops, something went wrong.