예제 #1
0
        public void SetFieldLength_Should_Let_DataTable_Null_When_It_Is_Null()
        {
            // Arrange
            DataTable dataTable     = new DataTable();
            int       dataTableHash = dataTable.GetHashCode();
            Header    header        = null;

            GenerateFiles generateFiles = new GenerateFiles(this.config, this.spreadsheet, this.fileSystem, this.outputWriter);

            // Act
            generateFiles.SetFieldLength(dataTable, header);

            // Assert
            dataTable.GetHashCode().Should().Be(dataTableHash);
        }
예제 #2
0
        public void SetFieldLength_Should_Let_DataTable_And_Null_When_There_Are_Null()
        {
            // Arrange
            DataTable dataTable = null;
            Header    header    = null;

            GenerateFiles generateFiles = new GenerateFiles(this.config, this.spreadsheet, this.fileSystem, this.outputWriter);

            // Act
            generateFiles.SetFieldLength(dataTable, header);

            // Assert
            dataTable.Should().BeNull();
            header.Should().BeNull();
        }
예제 #3
0
        public void SetFieldLength_Should_Set_The_Length_Followed_The_Field_Length()
        {
            // Arrange
            GenerateFiles generateFiles = new GenerateFiles(this.config, this.spreadsheet, this.fileSystem, this.outputWriter);

            DataTable dataTable = GetPeopleTest1();

            int    dataTableHash = dataTable.GetHashCode();
            Header header        = new Header
            {
                Fields = new List <Field>
                {
                    new Field
                    {
                        Column = 0,
                        Text   = "LastName",
                        Length = 0,
                        Row    = 0,
                        Type   = Enum.DatabaseEnum.TypeField.Text
                    },
                    new Field
                    {
                        Column = 1,
                        Text   = "FirstName",
                        Length = 0,
                        Row    = 0,
                        Type   = Enum.DatabaseEnum.TypeField.Text
                    },
                    new Field
                    {
                        Column = 2,
                        Text   = "Name",
                        Length = 4,
                        Row    = 0,
                        Type   = Enum.DatabaseEnum.TypeField.Text
                    },
                    new Field
                    {
                        Column = 3,
                        Text   = "DateOfBirth",
                        Length = 0,
                        Row    = 0,
                        Type   = Enum.DatabaseEnum.TypeField.Date
                    },
                    new Field
                    {
                        Column = 4,
                        Text   = "Salary",
                        Length = 0,
                        Row    = 0,
                        Type   = Enum.DatabaseEnum.TypeField.Number
                    }
                }
            };

            // Act
            generateFiles.SetFieldLength(dataTable, header);

            // Assert
            header.Should().NotBeNull();
            header.Fields.Find(f => f.Name == "LastName".ToLower()).Length.Should().Be(20);
            header.Fields.Find(f => f.Name == "FirstName".ToLower()).Length.Should().Be(30);
            header.Fields.Find(f => f.Name == "Name".ToLower()).Length.Should().Be(10);
            header.Fields.Find(f => f.Name == "DateOfBirth".ToLower()).Length.Should().Be(10);
            header.Fields.Find(f => f.Name == "Salary".ToLower()).Length.Should().Be(30);
        }