示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }