public void FormatValueFromDirectory_Null_ReturnsNull() { //prepare _mappingArguments.PropertyType = typeof(Collection <DateTime>); var propertyMapping = new DateCollectionPropertyMapping <DateCollectionPropertyMappingTest>(_mappingArguments, null); //act var value = propertyMapping.FormatValueFromDirectory(null, "dn"); //assert value.Should().Be.Null(); }
public void FormatValueFromDirectory_NullableFileTimeDateTimeCollection_ReturnsDateTimesCollection() { //prepare var dates = new Collection <DateTime?>(new DateTime?[] { DateTime.Now, DateTime.Now.AddDays(1) }); _mappingArguments.PropertyType = typeof(Collection <DateTime?>); var propertyMapping = new DateCollectionPropertyMapping <DateCollectionPropertyMappingTest>(_mappingArguments, null); //act var value = propertyMapping.FormatValueFromDirectory(new DirectoryAttribute("names", dates.Select(d => d.Value.ToFileTime().ToString()).ToArray()), "dn"); //assert value.As <Collection <DateTime?> >().Should().Have.SameSequenceAs(dates); }
public void FormatValueFromDirectory_SingleDateTime_ReturnsAsDateTimeCollection() { //prepare var now = DateTime.Now; _mappingArguments.PropertyType = typeof(Collection <DateTime>); var propertyMapping = new DateCollectionPropertyMapping <DateCollectionPropertyMappingTest>(_mappingArguments, null); //act var value = propertyMapping.FormatValueFromDirectory(new DirectoryAttribute("name", now.ToFileTime().ToString()), "dn"); //assert value.As <Collection <DateTime> >().Should().Contain(now); }
public void FormatValueFromDirectory_DateTimeCollection_ReturnsDateTimesCollection() { //prepare var now = DateTime.Now; var tomorrow = now.AddDays(1); var dates = new Collection <DateTime>(new[] { new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second), new DateTime(tomorrow.Year, tomorrow.Month, tomorrow.Day, tomorrow.Hour, tomorrow.Minute, tomorrow.Second) }); _mappingArguments.PropertyType = typeof(Collection <DateTime>); var propertyMapping = new DateCollectionPropertyMapping <DateCollectionPropertyMappingTest>(_mappingArguments, "yyyyMMddHHmmss.0Z"); //act var value = propertyMapping.FormatValueFromDirectory(new DirectoryAttribute("names", dates.Select(d => d.FormatLdapDateTime("yyyyMMddHHmmss.0Z")).ToArray()), "dn"); //assert value.As <Collection <DateTime> >().Should().Have.SameSequenceAs(dates); }