@@ -30,6 +30,7 @@ public FileExtractFunctionTests()
3030 _fileExtractQueueClientMock = new Mock < IFileExtractQueueClient > ( ) ;
3131 _fileTransformQueueClientMock = new Mock < IFileTransformQueueClient > ( ) ;
3232 _blobStoreMock = new Mock < IMeshFilesBlobStore > ( ) ;
33+ _configurationMock = new Mock < IFileExtractFunctionConfiguration > ( ) ;
3334
3435 var options = new DbContextOptionsBuilder < ServiceLayerDbContext > ( )
3536 . UseInMemoryDatabase ( Guid . NewGuid ( ) . ToString ( ) )
@@ -56,15 +57,41 @@ public FileExtractFunctionTests()
5657 [ Fact ]
5758 public async Task Run_FileNotFound_ExitsSilently ( )
5859 {
60+ // Arrange
5961 var message = new FileExtractQueueMessage { FileId = "nonexistent-file" } ;
6062
61- var exception = await Assert . ThrowsAsync < InvalidOperationException > ( ( ) => _function . Run ( message ) ) ;
62- Assert . Equal ( "File not found" , exception . Message ) ;
63+ // Act
64+ await _function . Run ( message ) ;
65+
66+ // Assert
67+ _loggerMock . Verify (
68+ x => x . Log (
69+ LogLevel . Warning ,
70+ It . IsAny < EventId > ( ) ,
71+ It . Is < It . IsAnyType > ( ( v , t ) => v . ToString ( ) == $ "File with id: { message . FileId } not found in MeshFiles table.") ,
72+ null ,
73+ It . IsAny < Func < It . IsAnyType , Exception ? , string > > ( )
74+ ) , Times . Once ) ;
75+ _loggerMock . Verify (
76+ x => x . Log (
77+ LogLevel . Warning ,
78+ It . IsAny < EventId > ( ) ,
79+ It . Is < It . IsAnyType > ( ( v , t ) => v . ToString ( ) == "Exiting function." ) ,
80+ null ,
81+ It . IsAny < Func < It . IsAnyType , Exception ? , string > > ( )
82+ ) , Times . Once ) ;
83+
84+ Assert . Equal ( 0 , _dbContext . MeshFiles . Count ( ) ) ;
85+ _meshInboxServiceMock . Verify ( x => x . GetHeadMessageByIdAsync ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) , Times . Never ) ;
86+ _blobStoreMock . Verify ( x => x . UploadAsync ( It . IsAny < MeshFile > ( ) , It . IsAny < byte [ ] > ( ) ) , Times . Never ) ;
87+ _fileTransformQueueClientMock . Verify ( x => x . EnqueueFileTransformAsync ( It . IsAny < MeshFile > ( ) ) , Times . Never ) ;
88+ _fileTransformQueueClientMock . Verify ( x => x . SendToPoisonQueueAsync ( It . IsAny < FileTransformQueueMessage > ( ) ) , Times . Never ) ;
6389 }
6490
6591 [ Fact ]
6692 public async Task Run_FileInInvalidStatus_ExitsSilently ( )
6793 {
94+ // Arrange
6895 var file = new MeshFile
6996 {
7097 FileType = MeshFileType . NbssAppointmentEvents ,
@@ -78,8 +105,31 @@ public async Task Run_FileInInvalidStatus_ExitsSilently()
78105
79106 var message = new FileExtractQueueMessage { FileId = "file-1" } ;
80107
81- var exception = await Assert . ThrowsAsync < InvalidOperationException > ( ( ) => _function . Run ( message ) ) ;
82- Assert . Equal ( "File is not in expected status" , exception . Message ) ;
108+ // Act
109+ await _function . Run ( message ) ;
110+
111+ // Assert
112+ _loggerMock . Verify (
113+ x => x . Log (
114+ LogLevel . Warning ,
115+ It . IsAny < EventId > ( ) ,
116+ It . Is < It . IsAnyType > ( ( v , t ) => v . ToString ( ) . StartsWith ( $ "File with id: { message . FileId } found in MeshFiles table but is not suitable for extraction. Status: { file . Status } , LastUpdatedUtc:") ) ,
117+ null ,
118+ It . IsAny < Func < It . IsAnyType , Exception ? , string > > ( )
119+ ) , Times . Once ) ;
120+ _loggerMock . Verify (
121+ x => x . Log (
122+ LogLevel . Warning ,
123+ It . IsAny < EventId > ( ) ,
124+ It . Is < It . IsAnyType > ( ( v , t ) => v . ToString ( ) == "Exiting function." ) ,
125+ null ,
126+ It . IsAny < Func < It . IsAnyType , Exception ? , string > > ( )
127+ ) , Times . Once ) ;
128+
129+ _meshInboxServiceMock . Verify ( x => x . GetHeadMessageByIdAsync ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) , Times . Never ) ;
130+ _blobStoreMock . Verify ( x => x . UploadAsync ( It . IsAny < MeshFile > ( ) , It . IsAny < byte [ ] > ( ) ) , Times . Never ) ;
131+ _fileTransformQueueClientMock . Verify ( x => x . EnqueueFileTransformAsync ( It . IsAny < MeshFile > ( ) ) , Times . Never ) ;
132+ _fileTransformQueueClientMock . Verify ( x => x . SendToPoisonQueueAsync ( It . IsAny < FileTransformQueueMessage > ( ) ) , Times . Never ) ;
83133 }
84134
85135 [ Fact ]
0 commit comments