示例#1
0
        public void Should_Create_Null_Date_From_Nullable()
        {
            // arrange
            DateTime?date      = null;
            var      converter = new DynamoDateConverter();

            // act
            var entry = converter.ToEntry(date);

            // assert
            Assert.IsType <DynamoDBNull>(entry);
        }
示例#2
0
        public void Should_Create_Entry_From_DateTime()
        {
            // arrange
            var date      = new DateTime(2020, 1, 1, 12, 1, 1);
            var converter = new DynamoDateConverter();
            var expected  = "2020-01-01";

            // act
            var entry = converter.ToEntry(date);

            // assert
            Assert.Equal(expected, entry.AsString());
        }
示例#3
0
        public void Should_Treat_Date_As_Utc()
        {
            // arrange
            var date      = new DateTime(2020, 1, 2, 0, 0, 1, DateTimeKind.Utc);
            var converter = new DynamoDateConverter();
            var expected  = "2020-01-02";

            // act
            var entry = converter.ToEntry(date);

            // assert
            Assert.Equal(expected, entry.AsString());
        }
示例#4
0
        public void Should_Throw_If_Not_DateTime()
        {
            // arrange
            var value     = 1;
            var converter = new DynamoDateConverter();
            var expected  = @"The given value is not a DateTime nor a Nullable<DateTime>.
Parameter name: value";

            // act
            var exception = Assert.Throws <ArgumentException>(() => converter.ToEntry(value));

            // assert
            Assert.Equal(expected, exception.Message);
        }
示例#5
0
        public void Should_Create_DateTime_From_Entry()
        {
            // arrange
            DynamoDBEntry entry = new Primitive {
                Value = "2020-01-01"
            };
            var converter = new DynamoDateConverter();
            var expected  = new DateTime(2020, 1, 1);

            // act
            var date = converter.FromEntry(entry);

            // assert
            Assert.Equal(expected, date);
        }
示例#6
0
        public void Should_Return_DateTime_Minvalue_From_Null(string input)
        {
            // arrange
            DynamoDBEntry entry = new Primitive {
                Value = input
            };
            var converter = new DynamoDateConverter();
            var expected  = DateTime.MinValue;

            // act
            var date = converter.FromEntry(entry);

            // assert
            Assert.Equal(expected, date);
        }