Skip to content

Commit cb570ed

Browse files
committed
Add tests for unsupported caching types
1 parent cd23baf commit cb570ed

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Diff for: Gw2Sharp.Tests/WebApi/Caching/ArchiveCacheMethodTests.cs

+25
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,32 @@ public async Task LoadExistingArchiveTest()
9696
Assert.Equal(expiresAt, actualCache?.ExpiryTime);
9797
}
9898

99+
[Fact]
100+
public async Task GetsUnsupportedTypeFromArchiveTest()
101+
{
102+
const string CATEGORY = "category";
103+
const string ID = "id";
104+
var expiresAt = 1.Minutes().After(DateTime.Now);
105+
106+
// We need to store something valid first
107+
byte[] data = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
108+
await this.cacheMethod.SetAsync(CATEGORY, ID, data, expiresAt);
109+
110+
await this.cacheMethod.Invoking(x => x.TryGetAsync<object>(CATEGORY, ID))
111+
.Should().ThrowAsync<NotSupportedException>();
112+
}
113+
114+
[Fact]
115+
public async Task StoresUnsupportedTypeIntoArchiveTest()
116+
{
117+
const string CATEGORY = "category";
118+
const string ID = "id";
119+
var expiresAt = 1.Minutes().After(DateTime.Now);
99120

121+
object data = new object();
122+
await this.cacheMethod.Invoking(x => x.SetAsync(CATEGORY, ID, data, expiresAt))
123+
.Should().ThrowAsync<NotSupportedException>();
124+
}
100125

101126
public void Dispose()
102127
{

0 commit comments

Comments
 (0)