-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GetAsync tests and fix JsInteropCookieService split
The GetAsyncTests file was created to ensure correct handling of cookie values and values containing '='. The split logic in JsInteropCookieService was updated to consider only two parts when splitting with '=', preventing errors on cookies with '=' characters in values. Additionally, a new test was added to HttpContextCookieServiceTests to verify correct behavior when setting cookies with duplicate keys.
- Loading branch information
1 parent
c7e95a1
commit 8eb6d70
Showing
4 changed files
with
31 additions
and
12 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,29 @@ | ||
using BitzArt.Blazor.Cookies; | ||
using Microsoft.JSInterop; | ||
using Moq; | ||
|
||
namespace BitzArt.Blazor.Auth | ||
{ | ||
public class GetAsyncTests | ||
{ | ||
[Fact] | ||
public async Task GetAsyncShouldHandleValue() | ||
{ | ||
var jsRuntime = new Mock<IJSRuntime>(); | ||
jsRuntime.Setup(x => x.InvokeAsync<string>("eval", It.IsAny<object[]>())) | ||
.ReturnsAsync("token=value123; path=/"); | ||
var result = await new JsInteropCookieService(jsRuntime.Object).GetAsync("token"); | ||
Assert.Equal("value123", result?.Value); | ||
} | ||
|
||
[Fact] | ||
public async Task GetAsyncShouldHandleEqualsInValue() | ||
{ | ||
var jsRuntime = new Mock<IJSRuntime>(); | ||
jsRuntime.Setup(x => x.InvokeAsync<string>("eval", It.IsAny<object[]>())) | ||
.ReturnsAsync("token=value=123; path=/"); | ||
var result = await new JsInteropCookieService(jsRuntime.Object).GetAsync("token"); | ||
Assert.Equal("value=123", result?.Value); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.