File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
test/AzureOpenAIProxy.ApiApp.Tests/Repositories Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 99using Microsoft . Extensions . DependencyInjection ;
1010
1111using NSubstitute ;
12+ using NSubstitute . ExceptionExtensions ;
1213
1314namespace AzureOpenAIProxy . ApiApp . Tests . Repositories ;
1415
@@ -90,4 +91,24 @@ await tableClient.Received(1).AddEntityAsync(Arg.Is<AdminResourceDetails>(x =>
9091 ) ) ;
9192 result . Should ( ) . BeEquivalentTo ( resourceDetails ) ;
9293 }
94+
95+ [ Fact ]
96+ public async Task Given_Failure_In_Add_Entity_When_CreateResource_Invoked_Then_It_Should_Throw_Exception ( )
97+ {
98+ // Arrange
99+ var settings = Substitute . For < StorageAccountSettings > ( ) ;
100+ var tableServiceClient = Substitute . For < TableServiceClient > ( ) ;
101+ var tableClient = Substitute . For < TableClient > ( ) ;
102+ tableServiceClient . GetTableClient ( Arg . Any < string > ( ) ) . Returns ( tableClient ) ;
103+
104+ var repository = new AdminResourceRepository ( tableServiceClient , settings ) ;
105+
106+ tableClient . AddEntityAsync ( Arg . Any < AdminResourceDetails > ( ) ) . ThrowsAsync ( new InvalidOperationException ( ) ) ;
107+
108+ // Act
109+ Func < Task > func = ( ) => repository . CreateResource ( new AdminResourceDetails ( ) ) ;
110+
111+ // Assert
112+ await func . Should ( ) . ThrowAsync < InvalidOperationException > ( ) ;
113+ }
93114}
You can’t perform that action at this time.
0 commit comments