public void GivenCreateNotCalled_WhenSetupFooter_ThenThrowException() { using (var target = new StudentProfileExportFile()) { target.ExpectException <InvalidOperationException>(() => target.SetupFooter("whatever")); } }
public void GivenNoStream_WhenCreate_ThenThrowException() { using (var target = new StudentProfileExportFile()) { target.ExpectException <NotSupportedException>(() => target.Create()); } }
public void GivenNullStream_WhenCreate_ThenIsReadyTrue() { using (var target = new StudentProfileExportFile()) { target.ExpectException <ArgumentNullException>(() => target.Create(null)); } }
public void GivenNullColumnNames_WhenSetupColumnHeaders_ThenThrowException() { using (var target = new StudentProfileExportFile()) { target.ExpectException <ArgumentNullException>(() => target.SetupColumnHeaders(null)); } }
public void GivenCreateNotCalled_WhenSetupColumnHeaders_ThenThrowException() { using (var target = new StudentProfileExportFile()) { target.ExpectException <InvalidOperationException>(() => target.SetupColumnHeaders(new[] { "whatever" })); } }
public void GivenNullObjects_WhenFillData_ThenThrowException() { using (var target = new StudentProfileExportFile()) { target.ExpectException <ArgumentNullException>(() => target.FillData(null)); } }
public void GivenCreateNotCalled_WhenFillData_ThenThrowException() { using (var target = new StudentProfileExportFile()) { target.ExpectException <InvalidOperationException>(() => target.FillData(new List <IEnumerable <object> > { new[] { new object() } })); } }
public void GivenInvalidStream_WhenCreate_ThenThrowException() { using (Stream stream = new MemoryStream()) { using (var target = new StudentProfileExportFile()) { target.ExpectException <OpenXmlPackageException>(() => target.Create(stream)); } } }
public void GivenFooterText_AndFooterTextExceeds255Characters_WhenSetupFooter_ThenThrowException() { StringBuilder tooLong = new StringBuilder(); for (int i = 0; i < 256; i++) { tooLong.Append('a'); } byte[] templateData = File.ReadAllBytes(@"TestData\StudentProfileExportTemplate.xltx"); using (MemoryStream stream = new MemoryStream()) { stream.Write(templateData, 0, (int)templateData.Length); using (var target = new StudentProfileExportFile()) { target.Create(stream); target.ExpectException <ArgumentException>(() => target.SetupFooter(tooLong.ToString())); } } }