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