public void GenerateDocument_January2019_GeneratesTableWith9Columns()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();

            Document document = documentGenerator.GenerateDocument();

            int numberOfColumns = document.Sections[0].LastTable.Columns.Count;
            Assert.That(numberOfColumns, Is.EqualTo(9));
        }
        public void GenerateDocument_January2019_GeneratesParagraphWithDocumentTitle()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();

            Document document = documentGenerator.GenerateDocument();

            string content = ((Text)document.Sections[0].LastParagraph.Elements[0]).Content;
            Assert.That(content, Is.EqualTo("January 2019"));
        }
        public void GenerateDocument_January2019_GeneratesDocumentWithLandscapeSectionOrientation()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();

            Document document = documentGenerator.GenerateDocument();

            Orientation orientation = document.Sections[0].PageSetup.Orientation;
            Assert.That(orientation, Is.EqualTo(Orientation.Landscape));
        }
        public void GenerateDocument_January2019_GeneratesDocumentWithOneSection()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();

            Document document = documentGenerator.GenerateDocument();

            int numberOfSections = document.Sections.Count;
            Assert.That(numberOfSections, Is.EqualTo(1));
        }
        public void GenerateDocument_January2019_FirstColumnInFourthRowIsEqualTo4WithDot()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();

            Document document = documentGenerator.GenerateDocument();

            string content = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[4].Cells[0].Elements[0]).Elements[0]).Content;
            Assert.That(content, Is.EqualTo("4."));
        }
        public void GenerateDocument_January2019_SundayThe1stRowsColorIsCorrect()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();

            Document document = documentGenerator.GenerateDocument();

            Color backgroundColor = document.Sections[0].LastTable.Rows[1].Shading.Color;
            Assert.That(backgroundColor, Is.EqualTo(documentGenerator.DayOffBackgroundColor));
        }
        public void GenerateDocument_January2019_SecondColumnInThirtyFirstRowIsEqualToThursdayAbbreviation()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();

            Document document = documentGenerator.GenerateDocument();

            string content = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[31].Cells[1].Elements[0]).Elements[0]).Content;
            Assert.That(content, Is.EqualTo("Thu."));
        }
        public void GenerateDocument_January2019_GeneratesTable()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();

            Document document = documentGenerator.GenerateDocument();

            Table table = document.Sections[0].LastTable;
            Assert.That(table, Is.Not.Null);
        }
        public void GenerateDocument_January2019WithoutDocumentColors_SundayThe13thRowsColorIsEqualToZero()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();
            documentGenerator.EnableColors = false;

            Document document = documentGenerator.GenerateDocument();

            Color backgroundColor = document.Sections[0].LastTable.Rows[13].Shading.Color;
            Assert.That(backgroundColor.RGB, Is.EqualTo(0));
        }
        public void GenerateDocument_January2019_FourthFullnameInTheTableDoesNotExistAndThrowsAnException()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();

            Document document = documentGenerator.GenerateDocument();

            string content;
            TestDelegate getContent = () => content = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[0].Cells[6].Elements[0]).Elements[0]).Content;
            Assert.That(getContent, Throws.InstanceOf<ArgumentOutOfRangeException>());
        }
        public void GenerateDocument_January2019DisabledTableStretching_FirstRowsHeightIsEqualTo33()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();
            documentGenerator.EnableTableStretching = false;

            Document document = documentGenerator.GenerateDocument();

            var height = document.Sections[0].LastTable.Rows[0].Height;
            Assert.That(height.ToString(), Is.EqualTo("33"));
        }
        public void GenerateDocument_January2019DisabledSundaysTexts_CellsIndexThrowsException()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();
            documentGenerator.EnableSundaysTexts = false;
            Document document = documentGenerator.GenerateDocument();

            string content;
            TestDelegate getContent = () => content = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[20].Cells[2].Elements[0]).Elements[0]).Content;

            Assert.That(getContent, Throws.Exception);
        }
        public void GenerateDocument_January2019_ThirdFullnameInTheTableIsEqualToPassedOne()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();

            Document document = documentGenerator.GenerateDocument();

            string firstName = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[0].Cells[4].Elements[0]).Elements[0]).Content;
            string lastName = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[0].Cells[4].Elements[0]).Elements[2]).Content;
            Assert.That(firstName, Is.EqualTo("Ryan"));
            Assert.That(lastName, Is.EqualTo("Carroll"));
        }
        public void GenerateDocument_January2019_AllTuesdayThe1stColumnsContentAreEqualToNewYearsDayName()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();

            Document document = documentGenerator.GenerateDocument();

            string firstColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[1].Cells[2].Elements[0]).Elements[0]).Content;
            string secondColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[1].Cells[3].Elements[0]).Elements[0]).Content;
            string thirdColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[1].Cells[4].Elements[0]).Elements[0]).Content;
            string fourthColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[1].Cells[5].Elements[0]).Elements[0]).Content;
            string fifthColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[1].Cells[6].Elements[0]).Elements[0]).Content;
            string sixthColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[1].Cells[7].Elements[0]).Elements[0]).Content;
            string seventhColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[1].Cells[8].Elements[0]).Elements[0]).Content;
            List<string> columnsList = new List<string> { firstColumn, secondColumn, thirdColumn, fourthColumn, fifthColumn, sixthColumn, seventhColumn };
            Assert.That(columnsList, Is.All.EqualTo("NEW YEARS DAY"));
        }
        public void GenerateDocument_January2019DisabledHolidaysTexts_SundayThe6thAllColumnsAreEqualToSunday()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();
            documentGenerator.EnableHolidaysTexts = false;

            Document document = documentGenerator.GenerateDocument();

            string firstColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[2].Elements[0]).Elements[0]).Content;
            string secondColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[3].Elements[0]).Elements[0]).Content;
            string thirdColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[4].Elements[0]).Elements[0]).Content;
            string fourthColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[5].Elements[0]).Elements[0]).Content;
            string fifthColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[6].Elements[0]).Elements[0]).Content;
            string sixthColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[7].Elements[0]).Elements[0]).Content;
            string seventhColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[8].Elements[0]).Elements[0]).Content;
            List<string> columnsList = new List<string> { firstColumn, secondColumn, thirdColumn, fourthColumn, fifthColumn, sixthColumn, seventhColumn };
            Assert.That(columnsList, Is.All.EqualTo("SUNDAY"));
        }
        public void GenerateDocument_January2019_SundayThe6thEvenColumnsAreEqualToSundayNameAndOddColumnsAreEqualToEpiphanyName()
        {
            AttendanceListDocumentGenerator documentGenerator = GetAttendanceListDocumentGenerator();

            Document document = documentGenerator.GenerateDocument();

            string firstColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[2].Elements[0]).Elements[0]).Content;
            string secondColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[3].Elements[0]).Elements[0]).Content;
            string thirdColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[4].Elements[0]).Elements[0]).Content;
            string fourthColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[5].Elements[0]).Elements[0]).Content;
            string fifthColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[6].Elements[0]).Elements[0]).Content;
            string sixthColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[7].Elements[0]).Elements[0]).Content;
            string seventhColumn = ((Text)((Paragraph)document.Sections[0].LastTable.Rows[6].Cells[8].Elements[0]).Elements[0]).Content;
            List<string> sundayList = new List<string> { firstColumn, thirdColumn, fifthColumn, seventhColumn };
            List<string> epiphanyList = new List<string> { secondColumn, fourthColumn, sixthColumn };
            Assert.That(sundayList, Is.All.EqualTo("SUNDAY"));
            Assert.That(epiphanyList, Is.All.EqualTo("EPIPHANY"));
        }
