コード例 #1
0
        public void PullsEmptyStringForEmpty()
        {
            // Arrange
            string[] headerrow = { "ReportName" };
            ICsvRowActivator <J139Report> workload = CreateSut <J139Report>(headerrow);

            string[] valuerow = { "" };

            // Act
            J139Report report = workload.CreateFromRow(valuerow);

            // Assert
            Assert.AreEqual("", report.ReportName);
        }
コード例 #2
0
        public void CanJustPullSingleField()
        {
            // Arrange
            string[] headerrow = { "Weight" };
            ICsvRowActivator <J139Report> workload = CreateSut <J139Report>(headerrow);

            string[] valuerow = { "3.14" };

            // Act
            J139Report report = workload.CreateFromRow(valuerow);

            // Assert
            Assert.AreEqual(0, report.ClientId);
            Assert.AreEqual(DateTime.MinValue, report.BirthDate);
            Assert.AreEqual(3.14, report.Weight);
            Assert.AreEqual(null, report.ReportName);
        }
コード例 #3
0
        public void CanReorderFields()
        {
            // Arrange
            string[] headerrow = { "ReportName", "Weight", "BirthDate", "ClientId" };
            ICsvRowActivator <J139Report> workload = CreateSut <J139Report>(headerrow);

            string[] valuerow = { "J139", "3.14", "5/3/2013", "156" };

            // Act
            J139Report report = workload.CreateFromRow(valuerow);

            // Assert
            Assert.AreEqual(156, report.ClientId);
            Assert.AreEqual(new DateTime(2013, 5, 3), report.BirthDate);
            Assert.AreEqual(3.14, report.Weight);
            Assert.AreEqual("J139", report.ReportName);
        }
コード例 #4
0
        public void CreateTestFile()
        {
            Fixture    fixture    = new Fixture();
            J139Report testReport = fixture.CreateAnonymous <J139Report>();

            using (StreamWriter writer = new StreamWriter(testCsvFilePath, false, Encoding.UTF8, 4096))
            {
                writer.WriteLine("ClientId,BirthDate,Weight,ReportName");
                for (int i = 0; i < rowcount; i++)
                {
                    writer.WriteLine(string.Format("{0},{1},{2},{3}",
                                                   testReport.ClientId,
                                                   testReport.BirthDate.ToString("MM/dd/yy"),
                                                   testReport.Weight,
                                                   testReport.ReportName)
                                     );
                }
                writer.Flush();
            }
        }
コード例 #5
0
        public void PerformanceTestBulk()
        {
            // Arrange
            string[] headerrow = { "ClientId", "BirthDate", "Weight", "ReportName" };
            ICsvRowActivator <J139Report> workload = CreateSut <J139Report>(headerrow);

            string[] valuerow = { "156", "5/3/2013", "3.14", "J139" };

            // Act

            int max = 1000000;

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            for (int i = 0; i < max; i++)
            {
                J139Report report = workload.CreateFromRow(valuerow);
            }
            TimeSpan endTime = stopwatch.Elapsed;

            Console.Write(max + " runs took " + endTime.Milliseconds + "ms");
        }