| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using Xunit.Abstractions;
- namespace UnitTests_Parallelizable.ApplicationTests.RunnableTests;
- /// <summary>
- /// Tests for RunnableSessionToken class.
- /// </summary>
- public class RunnableSessionTokenTests (ITestOutputHelper output)
- {
- private readonly ITestOutputHelper _output = output;
- [Fact]
- public void RunnableSessionToken_Constructor_SetsRunnable ()
- {
- // Arrange
- Runnable<int> runnable = new ();
- // Act
- RunnableSessionToken token = new (runnable);
- // Assert
- Assert.NotNull (token.Runnable);
- Assert.Same (runnable, token.Runnable);
- }
- [Fact]
- public void RunnableSessionToken_Runnable_CanBeSetToNull ()
- {
- // Arrange
- Runnable<int> runnable = new ();
- RunnableSessionToken token = new (runnable);
- // Act
- token.Runnable = null;
- // Assert
- Assert.Null (token.Runnable);
- }
- [Fact]
- public void RunnableSessionToken_Dispose_ThrowsIfRunnableNotNull ()
- {
- // Arrange
- Runnable<int> runnable = new ();
- RunnableSessionToken token = new (runnable);
- // Act & Assert
- Assert.Throws<InvalidOperationException> (() => token.Dispose ());
- }
- [Fact]
- public void RunnableSessionToken_Dispose_SucceedsIfRunnableIsNull ()
- {
- // Arrange
- Runnable<int> runnable = new ();
- RunnableSessionToken token = new (runnable);
- token.Runnable = null;
- // Act & Assert - should not throw
- token.Dispose ();
- }
- }
|