public void TryParseShouldReturnCorrectVersion() { var version = VersionValidator.TryParse("1.1", TestObjectFactory.GetFailingValidationAction()); Assert.Equal(1, version.Major); Assert.Equal(1, version.Minor); }
public void TryParseShouldInvokeFailedActionIfStringIsNotInCorrectFormat() { var exception = Assert.Throws <NullReferenceException>(() => { VersionValidator.TryParse("test", TestObjectFactory.GetFailingValidationAction()); }); Assert.Equal("version valid version string invalid one", exception.Message); }
/// <summary> /// Tests whether HTTP response message version is the same as the provided version as string. /// </summary> /// <param name="version">Expected version as string.</param> /// <returns>The same HTTP response message test builder.</returns> public IAndHttpResponseMessageTestBuilder WithVersion(string version) { var parsedVersion = VersionValidator.TryParse(version, this.ThrowNewHttpResponseMessageAssertionException); return(this.WithVersion(parsedVersion)); }
/// <summary> /// Adds HTTP version to the built HTTP request message. /// </summary> /// <param name="version">HTTP version provided by string.</param> /// <returns>The same HTTP request message builder.</returns> public IAndHttpRequestMessageBuilder WithVersion(string version) { var parsedVersion = VersionValidator.TryParse(version, this.ThrowNewInvalidHttpRequestMessageException); return(this.WithVersion(parsedVersion)); }
public void TryParseShouldInvokeFailedActionIfStringIsNotInCorrectFormat() { VersionValidator.TryParse("test", TestObjectFactory.GetFailingValidationAction()); }