コード例 #1
0
        public void Conversion_to_BSON_does_not_swallow_invalid_type()
        {
            // Arrange
            var converter = new TimeSpanTypeConverter();
            const int integer = 5;

            // Act/Assert
            Assert.Throws<InvalidCastException>(() => converter.ConvertToBson(integer));
        }
コード例 #2
0
        public void Conversion_to_BSON_produces_correct_value()
        {
            // Arrange
            var converter = new TimeSpanTypeConverter();
            var timeSpan = new TimeSpan(8, 5, 3);

            // Act
            var result = (long)converter.ConvertToBson(timeSpan);

            // Assert
            Assert.Equal(timeSpan.Ticks, result);
        }
コード例 #3
0
        public void Converts_TimeSpan_to_a_long()
        {
            // Arrange
            var converter = new TimeSpanTypeConverter();
            var timeSpan = new TimeSpan(8, 5, 3);

            // Act
            var result = converter.ConvertToBson(timeSpan);

            // Assert
            Assert.True(result is long);
        }