1
+ using System . Net ;
2
+
3
+ using AzureOpenAIProxy . AppHost . Tests . Fixtures ;
4
+
5
+ using FluentAssertions ;
6
+
7
+ namespace AzureOpenAIProxy . AppHost . Tests . PlaygroundApp . Pages ;
8
+
9
+ public class AdminUpdateEventPageTests ( AspireAppHostFixture host ) : IClassFixture < AspireAppHostFixture >
10
+ {
11
+ [ Fact ]
12
+ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_OK ( )
13
+ {
14
+ // Arrange
15
+ using var httpClient = host . App ! . CreateHttpClient ( "playgroundapp" ) ;
16
+ await host . ResourceNotificationService . WaitForResourceAsync ( "playgroundapp" , KnownResourceStates . Running ) . WaitAsync ( TimeSpan . FromSeconds ( 30 ) ) ;
17
+
18
+ var eventId = Guid . NewGuid ( ) ;
19
+ var expectedUrl = $ "/admin/events/edit/{ eventId } ";
20
+
21
+ // Act
22
+ var response = await httpClient . GetAsync ( expectedUrl ) ;
23
+
24
+ // Assert
25
+ response . StatusCode . Should ( ) . Be ( HttpStatusCode . OK ) ;
26
+ }
27
+
28
+ [ Theory ]
29
+ [ InlineData ( "_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css" ) ]
30
+ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_CSS_Elements ( string expected )
31
+ {
32
+ // Arrange
33
+ using var httpClient = host . App ! . CreateHttpClient ( "playgroundapp" ) ;
34
+ await host . ResourceNotificationService . WaitForResourceAsync ( "playgroundapp" , KnownResourceStates . Running ) . WaitAsync ( TimeSpan . FromSeconds ( 30 ) ) ;
35
+
36
+ var eventId = Guid . NewGuid ( ) ;
37
+ var expectedUrl = $ "/admin/events/edit/{ eventId } ";
38
+
39
+ // Act
40
+ var html = await httpClient . GetStringAsync ( expectedUrl ) ;
41
+
42
+ // Assert
43
+ html . Should ( ) . Contain ( expected ) ;
44
+ }
45
+
46
+ [ Theory ]
47
+ [ InlineData ( "_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.lib.module.js" ) ]
48
+ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_JavaScript_Elements ( string expected )
49
+ {
50
+ // Arrange
51
+ using var httpClient = host . App ! . CreateHttpClient ( "playgroundapp" ) ;
52
+ await host . ResourceNotificationService . WaitForResourceAsync ( "playgroundapp" , KnownResourceStates . Running ) . WaitAsync ( TimeSpan . FromSeconds ( 30 ) ) ;
53
+
54
+ var eventId = Guid . NewGuid ( ) ;
55
+ var expectedUrl = $ "/admin/events/edit/{ eventId } ";
56
+
57
+ // Act
58
+ var html = await httpClient . GetStringAsync ( expectedUrl ) ;
59
+
60
+ // Assert
61
+ html . Should ( ) . Contain ( expected ) ;
62
+ }
63
+
64
+ [ Theory ]
65
+ [ InlineData ( "<div class=\" fluent-tooltip-provider\" style=\" display: fixed;\" ></div>" ) ]
66
+ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_HTML_Elements ( string expected )
67
+ {
68
+ // Arrange
69
+ using var httpClient = host . App ! . CreateHttpClient ( "playgroundapp" ) ;
70
+ await host . ResourceNotificationService . WaitForResourceAsync ( "playgroundapp" , KnownResourceStates . Running ) . WaitAsync ( TimeSpan . FromSeconds ( 30 ) ) ;
71
+
72
+ var eventId = Guid . NewGuid ( ) ;
73
+ var expectedUrl = $ "/admin/events/edit/{ eventId } ";
74
+
75
+ // Act
76
+ var html = await httpClient . GetStringAsync ( expectedUrl ) ;
77
+
78
+ // Assert
79
+ html . Should ( ) . Contain ( expected ) ;
80
+ }
81
+ }
0 commit comments