コード例 #1
0
        public void ShouldImportDateTimeFieldFromDateColumn()
        {
            var result = new ImportManagerBuilder <ModelDateTimeProperty>()
                         .OpenFile(StreamTestFile.GetStreamTestFile(), VariablesModelDateTimeProperty.WorksheetName)
                         .Init()
                         .StartImportProcess();

            result.Should().NotBeNullOrEmpty();
            result.Count.Should().Be(2);
            result[0].BirthDay.Should().BeSameDateAs(new DateTime(1991, 08, 28));
            result[1].BirthDay.Should().BeSameDateAs(new DateTime(2021, 1, 1));

            StreamTestFile.CloseFile();
        }
コード例 #2
0
        public void ShouldImportDecimalFieldFromNumberColumn()
        {
            var result = new ImportManagerBuilder <ModelDecimalNullableProperty>()
                         .OpenFile(StreamTestFile.GetStreamTestFile(), VariablesModelDecimalNullableProperty.WorksheetName)
                         .Init()
                         .StartImportProcess();

            result.Should().NotBeNullOrEmpty();
            result.Count.Should().Be(2);
            result[0].Salary.Should().Be((decimal)12233.45);
            result[1].Salary.Should().BeNull();

            StreamTestFile.CloseFile();
        }
コード例 #3
0
        public void ShouldImportIntFieldFromBooleanColumn()
        {
            var result = new ImportManagerBuilder <ModelBoolNullableProperty>()
                         .OpenFile(StreamTestFile.GetStreamTestFile(), VariablesModelBoolNullableProperty.WorksheetName)
                         .Init()
                         .StartImportProcess();

            result.Should().NotBeNullOrEmpty();
            result.Count.Should().Be(2);
            result[0].Active.Should().BeTrue();
            result[1].Active.Should().BeNull();

            StreamTestFile.CloseFile();
        }
コード例 #4
0
        public void ShouldImportIntFieldFromNumberColumn()
        {
            var result = new ImportManagerBuilder <ModelStringProperty>()
                         .OpenFile(StreamTestFile.GetStreamTestFile(), VariablesModelStringProperty.WorksheetName)
                         .Init()
                         .StartImportProcess();

            result.Should().NotBeNullOrEmpty();
            result.Count.Should().Be(2);
            result[0].Name.Should().Be("Ruan");
            result[1].Name.Should().Be("");

            StreamTestFile.CloseFile();
        }