Beispiel #17
0
        private void Generate()
        {
            IList <IPerson> people = GetPeopleList();

            // Generate data
            DaysOffData        daysOff  = new DaysOffData(Year);
            AttendanceListData listData = new AttendanceListData(daysOff, people, Month, Year);

            // Create document generator
            LocalizedNames localizedNames = new LocalizedNames();
            AttendanceListDocumentGenerator documentGenerator = new AttendanceListDocumentGenerator(listData, localizedNames);

            // Set document generator settings
            documentGenerator.EnableColors          = EnableColors;
            documentGenerator.EnableHolidaysTexts   = EnableHolidaysTexts;
            documentGenerator.EnableSundaysTexts    = EnableSundaysTexts;
            documentGenerator.EnableTableStretching = EnableTableStretching;

            // Generate a document
            Document document = documentGenerator.GenerateDocument();

            // Get directory path and filename
            DirectoryProvider directoryProvider = new DirectoryProvider(localizedNames);
            FilenameGenerator filenameGenerator = new FilenameGenerator(localizedNames, _dateTimeProvider);
            string            path     = directoryProvider.GetDocumentsDirectoryPath();
            string            filename = filenameGenerator.GeneratePdfDocumentFilename(listData);

            // Save document
            FileSaver fileSaver = new FileSaver();

            fileSaver.SavePdfDocument(document, path, filename);

            // And open it
            FileOpener fileOpener = new FileOpener();

            fileOpener.OpenFile(path, filename);

            SerializeSettings(directoryProvider, filenameGenerator, fileSaver);
        }