Skip to content

Commit 60d491c

Browse files
author
Changjian Wang
committed
TEST: Enhance console output for analysis operation verification in Sample02_AnalyzeUrl
1 parent 356cbce commit 60d491c

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

sdk/contentunderstanding/Azure.AI.ContentUnderstanding/tests/samples/Sample02_AnalyzeUrl.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,23 @@ public async Task AnalyzeUrlAsync()
4747
Assert.IsNotNull(operation.GetRawResponse(), "Analysis operation should have a raw response");
4848
Assert.IsTrue(operation.GetRawResponse().Status >= 200 && operation.GetRawResponse().Status < 300,
4949
$"Response status should be successful, but was {operation.GetRawResponse().Status}");
50-
Console.WriteLine("? Analysis operation properties verified");
50+
Console.WriteLine(" Analysis operation properties verified");
5151
Assert.IsNotNull(result, "Analysis result should not be null");
5252
Assert.IsNotNull(result.Contents, "Result contents should not be null");
53-
Console.WriteLine($"? Analysis result contains {result.Contents?.Count ?? 0} content(s)");
53+
Console.WriteLine($" Analysis result contains {result.Contents?.Count ?? 0} content(s)");
5454
#endregion
5555

5656
#region Snippet:ContentUnderstandingExtractMarkdownFromUrl
5757
// A PDF file has only one content element even if it contains multiple pages
58-
MediaContent? content = null;
58+
MediaContent? content = null;
5959
if (result.Contents == null || result.Contents.Count == 0)
6060
{
6161
Console.WriteLine("(No content returned from analysis)");
6262
}
6363
else
6464
{
6565
content = result.Contents.First();
66-
if (!string.IsNullOrEmpty(content.Markdown))
66+
if (! string.IsNullOrEmpty(content.Markdown))
6767
{
6868
Console.WriteLine(content.Markdown);
6969
}
@@ -86,14 +86,14 @@ public async Task AnalyzeUrlAsync()
8686
Assert.IsTrue(mediaContent.Markdown.Length > 0, "Markdown content should not be empty");
8787
Assert.IsFalse(string.IsNullOrWhiteSpace(mediaContent.Markdown),
8888
"Markdown content should not be just whitespace");
89-
Console.WriteLine($"? Markdown content extracted successfully ({mediaContent.Markdown.Length} characters)");
89+
Console.WriteLine($" Markdown content extracted successfully ({mediaContent.Markdown.Length} characters)");
9090
}
9191
#endregion
9292

9393
// Check if this is document content to access document-specific properties
9494
if (content is DocumentContent documentContent)
9595
{
96-
Console.WriteLine($"Document type: {documentContent.MimeType ?? "(unknown)"}");
96+
Console.WriteLine($"Document type: {documentContent.MimeType ?? "(unknown)"}");
9797
Console.WriteLine($"Start page: {documentContent.StartPageNumber}");
9898
Console.WriteLine($"End page: {documentContent.EndPageNumber}");
9999
Console.WriteLine($"Total pages: {documentContent.EndPageNumber - documentContent.StartPageNumber + 1}");
@@ -131,23 +131,23 @@ public async Task AnalyzeUrlAsync()
131131
Assert.IsNotNull(docContent.MimeType, "MIME type should not be null");
132132
Assert.IsFalse(string.IsNullOrWhiteSpace(docContent.MimeType), "MIME type should not be empty");
133133
Assert.AreEqual("application/pdf", docContent.MimeType, "MIME type should be application/pdf");
134-
Console.WriteLine($"? MIME type verified: {docContent.MimeType}");
134+
Console.WriteLine($" MIME type verified: {docContent.MimeType}");
135135

136136
// Validate page numbers
137137
Assert.IsTrue(docContent.StartPageNumber >= 1, "Start page should be >= 1");
138138
Assert.IsTrue(docContent.EndPageNumber >= docContent.StartPageNumber,
139139
"End page should be >= start page");
140140
int totalPages = docContent.EndPageNumber - docContent.StartPageNumber + 1;
141141
Assert.IsTrue(totalPages > 0, "Total pages should be positive");
142-
Console.WriteLine($"? Page range verified: {docContent.StartPageNumber} to {docContent.EndPageNumber} ({totalPages} pages)");
142+
Console.WriteLine($" Page range verified: {docContent.StartPageNumber} to {docContent.EndPageNumber} ({totalPages} pages)");
143143

144144
// Validate pages collection
145145
if (docContent.Pages != null && docContent.Pages.Count > 0)
146146
{
147147
Assert.IsTrue(docContent.Pages.Count > 0, "Pages collection should not be empty when not null");
148148
Assert.AreEqual(totalPages, docContent.Pages.Count,
149149
"Pages collection count should match calculated total pages");
150-
Console.WriteLine($"? Pages collection verified: {docContent.Pages.Count} pages");
150+
Console.WriteLine($" Pages collection verified: {docContent.Pages.Count} pages");
151151

152152
// Track page numbers to ensure they're sequential and unique
153153
var pageNumbers = new System.Collections.Generic.HashSet<int>();
@@ -166,19 +166,19 @@ public async Task AnalyzeUrlAsync()
166166
Assert.IsTrue(pageNumbers.Add(page.PageNumber),
167167
$"Page number {page.PageNumber} appears multiple times");
168168

169-
Console.WriteLine($" ? Page {page.PageNumber}: {page.Width} x {page.Height} {docContent.Unit?.ToString() ?? "units"}");
169+
Console.WriteLine($" Page {page.PageNumber}: {page.Width} x {page.Height} {docContent.Unit?.ToString() ?? "units"}");
170170
}
171171
}
172172
else
173173
{
174-
Console.WriteLine("?? No pages collection available in document content");
174+
Console.WriteLine("⚠️ No pages collection available in document content");
175175
}
176176

177177
// Validate tables collection
178178
if (docContent.Tables != null && docContent.Tables.Count > 0)
179179
{
180180
Assert.IsTrue(docContent.Tables.Count > 0, "Tables collection should not be empty when not null");
181-
Console.WriteLine($"? Tables collection verified: {docContent.Tables.Count} tables");
181+
Console.WriteLine($" Tables collection verified: {docContent.Tables.Count} tables");
182182

183183
int tableCounter = 1;
184184
foreach (var table in docContent.Tables)
@@ -202,21 +202,21 @@ public async Task AnalyzeUrlAsync()
202202
}
203203
}
204204

205-
Console.WriteLine($" ? Table {tableCounter}: {table.RowCount} rows x {table.ColumnCount} columns" +
205+
Console.WriteLine($" Table {tableCounter}: {table.RowCount} rows x {table.ColumnCount} columns" +
206206
(table.Cells != null ? $" ({table.Cells.Count} cells)" : ""));
207207
tableCounter++;
208208
}
209209
}
210210
else
211211
{
212-
Console.WriteLine("?? No tables found in document content");
212+
Console.WriteLine("⚠️ No tables found in document content");
213213
}
214214

215-
Console.WriteLine("? All document properties validated successfully");
215+
Console.WriteLine(" All document properties validated successfully");
216216
}
217217
else
218218
{
219-
Console.WriteLine("?? Content is not DocumentContent type, skipping document-specific validations");
219+
Console.WriteLine("⚠️ Content is not DocumentContent type, skipping document-specific validations");
220220
Assert.Warn("Expected DocumentContent but got " + content?.GetType().Name);
221221
}
222222
#endregion

0 commit comments

Comments
 (0)