示例#1
0
        public void FromString_DetectStyle()
        {
            // Assert
            var item                    = "storage://stylesheets/provider-key/string/value";
            var itemUriSafe             = "storage$_stylesheets$_provider-key$_string$_value";
            var autoItemSafeIntAsString = "1";
            var shortStyle              = "/string/blahblah";
            var shortStyleInt           = "/int32/1234";

            // Act
            var tryDetect                = HiveId.DetectFormatStyleFromString(item);
            var tryDetectUriSafe         = HiveId.DetectFormatStyleFromString(itemUriSafe);
            var tryDetectAutoIntAsString = HiveId.DetectFormatStyleFromString(autoItemSafeIntAsString);
            var tryDetectShort           = HiveId.DetectFormatStyleFromString(shortStyle);
            var tryDetectShortAsInt      = HiveId.DetectFormatStyleFromString(shortStyleInt);

            // Assert
            Assert.IsTrue(tryDetect.Success);
            Assert.AreEqual(HiveIdFormatStyle.AsUri, tryDetect.Result);
            Assert.IsTrue(tryDetectUriSafe.Success);
            Assert.AreEqual(HiveIdFormatStyle.UriSafe, tryDetectUriSafe.Result);
            Assert.IsTrue(tryDetectAutoIntAsString.Success);
            Assert.AreEqual(HiveIdFormatStyle.AutoSingleValue, tryDetectAutoIntAsString.Result);
            Assert.IsTrue(tryDetectShort.Success);
            Assert.AreEqual(HiveIdFormatStyle.AsUri, tryDetectShort.Result);
            Assert.IsTrue(tryDetectShortAsInt.Success);
            Assert.AreEqual(HiveIdFormatStyle.AsUri, tryDetectShortAsInt.Result);
        }