public void Write_Reallocates_When_Length_Exceeds_Slack_And_PreventReallocation_Is_False() { var headers = new Dictionary <string, int>() { { "one", 0 }, { "two", 1 }, { "three", 2 } }; var line = new LazyCsvLine("1,2,3", headers, 0, false); var ex1 = Record.Exception(() => line[0] = "11"); var ex2 = Record.Exception(() => line[1] = "22"); var ex3 = Record.Exception(() => line[2] = "33"); Assert.Null(ex1); Assert.Null(ex2); Assert.Null(ex3); Assert.Equal("11,22,33", line.ToString()); Assert.Equal(0, line.Slack); }
public void Write_Leaves_Slack_When_Length_Shrinks() { var headers = new Dictionary <string, int>() { { "one", 0 }, { "two", 1 }, { "three", 2 } }; var line = new LazyCsvLine("11,22,33", headers, 0, false); var ex1 = Record.Exception(() => line[0] = "1"); var ex2 = Record.Exception(() => line[1] = "2"); var ex3 = Record.Exception(() => line[2] = "3"); Assert.Null(ex1); Assert.Null(ex2); Assert.Null(ex3); Assert.Equal("1,2,3", line.ToString()); Assert.Equal(3, line.Slack); }
public void Write_Leaves_Slack_2() { var headers = new Dictionary <string, int>() { { "one", 0 }, { "two", 1 }, { "three", 2 } }; // length = 147 var line = new LazyCsvLine("Lorem ipsum dolor sit amet consectetur adipiscing elit.,Nunc a massa sit amet augue lacinia lacinia.,Aliquam scelerisque placerat turpis ut mollis.", headers, 0, false); var ex1 = Record.Exception(() => line[0] = "1"); var ex2 = Record.Exception(() => line[1] = "2"); var ex3 = Record.Exception(() => line[2] = "3"); Assert.Null(ex1); Assert.Null(ex2); Assert.Null(ex3); Assert.Equal("1,2,3", line.ToString()); // length = 5 Assert.Equal(142, line.Slack); // 147 - 5 }
public void Write_Reallocates_When_Length_Exceeds_Slack_And_PreventReallocation_Is_False2() { var headers = new Dictionary <string, int>() { { "one", 0 }, { "two", 1 }, { "three", 2 } }; var line = new LazyCsvLine("1,2,3", headers, 0, false); var ex1 = Record.Exception(() => line[0] = "Lorem ipsum dolor sit amet consectetur adipiscing elit."); var ex2 = Record.Exception(() => line[1] = "Nunc a massa sit amet augue lacinia lacinia."); var ex3 = Record.Exception(() => line[2] = "Aliquam scelerisque placerat turpis ut mollis."); Assert.Null(ex1); Assert.Null(ex2); Assert.Null(ex3); Assert.Equal("Lorem ipsum dolor sit amet consectetur adipiscing elit.,Nunc a massa sit amet augue lacinia lacinia.,Aliquam scelerisque placerat turpis ut mollis.", line.ToString()); Assert.Equal(0, line.Slack); }