Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
760e17b
Updated ISessionManager and SessionManager with timeout and cancellat…
luizbicalhoagl May 1, 2024
d54e552
`Refactor SessionManager and StateManager for improved session handling`
luizbicalhoagl May 1, 2024
911eb96
Refactor SessionManagerTests and remove certain test methods
luizbicalhoagl May 1, 2024
2b35219
Refactor SessionManager and update related tests
luizbicalhoagl May 2, 2024
d648d77
Merge branch 'main' into main
luizfbicalho May 3, 2024
33a0c17
`Convert SaveState to async in StateManager.cs`
luizbicalhoagl May 3, 2024
8e4617b
Merge branch 'main' of https://github.com/luizfbicalho/csla
luizbicalhoagl May 3, 2024
74ffc4c
`Update packages, refactor code, add tests, and remove project`
luizbicalhoagl May 3, 2024
ce84444
Updated SessionManager and its tests for async operations and better …
luizbicalhoagl May 4, 2024
73e9986
Subject: Refactored test methods and updated session retrieval
luizbicalhoagl May 4, 2024
5f59d4a
Refactor variable names to follow C# naming convention
luizbicalhoagl May 4, 2024
d9201aa
Merge branch 'main' into main
rockfordlhotka May 6, 2024
b6c01b9
Switch from Moq to NSubstitute in Csla.Blazor.WebAssembly.Tests
luizbicalhoagl May 7, 2024
76c6b75
Merge branch 'main' of https://github.com/luizfbicalho/csla
luizbicalhoagl May 7, 2024
57c3c5b
Merge branch 'main' into main
luizfbicalho May 7, 2024
98bc9e4
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 11, 2024
0eb640f
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 16, 2024
2b5ed27
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 18, 2024
72454d8
Merge branch 'main' of https://github.com/luizfbicalho/csla
luizbicalhoagl May 19, 2024
97ddc29
Refactored code for readability and modified deserialization process
luizbicalhoagl May 19, 2024
410d2ce
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 21, 2024
df149e3
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 21, 2024
4db5841
merge from main
luizbicalhoagl May 21, 2024
712a854
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 24, 2024
a926603
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 25, 2024
26873f2
merge from main
luizbicalhoagl May 25, 2024
8e4822a
Merge branch 'main' into feature/RemoveOnDeserialized
luizfbicalho May 26, 2024
c792c48
Merge branch 'main' into feature/RemoveOnDeserialized
rockfordlhotka Jun 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor variable names to follow C# naming convention
Updated variable names `_SessionManager` and `SessionValue` to `_sessionManager` and `_sessionValue` respectively, to adhere to the common C# naming convention for private fields. All instances of these variables in the code, including in the `Initialize()`, `Deserialize()`, `RetrieveSession()`, `SendSession()`, and `GetCachedSession()` methods, as well as in test assertions, have been updated accordingly.
  • Loading branch information
