-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made some chages to InProcessMessageStore.
- Returns all messages if requested message id > max message id - Ensure multiple cleanup loops don't happen concurrently. - Removed GetAll(key) from IMessageStore. - Added unit tests
- Loading branch information
Showing
7 changed files
with
84 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace SignalR.Tests { | ||
public class InProcessMessageStoreTest { | ||
[Fact] | ||
public void GetAllSinceReturnsAllMessagesAfterIdOrderedById() { | ||
var store = new InProcessMessageStore(garbageCollectMessages: false); | ||
|
||
store.Save("a", "1").Wait(); | ||
store.Save("a", "2").Wait(); | ||
store.Save("a", "3").Wait(); | ||
|
||
var messages = store.GetAllSince("a", 1).Result.ToList(); | ||
Assert.Equal(2, messages.Count); | ||
Assert.Equal("2", messages[0].Value); | ||
Assert.Equal("3", messages[1].Value); | ||
} | ||
|
||
[Fact] | ||
public void GetAllSinceReturnsAllMessagesIfIdGreaterThanMaxId() { | ||
var store = new InProcessMessageStore(garbageCollectMessages: false); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
store.Save("a", i).Wait(); | ||
} | ||
|
||
var messages = store.GetAllSince("a", 100).Result.ToList(); | ||
Assert.Equal(10, messages.Count); | ||
for (int i = 0; i < 10; i++) { | ||
Assert.Equal(i, messages[i].Value); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void GetLastIdReturnsMaxMessageId() { | ||
var store = new InProcessMessageStore(garbageCollectMessages: false); | ||
|
||
store.Save("a", "1").Wait(); | ||
store.Save("a", "2").Wait(); | ||
store.Save("a", "3").Wait(); | ||
|
||
Assert.Equal(3, store.GetLastId().Result); | ||
} | ||
} | ||
} |
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
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