Exemplo n.º 1
0
            public void Given()
            {
                var dataToFormat = new List <DataExport>
                {
                    new DataExport {
                        FirstName = "dave", LastName = "jones", Gender = "m"
                    },
                    new DataExport {
                        FirstName = "joe", LastName = "schmoe", Gender = "m"
                    },
                    new DataExport {
                        FirstName = "betty", LastName = "ann", Gender = "f"
                    }
                };

                var fixedWidthFormatter = new FixedWidthFormatter <DataExport>();

                fixedWidthFormatter.SetPositionFor(x => x.FirstName).From(1).To(6);
                fixedWidthFormatter.SetPositionFor(x => x.LastName).From(7).To(14);
                fixedWidthFormatter.InsertBlank().From(15).To(16);
                fixedWidthFormatter.SetPositionFor(x => x.Gender).From(17).To(19);

                expected = "dave  jones     m  \r\njoe   schmoe    m  \r\nbetty ann       f  \r\n";

                actual = fixedWidthFormatter.Format(dataToFormat);
            }
Exemplo n.º 2
0
            public void ThrowsInvalidOperationException()
            {
                var fixedWidthFormatter = new FixedWidthFormatter <DataExport>();

                fixedWidthFormatter.SetPositionFor(x => x.FirstName).From(1).To(4);
                fixedWidthFormatter.SetPositionFor(x => x.LastName).From(2).To(6);
                fixedWidthFormatter.Format(new List <DataExport>());
            }
Exemplo n.º 3
0
            public void Given()
            {
                var dataToFormat = new List <DataExport>
                {
                    new DataExport {
                        FirstName = "dave", LastName = null, Gender = "m"
                    }
                };

                var fixedWidthFormatter = new FixedWidthFormatter <DataExport>();

                fixedWidthFormatter.SetPositionFor(x => x.FirstName).From(1).To(10);
                fixedWidthFormatter.SetPositionFor(x => x.LastName).From(11).To(20);
                fixedWidthFormatter.SetPositionFor(x => x.Gender).From(21).To(25);

                expected = "dave                m    \r\n";
                actual   = fixedWidthFormatter.Format(dataToFormat);
            }