File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
src/Microsoft.Agents.AI.A2A
tests/Microsoft.Agents.AI.A2A.UnitTests Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,10 @@ protected sealed override ValueTask<AgentSession> CreateSessionCoreAsync(Cancell
6363 /// <param name="contextId">The context id to continue.</param>
6464 /// <returns>A value task representing the asynchronous operation. The task result contains a new <see cref="AgentSession"/> instance.</returns>
6565 public ValueTask < AgentSession > CreateSessionAsync ( string contextId )
66- => new ( new A2AAgentSession ( ) { ContextId = contextId } ) ;
66+ {
67+ _ = Throw . IfNullOrWhitespace ( contextId ) ;
68+ return new ( new A2AAgentSession ( ) { ContextId = contextId } ) ;
69+ }
6770
6871 /// <summary>
6972 /// Get a new <see cref="AgentSession"/> instance using an existing context id and task id, to resume that conversation from a specific task.
@@ -72,7 +75,11 @@ public ValueTask<AgentSession> CreateSessionAsync(string contextId)
7275 /// <param name="taskId">The task id to resume from.</param>
7376 /// <returns>A value task representing the asynchronous operation. The task result contains a new <see cref="AgentSession"/> instance.</returns>
7477 public ValueTask < AgentSession > CreateSessionAsync ( string contextId , string taskId )
75- => new ( new A2AAgentSession ( ) { ContextId = contextId , TaskId = taskId } ) ;
78+ {
79+ _ = Throw . IfNullOrWhitespace ( contextId ) ;
80+ _ = Throw . IfNullOrWhitespace ( taskId ) ;
81+ return new ( new A2AAgentSession ( ) { ContextId = contextId , TaskId = taskId } ) ;
82+ }
7683
7784 /// <inheritdoc/>
7885 protected override ValueTask < JsonElement > SerializeSessionCoreAsync ( AgentSession session , JsonSerializerOptions ? jsonSerializerOptions = null , CancellationToken cancellationToken = default )
Original file line number Diff line number Diff line change @@ -1199,7 +1199,7 @@ public async Task CreateSessionAsync_WithContextIdAndTaskId_CreatesSessionWithBo
11991199 public async Task CreateSessionAsync_WithInvalidContextId_ThrowsArgumentExceptionAsync ( string ? contextId )
12001200 {
12011201 // Act & Assert
1202- await Assert . ThrowsAsync < ArgumentException > ( async ( ) =>
1202+ await Assert . ThrowsAnyAsync < ArgumentException > ( async ( ) =>
12031203 await this . _agent . CreateSessionAsync ( contextId ! ) ) ;
12041204 }
12051205
@@ -1218,7 +1218,7 @@ public async Task CreateSessionAsync_WithInvalidContextIdAndValidTaskId_ThrowsAr
12181218 const string TaskId = "valid-task-id" ;
12191219
12201220 // Act & Assert
1221- await Assert . ThrowsAsync < ArgumentException > ( async ( ) =>
1221+ await Assert . ThrowsAnyAsync < ArgumentException > ( async ( ) =>
12221222 await this . _agent . CreateSessionAsync ( contextId ! , TaskId ) ) ;
12231223 }
12241224
@@ -1237,7 +1237,7 @@ public async Task CreateSessionAsync_WithValidContextIdAndInvalidTaskId_ThrowsAr
12371237 const string ContextId = "valid-context-id" ;
12381238
12391239 // Act & Assert
1240- await Assert . ThrowsAsync < ArgumentException > ( async ( ) =>
1240+ await Assert . ThrowsAnyAsync < ArgumentException > ( async ( ) =>
12411241 await this . _agent . CreateSessionAsync ( ContextId , taskId ! ) ) ;
12421242 }
12431243 #endregion
You can’t perform that action at this time.
0 commit comments