public void ParseNullReturnsCorrectResult() { UuidIri actualFromTry; bool couldParse = UuidIri.TryParse(null, out actualFromTry); Assert.Throws <ArgumentNullException>(() => UuidIri.Parse(null)); Assert.False(couldParse, "TryParse should fail."); Assert.Equal(default(UuidIri), actualFromTry); }
public void ParseCorrectlyFormattedStringReturnsCorrectResult( UuidIri expected) { var correctlyFormatted = expected.ToString(); UuidIri actualFromTry; bool couldParse = UuidIri.TryParse(correctlyFormatted, out actualFromTry); UuidIri actual = UuidIri.Parse(correctlyFormatted); Assert.True(couldParse, "TryParse should succeed."); Assert.Equal(expected, actualFromTry); Assert.Equal(expected, actual); }
public void ParseStringWithIncorrectIdReturnsCorrectResult( DateTimeOffset notAGuid) { var incorrectlyIdd = "urn:uuid:" + notAGuid.ToString(); UuidIri actualFromTry; bool couldParse = UuidIri.TryParse(incorrectlyIdd, out actualFromTry); Assert.Throws <ArgumentException>(() => UuidIri.Parse(incorrectlyIdd)); Assert.False(couldParse, "TryParse should fail."); Assert.Equal(default(UuidIri), actualFromTry); }
public void ParseIncorrectlyPrefixedStringReturnsCorrectResult( string incorrectPrefix, Guid guid) { Assert.NotEqual("urn:uuid:", incorrectPrefix); var inccorectlyPrefixed = incorrectPrefix + guid; UuidIri actualFromTry; bool couldParse = UuidIri.TryParse(inccorectlyPrefixed, out actualFromTry); Assert.Throws <ArgumentException>(() => UuidIri.Parse(inccorectlyPrefixed)); Assert.False(couldParse, "TryParse should fail."); Assert.Equal(default(UuidIri), actualFromTry); }