Ejemplo n.º 1
0
            public void GetFactoryShouldReturnFactoryWithRecordTypeAssignableToIResultRecord()
            {
                var factory = new[]
                {
                    RecordPropertyInfo.Create <string>("Name", 0)
                }.GetRecordFactory();

                factory.RecordType.Should().BeAssignableTo <IResultRecord>();
            }
Ejemplo n.º 2
0
        public void CreateRecordForSinglePropertyShouldWork()
        {
            var instance = ResultRecordBuilder.CreateRecord(
                RecordPropertyInfo.Create <int>("Count", 0)
                );
            var instanceType = instance.GetType();

            instanceType.GetProperties()
            .Should().HaveCount(1)
            .And.Subject.Single().ShouldBeEquivalentTo(new { Count = 0 }, opt => opt.ExcludingMissingMembers());
        }
Ejemplo n.º 3
0
        public void CreateRecordForTwoProperties()
        {
            var instance = ResultRecordBuilder.CreateRecord(
                RecordPropertyInfo.Create <int>("Count", 0),
                RecordPropertyInfo.Create <string>("Name", 1)
                );

            instance.ShouldBeEquivalentTo(
                new { Count = default(int), Name = default(string) },
                opt => opt.IncludingAllRuntimeProperties()
                );
        }
Ejemplo n.º 4
0
        public void CreateRecordCanBeCalledMultipleTimes()
        {
            var instance1 = ResultRecordBuilder.CreateRecord(
                RecordPropertyInfo.Create <int>("Count", 0),
                RecordPropertyInfo.Create <string>("Name", 1)
                );

            var instance2 = ResultRecordBuilder.CreateRecord(
                RecordPropertyInfo.Create <string>("FooString", 0),
                RecordPropertyInfo.Create <DateTime>("FooDate", 1),
                RecordPropertyInfo.Create <bool>("FooBool", 2)
                );
        }
Ejemplo n.º 5
0
        public void CsvWriteWriteHeaderShouldProducesExpectedHeader()
        {
            var instance = ResultRecordBuilder.CreateRecord(
                RecordPropertyInfo.Create<int>("Count", 0),
                RecordPropertyInfo.Create<string>("Name", 1),
                RecordPropertyInfo.Create<DateTime>("Date", 2)
            );

            using (var textWriter = new StringWriter())
            {
                using (var csvWriter = new CsvWriter(textWriter))
                {
                    csvWriter.Configuration.HasHeaderRecord = true;
                    csvWriter.WriteHeader(instance.GetType());
                    var lines = textWriter.ToString().Split(new []{Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
                    var header = lines[0];
                    header.Should().Be("Count,Name,Date");
                }
            }
        }