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()); }
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() ); }
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) ); }
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"); } } }