Exemple #1
0
            public void Visit(Date32Type type)
            {
                var builder = new Date32Array.Builder().Reserve(Length);
                var basis   = DateTimeOffset.UtcNow.AddDays(-Length);

                for (var i = 0; i < Length; i++)
                {
                    builder.Append(basis.AddDays(i));
                }

                Array = builder.Build();
            }
Exemple #2
0
            public void Visit(Date32Type type)
            {
                var builder = new Date32Array.Builder().Reserve(Length);

                // Length can be greater than the number of days since DateTime.MinValue.
                // Set a cap for how many days can be subtracted from now.
                int maxDays = Math.Min(Length, 100_000);
                var basis   = DateTimeOffset.UtcNow.AddDays(-maxDays);

                for (var i = 0; i < Length; i++)
                {
                    builder.Append(basis.AddDays(i % maxDays));
                }

                Array = builder.Build();
            }
Exemple #3
0
            public void AppendThenGetGivesNull()
            {
                // Arrange
                var builder = new Date32Array.Builder();

                // Act
                builder = builder.AppendNull();

                // Assert
                var array = builder.Build();

                Assert.Equal(1, array.Length);
                Assert.Null(array.GetDateTime(0));
                Assert.Null(array.GetDateTimeOffset(0));
                Assert.Null(array.GetValue(0));
            }
Exemple #4
0
            public void AppendGivesUtcDate(DateTimeOffset dateTimeOffset)
            {
                // Arrange
                var builder                = new Date32Array.Builder();
                var expectedDateTime       = dateTimeOffset.UtcDateTime.Date;
                var expectedDateTimeOffset = new DateTimeOffset(dateTimeOffset.UtcDateTime.Date, TimeSpan.Zero);
                int expectedValue          = (int)dateTimeOffset.UtcDateTime.Date.Subtract(new DateTime(1970, 1, 1)).TotalDays;

                // Act
                builder = builder.Append(dateTimeOffset);

                // Assert
                var array = builder.Build();

                Assert.Equal(1, array.Length);
                Assert.Equal(expectedDateTime, array.GetDateTime(0));
                Assert.Equal(expectedDateTimeOffset, array.GetDateTimeOffset(0));
                Assert.Equal(expectedValue, array.GetValue(0));
            }
Exemple #5
0
            public void AppendWithTimeGivesSameWithTimeIgnored(DateTime dateTime)
            {
                // Arrange
                var builder                = new Date32Array.Builder();
                var expectedDateTime       = dateTime.Date;
                var expectedDateTimeOffset =
                    new DateTimeOffset(DateTime.SpecifyKind(dateTime.Date, DateTimeKind.Unspecified), TimeSpan.Zero);
                int expectedValue = (int)dateTime.Date.Subtract(new DateTime(1970, 1, 1)).TotalDays;

                // Act
                builder = builder.Append(dateTime);

                // Assert
                var array = builder.Build();

                Assert.Equal(1, array.Length);
                Assert.Equal(expectedDateTime, array.GetDateTime(0));
                Assert.Equal(expectedDateTimeOffset, array.GetDateTimeOffset(0));
                Assert.Equal(expectedValue, array.GetValue(0));
            }