Skip to content

Commit 30922cd

Browse files
Copilotkbeaugrand
andcommitted
Address code review feedback - improve delimiter tests
Co-authored-by: kbeaugrand <9513635+kbeaugrand@users.noreply.github.com>
1 parent 5dc68a2 commit 30922cd

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

src/IoTHub.Portal.Tests.Unit/Server/Managers/ExportManagerTests.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,12 @@ public void ExportDeviceListShouldUseCommaDelimiterNotSemicolon()
459459
using var reader = new StreamReader(fileStream);
460460
var content = reader.ReadToEnd();
461461

462-
// Assert - Should contain commas as delimiters, not semicolons
463-
_ = content.Should().Contain(",", "CSV should use comma delimiter");
464-
_ = content.Should().NotContain(";", "CSV should not use semicolon delimiter");
465-
466-
// Verify that header fields are properly comma-separated
462+
// Assert - Verify header is comma-separated by parsing it
467463
var lines = content.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);
468464
var headerFields = lines[0].Split(',');
465+
466+
// Should be able to parse the header with comma delimiter
467+
_ = headerFields.Length.Should().BeGreaterThan(1, "CSV header should have multiple comma-separated fields");
469468
_ = headerFields.Should().Contain("Id");
470469
_ = headerFields.Should().Contain("Name");
471470
_ = headerFields.Should().Contain("ModelId");
@@ -496,12 +495,12 @@ public void ExportTemplateFileShouldUseCommaDelimiterNotSemicolon()
496495
using var reader = new StreamReader(fileStream);
497496
var content = reader.ReadToEnd();
498497

499-
// Assert - Should contain commas as delimiters, not semicolons
500-
_ = content.Should().Contain(",", "CSV template should use comma delimiter");
501-
_ = content.Should().NotContain(";", "CSV template should not use semicolon delimiter");
502-
503-
// Verify that header fields are properly comma-separated
504-
var headerFields = content.TrimEnd().Split(',');
498+
// Assert - Verify header is comma-separated by parsing it
499+
var lines = content.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);
500+
var headerFields = lines[0].Split(',');
501+
502+
// Should be able to parse the header with comma delimiter
503+
_ = headerFields.Length.Should().BeGreaterThan(1, "CSV template header should have multiple comma-separated fields");
505504
_ = headerFields.Should().Contain("Id");
506505
_ = headerFields.Should().Contain("Name");
507506
_ = headerFields.Should().Contain("ModelId");

0 commit comments

Comments
 (0)