public void Parse_NullValue_Throw() { TimeSpanHeaderParser parser = TimeSpanHeaderParser.Parser; int index = 0; Assert.Throws <FormatException>(() => { parser.ParseValue(null, null, ref index); }); }
public void ToString_UseDifferentValues_MatchExpectation() { TimeSpanHeaderParser parser = TimeSpanHeaderParser.Parser; Assert.Equal("123", parser.ToString(new TimeSpan(0, 2, 3))); Assert.Equal("0", parser.ToString(new TimeSpan(0, 0, 0))); }
public void Properties_ReadValues_MatchExpectation() { TimeSpanHeaderParser parser = TimeSpanHeaderParser.Parser; Assert.False(parser.SupportsMultipleValues, "SupportsMultipleValues"); Assert.Null(parser.Comparer); }
public void Parse_InvalidValue_Throw() { // This test verifies that Parse() correctly calls TryParse(). TimeSpanHeaderParser parser = TimeSpanHeaderParser.Parser; int index = 0; Assert.Throws <FormatException>(() => { parser.ParseValue("a", null, ref index); }); }
private void CheckValidParsedValue(string input, int startIndex, TimeSpan expectedResult, int expectedIndex) { TimeSpanHeaderParser parser = TimeSpanHeaderParser.Parser; object result = 0; Assert.True(parser.TryParseValue(input, null, ref startIndex, out result), string.Format("TryParse returned false: {0}", input)); Assert.Equal(expectedResult, result); Assert.Equal(expectedIndex, startIndex); }
private void CheckInvalidParsedValue(string input, int startIndex) { TimeSpanHeaderParser parser = TimeSpanHeaderParser.Parser; object result = 0; int newIndex = startIndex; Assert.False(parser.TryParseValue(input, null, ref newIndex, out result), string.Format("TryParse returned true: {0}", input)); Assert.Null(result); Assert.Equal(startIndex, newIndex); }
public void Parse_ValidValue_ReturnsLongValue() { // This test verifies that Parse() correctly calls TryParse(). TimeSpanHeaderParser parser = TimeSpanHeaderParser.Parser; int index = 2; Assert.Equal(new TimeSpan(0, 0, 15), parser.ParseValue(" 15", null, ref index)); Assert.Equal(4, index); index = 0; Assert.Equal(new TimeSpan(0, 0, 30), parser.ParseValue(" 030", null, ref index)); Assert.Equal(5, index); }