1
+ using System . Net ;
2
+ using az_appservice_dotnet . services ;
3
+ using Microsoft . Azure . Cosmos ;
4
+
5
+ namespace az_appservice_dotnet . xUnit . services . v1 . CosmoDbProcessingStateService ;
6
+
7
+ [ Collection ( "CosmosContainer collection" ) ]
8
+ public class CreateInitialStateTest
9
+ {
10
+ readonly ContainerFixture _containerFixture ;
11
+
12
+ public CreateInitialStateTest ( ContainerFixture containerFixture )
13
+ {
14
+ _containerFixture = containerFixture ;
15
+ }
16
+
17
+ [ Fact ]
18
+ public async Task Should_Create ( )
19
+ {
20
+ // Arrange
21
+ var sut = _containerFixture . GetService ( ) ;
22
+ var taskId = 777 ;
23
+ var fileName = "file1.txt" ;
24
+ // Act
25
+ var actual = await sut . CreateInitialState ( taskId , fileName ) ;
26
+ // Assert
27
+ Assert . IsType < IProcessingStateService . State > ( actual ) ;
28
+ Assert . Equal ( ( int ) taskId , ( int ) actual . TaskId ) ;
29
+ Assert . Equal ( fileName , actual . FileName ) ;
30
+
31
+ var readResponse = await _containerFixture . Container . ReadItemAsync < az_appservice_dotnet . services . v1 . CosmoDbProcessingStateService . CosmosState > ( actual . Id ,
32
+ new PartitionKey ( actual . TaskId ) ) ;
33
+ Assert . Equal ( HttpStatusCode . OK , readResponse . StatusCode ) ;
34
+ var read = readResponse . Resource ;
35
+ Assert . IsType < az_appservice_dotnet . services . v1 . CosmoDbProcessingStateService . CosmosState > ( read ) ;
36
+ Assert . Equal ( actual . Id , read . Id ) ;
37
+ Assert . Equal ( ( int ) actual . TaskId , read . TaskId ) ;
38
+ Assert . Equal ( actual . Status , read . Status ) ;
39
+ Assert . Equal ( actual . OriginalFileUrl , read . OriginalFileUrl ) ;
40
+ Assert . Equal ( actual . ProcessedFileUrl , read . ProcessedFileUrl ) ;
41
+ Assert . Equal ( actual . FileName , read . FileName ) ;
42
+ }
43
+
44
+ }
0 commit comments