// ASSERT public override void Assert <TItem>(TItem expected, TItem actual) { string[] expected_SectionNames = (expected as object[])[0] as string[]; string[][][] expected_Entries = (expected as object[])[1] as string[][][]; string[] expected_RawLines = (expected as object[])[2] as string[]; string[] actual_SectionNames = (actual as object[])[0] as string[]; string[][][] actual_Entries = (actual as object[])[1] as string[][][]; string[] actual_RawLines = (actual as object[])[2] as string[]; // Print Blank Line Console.WriteLine(); // Print Number of Section Names and Sections (Entries) Console.WriteLine($"Number of Section Names (Sections) : Expected = {expected_SectionNames.Length}, Actual = {actual_SectionNames.Length}"); Console.WriteLine($"Number of Sections (Entries): Expected = {expected_Entries.Length}, Actual = {actual_Entries.Length}"); // ASSERT Number of Section Names and Sections (Entries); and these should be the same number Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(expected_SectionNames.Length, actual_SectionNames.Length); Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(expected_Entries.Length, actual_Entries.Length); Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(actual_SectionNames.Length, actual_Entries.Length); // for Sections for (int i = 0; i < expected_SectionNames.Length; i++) { // ASSERT Section PrivateProfileSectionTests.AssertSection( expected_SectionNames[i], expected_Entries[i], null, actual_SectionNames[i], actual_Entries[i], null); } // Print Number of Raw Lines Console.WriteLine($"Number of Raw Lines: Expected = {expected_RawLines.Length}, Actual = {actual_RawLines.Length}"); // ASSERT Number of Raw Lines Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(expected_RawLines.Length, actual_RawLines.Length); // for Raw Lines for (int i = 0; i < expected_RawLines.Length; i++) { // Print Raw Line Console.WriteLine($"Raw Lines[{i}]: Expected\t= \"{expected_RawLines[i]}\""); Console.WriteLine($"Raw Lines[{i}]: Actual\t= \"{actual_RawLines[i]}\""); // ASSERT Raw Line Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(expected_RawLines[i], actual_RawLines[i]); } }
// ARRANGE public override void Arrange(out object[] expected) { // BASE base.Arrange(out expected); // NEW Section this.Section = new PrivateProfileSection(this.BeforeRawLines); // Print Entries before change Console.WriteLine("Before Change:"); PrivateProfileSectionTests.PrintSection(this.Section); Console.WriteLine(); }
// ASSERT public override void Assert <TItem>(TItem expected, TItem actual) { string expectedSectionName = (expected as object[])[0] as string; string[][] expectedEntries = (expected as object[])[1] as string[][]; string[] expectedRawLines = (expected as object[])[2] as string[]; string actualSectionName = (actual as object[])[0] as string; string[][] actualEntries = (actual as object[])[1] as string[][]; string[] actualRawLines = (actual as object[])[2] as string[]; // ASSERT Section PrivateProfileSectionTests.AssertSection( expectedSectionName, expectedEntries, expectedRawLines, actualSectionName, actualEntries, actualRawLines); }