Exemple #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);
        }
Exemple #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());
        }
Exemple #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());
        }
Exemple #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);
        }