luizbicalhoagl committed May 4, 2024
commit 5f59d4a50f8c6d9f6827520d87caf8df176f4d1e
44 changes: 22 additions & 22 deletions Source/Csla.Blazor.WebAssembly.Tests/SessionManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace Csla.Test.State
[TestClass]
public class SessionManagerTests
{
private SessionManager _SessionManager;
private SessionMessage SessionValue;
private SessionManager _sessionManager;
private SessionMessage _sessionValue;

[TestInitialize]
public void Initialize()
Expand All @@ -35,7 +35,7 @@ public void Initialize()
// Mock IServiceProvider
mockServiceProvider.Setup(x => x.GetService(typeof(AuthenticationStateProvider))).Returns(mockAuthStateProvider.Object);

SessionValue = new SessionMessage
_sessionValue = new SessionMessage
{
// Set properties here
// For example:
Expand All @@ -46,7 +46,7 @@ public void Initialize()
// Mock ISerializationFormatter
var mockFormatter = new Mock<ISerializationFormatter>();
mockFormatter.Setup(x => x.Serialize(It.IsAny<Stream>(), It.IsAny<object>()));
mockFormatter.Setup(x => x.Deserialize(It.IsAny<Stream>())).Returns(SessionValue);
mockFormatter.Setup(x => x.Deserialize(It.IsAny<Stream>())).Returns(_sessionValue);

// Mock IServiceProvider
mockServiceProvider.Setup(x => x.GetService(typeof(Csla.Serialization.Mobile.MobileFormatter))).Returns(mockFormatter.Object);
Expand Down Expand Up @@ -77,7 +77,7 @@ public void Initialize()
var _applicationContext = new ApplicationContext(mockApplicationContextAccessor.Object);


_SessionManager = new SessionManager(_applicationContext, GetHttpClient(SessionValue, _applicationContext), new BlazorWebAssemblyConfigurationOptions { SyncContextWithServer = true });
_sessionManager = new SessionManager(_applicationContext, GetHttpClient(_sessionValue, _applicationContext), new BlazorWebAssemblyConfigurationOptions { SyncContextWithServer = true });
}

private static HttpClient GetHttpClient(SessionMessage session, ApplicationContext _applicationContext)
Expand Down Expand Up @@ -131,85 +131,85 @@ private static byte[] GetSession(SessionMessage session, ApplicationContext _app
public async Task RetrieveSession_WithTimeoutValue_ShouldNotThrowException()
{
var timeout = TimeSpan.FromHours(1);
var session = await _SessionManager.RetrieveSession(timeout);
Assert.AreEqual(session, SessionValue.Session);
var session = await _sessionManager.RetrieveSession(timeout);
Assert.AreEqual(session, _sessionValue.Session);
}

[TestMethod]
public async Task RetrieveSession_WithZeroTimeout_ShouldThrowTimeoutException()
{
var timeout = TimeSpan.Zero;
await Assert.ThrowsExceptionAsync<TimeoutException>(() => _SessionManager.RetrieveSession(timeout));
await Assert.ThrowsExceptionAsync<TimeoutException>(() => _sessionManager.RetrieveSession(timeout));
}

[TestMethod]
public async Task RetrieveSession_WithValidCancellationToken_ShouldNotThrowException()
{
var cts = new CancellationTokenSource();
var session = await _SessionManager.RetrieveSession(cts.Token);
Assert.AreEqual(session, SessionValue.Session);
var session = await _sessionManager.RetrieveSession(cts.Token);
Assert.AreEqual(session, _sessionValue.Session);
}

[TestMethod]
public async Task RetrieveSession_WithCancelledCancellationToken_ShouldThrowTaskCanceledException()
{
var cts = new CancellationTokenSource();
cts.Cancel();
await Assert.ThrowsExceptionAsync<TaskCanceledException>(() => _SessionManager.RetrieveSession(cts.Token));
await Assert.ThrowsExceptionAsync<TaskCanceledException>(() => _sessionManager.RetrieveSession(cts.Token));
}

[TestMethod]
public async Task SendSession_WithTimeoutValue_ShouldNotThrowException()
{
await _SessionManager.RetrieveSession(TimeSpan.FromHours(1));
await _sessionManager.RetrieveSession(TimeSpan.FromHours(1));

var timeout = TimeSpan.FromHours(1);
await _SessionManager.SendSession(timeout);
await _sessionManager.SendSession(timeout);
Assert.IsTrue(true);
}

[TestMethod]
public async Task SendSession_WithZeroTimeout_ShouldThrowTimeoutException()
{
await _SessionManager.RetrieveSession(TimeSpan.FromHours(1));
await _sessionManager.RetrieveSession(TimeSpan.FromHours(1));

var timeout = TimeSpan.Zero;
await Assert.ThrowsExceptionAsync<TimeoutException>(() => _SessionManager.SendSession(timeout));
await Assert.ThrowsExceptionAsync<TimeoutException>(() => _sessionManager.SendSession(timeout));
}

[TestMethod]
public async Task SendSession_WithValidCancellationToken_ShouldNotThrowException()
{
await _SessionManager.RetrieveSession(TimeSpan.FromHours(1));
await _sessionManager.RetrieveSession(TimeSpan.FromHours(1));

var cts = new CancellationTokenSource();
await _SessionManager.SendSession(cts.Token);
await _sessionManager.SendSession(cts.Token);
Assert.IsTrue(true);
}

[TestMethod]
public async Task SendSession_WithCancelledCancellationToken_ShouldThrowTaskCanceledException()
{
await _SessionManager.RetrieveSession(TimeSpan.FromHours(1));
await _sessionManager.RetrieveSession(TimeSpan.FromHours(1));

var cts = new CancellationTokenSource();
cts.Cancel();
await Assert.ThrowsExceptionAsync<TaskCanceledException>(() => _SessionManager.SendSession(cts.Token));
await Assert.ThrowsExceptionAsync<TaskCanceledException>(() => _sessionManager.SendSession(cts.Token));
}


[TestMethod]
public async Task RetrieveCachedSessionSession()
{
await _SessionManager.RetrieveSession(TimeSpan.FromHours(1));
await _sessionManager.RetrieveSession(TimeSpan.FromHours(1));

var session = _SessionManager.GetCachedSession();
var session = _sessionManager.GetCachedSession();
Assert.IsNotNull(session);
}
[TestMethod]
public void RetrieveNullCachedSessionSession()
{
var session = _SessionManager.GetCachedSession();
var session = _sessionManager.GetCachedSession();
Assert.IsNull(session);
}
}
Expand Down