Exemplo n.º 1
0
        public void WithSupportedFieldsFrom_CopiedSupportedFields()
        {
            FieldSet originalFieldSet = new FieldSet.Builder { SecondOfMinute = sampleField }.Build();
            DateTimeField newField = new PreciseDateTimeField(DateTimeFieldType.SecondOfMinute, PreciseDurationField.Seconds, PreciseDurationField.Minutes);

            FieldSet newFieldSet = new FieldSet.Builder { SecondOfMinute = newField }.WithSupportedFieldsFrom(originalFieldSet).Build();
            // SecondOfMinute is supported in originalFieldSet, so the field is copied over
            Assert.AreSame(originalFieldSet.SecondOfMinute, newFieldSet.SecondOfMinute);
        }
 public void FieldType()
 {
     PreciseDateTimeField field = new PreciseDateTimeField(DateTimeFieldType.MinuteOfHour, new FakeDurationField(1, true),
                                                           new FakeDurationField(60, true));
     Assert.AreEqual(DateTimeFieldType.MinuteOfHour, field.FieldType);
 }
Exemplo n.º 3
0
        public void WithSupportedFieldsFrom_DoesNotCopyUnsupportedFields()
        {
            FieldSet originalFieldSet = new FieldSet.Builder { SecondOfMinute = sampleField }.Build();
            Assert.IsFalse(originalFieldSet.SecondOfDay.IsSupported);

            DateTimeField newField = new PreciseDateTimeField(DateTimeFieldType.SecondOfMinute, PreciseDurationField.Seconds, PreciseDurationField.Minutes);

            FieldSet newFieldSet = new FieldSet.Builder { SecondOfDay = newField }.WithSupportedFieldsFrom(originalFieldSet).Build();
            // SecondOfDay isn't supported in originalFieldSet, so the property we set is kept
            Assert.AreSame(newField, newFieldSet.SecondOfDay);
        }