コード例 #1
0
        public void Conversion_from_BSON_does_not_swallow_invalid_type()
        {
            // Arrange
            var converter = new TimeSpanTypeConverter();
            var obj = new Object();

            // Act/Assert
            Assert.Throws<InvalidCastException>(() => converter.ConvertFromBson(obj));
        }
コード例 #2
0
        public void Converts_a_long_to_Timespan()
        {
            // Arrange
            var converter = new TimeSpanTypeConverter();
            const long value = 4234234234;

            // Act
            var result = converter.ConvertFromBson(value);

            // Assert
            Assert.True(result is TimeSpan);
        }
コード例 #3
0
        public void Conversion_from_BSON_produces_correct_value()
        {
            // Arrange
            var converter = new TimeSpanTypeConverter();
            const long value = 65435432112312;
            var timeSpan = TimeSpan.FromTicks(value);

            // Act
            var result = (TimeSpan)converter.ConvertFromBson(value);

            // Assert
            Assert.Equal(timeSpan, result);
        }