示例#1
0
 public void GivenCreateNotCalled_WhenSetupFooter_ThenThrowException()
 {
     using (var target = new StudentProfileExportFile())
     {
         target.ExpectException <InvalidOperationException>(() => target.SetupFooter("whatever"));
     }
 }
示例#2
0
 public void GivenNoStream_WhenCreate_ThenThrowException()
 {
     using (var target = new StudentProfileExportFile())
     {
         target.ExpectException <NotSupportedException>(() => target.Create());
     }
 }
示例#3
0
 public void GivenNullStream_WhenCreate_ThenIsReadyTrue()
 {
     using (var target = new StudentProfileExportFile())
     {
         target.ExpectException <ArgumentNullException>(() => target.Create(null));
     }
 }
示例#4
0
 public void GivenNullColumnNames_WhenSetupColumnHeaders_ThenThrowException()
 {
     using (var target = new StudentProfileExportFile())
     {
         target.ExpectException <ArgumentNullException>(() => target.SetupColumnHeaders(null));
     }
 }
示例#5
0
 public void GivenCreateNotCalled_WhenSetupColumnHeaders_ThenThrowException()
 {
     using (var target = new StudentProfileExportFile())
     {
         target.ExpectException <InvalidOperationException>(() => target.SetupColumnHeaders(new[] { "whatever" }));
     }
 }
示例#6
0
 public void GivenNullObjects_WhenFillData_ThenThrowException()
 {
     using (var target = new StudentProfileExportFile())
     {
         target.ExpectException <ArgumentNullException>(() => target.FillData(null));
     }
 }
示例#7
0
 public void GivenCreateNotCalled_WhenFillData_ThenThrowException()
 {
     using (var target = new StudentProfileExportFile())
     {
         target.ExpectException <InvalidOperationException>(() => target.FillData(new List <IEnumerable <object> > {
             new[] { new object() }
         }));
     }
 }
示例#8
0
 public void GivenInvalidStream_WhenCreate_ThenThrowException()
 {
     using (Stream stream = new MemoryStream())
     {
         using (var target = new StudentProfileExportFile())
         {
             target.ExpectException <OpenXmlPackageException>(() => target.Create(stream));
         }
     }
 }
示例#9
0
        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()));
                }
            }
        }