示例#1
0
    public void Is_Not_Leap_Year_Returns_False(int year)
    {
        // Arrange

        // Act
        var result = DateTimeInt.IsLeapYear(year);

        // Assert
        Assert.False(result);
    }
示例#2
0
    public void From_Null_Or_Empty_String_Returns_Zeroes(string input)
    {
        // Arrange

        // Act
        var result = new DateTimeInt(input);

        // Assert
        Assert.Equal("000000000000", result.ToString());
    }
示例#3
0
    public void Valid_Returns_True()
    {
        // Arrange
        var input = new DateTimeInt(2020, 1, 2, 3, 4);

        // Act
        var(valid, _) = input.IsValidDateTime();

        // Assert
        Assert.True(valid);
    }
示例#4
0
    public void From_Integers_Sets_Values()
    {
        // Arrange
        const string expected = "200001020304";

        // Act
        var result = new DateTimeInt(2000, 1, 2, 3, 4);

        // Assert
        Assert.Equal(expected, result.ToString());
    }
示例#5
0
    public void From_Valid_Long_Sets_Values()
    {
        // Arrange
        const long input = 200001020304;

        // Act
        var result = new DateTimeInt(input);

        // Assert
        Assert.Equal(input.ToString(), result.ToString());
    }
示例#6
0
    public void Valid_Returns_String_Value()
    {
        // Arrange
        const string expected = "200001020304";
        var          input    = new DateTimeInt(expected);

        // Act
        var result = input.ToString();

        // Assert
        Assert.Equal(expected, result);
    }
示例#7
0
#pragma warning disable xUnit1026 // Theory methods should use all of their parameters
    public void Invalid_Returns_Zeroes(int year, int month, int day, int hour, int minute, string _)
#pragma warning restore xUnit1026 // Theory methods should use all of their parameters
    {
        // Arrange
        var input = new DateTimeInt(year, month, day, hour, minute);

        // Act
        var result = input.ToString();

        // Assert
        Assert.Equal("000000000000", result);
    }
示例#8
0
    public void Invalid_Returns_False_And_Part(int year, int month, int day, int hour, int minute, string part)
    {
        // Arrange
        var input = new DateTimeInt(year, month, day, hour, minute);

        // Act
        var(valid, invalidPart) = input.IsValidDateTime();

        // Assert
        Assert.False(valid);
        Assert.Equal(part, invalidPart);
    }
示例#9
0
    public void Invalid_DateTime_Returns_None(int year, int month, int day, int hour, int minute, string part)
    {
        // Arrange
        var input = new DateTimeInt(year, month, day, hour, minute);

        // Act
        var result = input.ToDateTime();

        // Assert
        var none = result.AssertNone().AssertType <InvalidDateTimeMsg>();

        Assert.Equal(part, none.Value.part);
    }
示例#10
0
    public void Valid_DateTime_Returns_Some()
    {
        // Arrange
        var dt    = new DateTime(2000, 1, 2, 3, 4, 0);
        var input = new DateTimeInt(dt);

        // Act
        var result = input.ToDateTime();

        // Assert
        var some = result.AssertSome();

        Assert.Equal(dt, some);
    }