public void TestDRMapperSingleRow()
        {
            Stopwatch stopwatch;
            TestData  result;
            var       inMemoryData = Builder <TestData> .CreateListOfSize(1)
                                     .TheFirst(1)
                                     .With(c =>
            {
                c.Id        = 1337;
                c.FirstName = "Foo";
                c.LastName  = "Bar";
                return(c);
            })
                                     .Build();

            using (var dataReader = ObjectReader.Create(inMemoryData))
            {
                stopwatch = new Stopwatch();
                stopwatch.Start();
                result = DRMapper.ParseRecord <TestData>(dataReader);
            }

            stopwatch.Stop();
            _output.WriteLine($"Elapsed: {stopwatch.Elapsed}");
            result.Id.ShouldEqual(1337);
            result.FirstName.ShouldEqual("Foo");
            result.LastName.ShouldEqual("Bar");
        }
示例#2
0
        public void TestDRMapperSingleRowNull()
        {
            // fake data columns map to WrongTestData class
            var fakeData = new List <TestData>();

            // Put the test data into a datareader to parse it back out into test data using reflection.
            var dataReader = ObjectReader.Create(fakeData);
            var result     = DRMapper.ParseRecord <TestData>(dataReader);

            result.ShouldBeNull();
        }
        public void TestDRMapperCaseInsensitive()
        {
            TestData result;
            var      inMemoryData = Builder <TestDataUpperCase> .CreateListOfSize(1).Build();

            using (var dataReader = ObjectReader.Create(inMemoryData))
            {
                result = DRMapper.ParseRecord <TestData>(dataReader);
            }

            result.Id.ShouldEqual(1);
            result.FirstName.ShouldEqual("FirstName1", StringComparer.CurrentCultureIgnoreCase);
            result.LastName.ShouldEqual("LastName1", StringComparer.CurrentCultureIgnoreCase);
        }
示例#4
0
        public void TestDataReaderWithBadFieldNames()
        {
            // fake data columns map to WrongTestData class
            var fakeData = Builder <TestData> .CreateListOfSize(100).Build().ToList();

            // Put the test data into a datareader to parse it back out into test data using reflection.
            var dataReader = ObjectReader.Create(fakeData);

            // What do we expect to do if the DR doesn't have a record for this field?
            Assert.Throws <Exception>(() =>
            {
                // Attempt to map data to "TestData" class.
                var results = DRMapper.ParseList <WrongTestDto>(dataReader);
            });
        }
        public void TestDataReaderWithReflection()
        {
            // Put the test data into a datareader to parse it back out into test data using reflection.
            Stopwatch       stopwatch;
            List <TestData> results;
            var             inMemoryData = Builder <TestData> .CreateListOfSize(1000).Build().ToList();

            inMemoryData.First().Id.ShouldEqual(1);
            inMemoryData[899].Id.ShouldEqual(900);
            using (var dataReader = ObjectReader.Create(inMemoryData))
            {
                stopwatch = new Stopwatch();
                stopwatch.Start();

                results = DRMapper.ParseList <TestData>(dataReader);
            }
            stopwatch.Stop();
            _output.WriteLine($"Elapsed: {stopwatch.Elapsed}");
            var nineHundredth = results[899];

            nineHundredth.Id.ShouldEqual(900);
            nineHundredth.FirstName.ShouldEqual(inMemoryData[899].FirstName);
        }