コード例 #1
0
        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();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }