@@ -8,13 +8,12 @@ namespace Tests.CodeOfChaos.Extensions.AspNetCore.EventCallbacks;
88// Code
99// ---------------------------------------------------------------------------------------------------------------------
1010public class EventCallbackDebouncerTests {
11- private readonly EventCallbackFactory _factory = new ( ) ;
1211
1312 [ Test ]
1413 public async Task DefaultDebounceMs_ShouldBe100 ( ) {
1514 // Arrange
1615 int callCount = 0 ;
17- EventCallback callback = _factory . Create ( this , callback : ( ) => {
16+ EventCallback callback = EventCallback . Factory . Create ( this , callback : ( ) => {
1817 callCount ++ ;
1918 return Task . CompletedTask ;
2019 } ) ;
@@ -32,7 +31,7 @@ public async Task DefaultDebounceMs_ShouldBe100() {
3231 public async Task CustomDebounceMs_ShouldRespectSpecifiedTime ( ) {
3332 // Arrange
3433 int callCount = 0 ;
35- EventCallback callback = _factory . Create ( this , callback : ( ) => {
34+ EventCallback callback = EventCallback . Factory . Create ( this , callback : ( ) => {
3635 callCount ++ ;
3736 return Task . CompletedTask ;
3837 } ) ;
@@ -56,7 +55,7 @@ public async Task CustomDebounceMs_ShouldRespectSpecifiedTime() {
5655 public async Task MultipleInvocations_ShouldDebounce ( ) {
5756 // Arrange
5857 int callCount = 0 ;
59- EventCallback callback = _factory . Create ( this , callback : ( ) => {
58+ EventCallback callback = EventCallback . Factory . Create ( this , callback : ( ) => {
6059 callCount ++ ;
6160 return Task . CompletedTask ;
6261 } ) ;
@@ -76,7 +75,7 @@ public async Task MultipleInvocations_ShouldDebounce() {
7675 public async Task ConcurrentInvocations_ShouldBeThreadSafe ( ) {
7776 // Arrange
7877 int callCount = 0 ;
79- EventCallback callback = _factory . Create ( this , callback : ( ) => {
78+ EventCallback callback = EventCallback . Factory . Create ( this , callback : ( ) => {
8079 callCount ++ ;
8180 return Task . CompletedTask ;
8281 } ) ;
@@ -97,7 +96,7 @@ public async Task ConcurrentInvocations_ShouldBeThreadSafe() {
9796 [ Test ]
9897 public async Task AfterDispose_ShouldThrowObjectDisposedException ( ) {
9998 // Arrange
100- EventCallback callback = _factory . Create ( this , callback : ( ) => Task . CompletedTask ) ;
99+ EventCallback callback = EventCallback . Factory . Create ( this , callback : ( ) => Task . CompletedTask ) ;
101100 var debouncer = new EventCallbackDebouncer ( callback ) ;
102101
103102 // Act
@@ -111,7 +110,7 @@ await Assert.ThrowsAsync<ObjectDisposedException>(async () =>
111110 [ Test ]
112111 public async Task MultipleDispose_ShouldBeIdempotent ( ) {
113112 // Arrange
114- EventCallback callback = _factory . Create ( this , callback : ( ) => Task . CompletedTask ) ;
113+ EventCallback callback = EventCallback . Factory . Create ( this , callback : ( ) => Task . CompletedTask ) ;
115114 var debouncer = new EventCallbackDebouncer ( callback ) ;
116115
117116 // Act & Assert
@@ -123,15 +122,15 @@ public async Task MultipleDispose_ShouldBeIdempotent() {
123122 public async Task InvocationDuringDebounce_ShouldCancelPrevious ( ) {
124123 // Arrange
125124 var executionTimes = new List < DateTime > ( ) ;
126- EventCallback callback = _factory . Create ( this , callback : ( ) => {
125+ EventCallback callback = EventCallback . Factory . Create ( this , callback : ( ) => {
127126 executionTimes . Add ( DateTime . UtcNow ) ;
128127 return Task . CompletedTask ;
129128 } ) ;
130129
131130 // Act
132131 await using var debouncer = new EventCallbackDebouncer ( callback ) ;
133132 await debouncer . InvokeDebouncedAsync ( ) ;
134- await Task . Delay ( 50 ) ; // Wait half the debounced time
133+ await Task . Delay ( 50 ) ; // Wait half the debounced time
135134 await debouncer . InvokeDebouncedAsync ( ) ;
136135 await Task . Delay ( 150 ) ;
137136
0 commit comments