예제 #1
0
        public void ContentNaming_IncrementNameSuffix()
        {
            string msg;

            msg = IncrementNameSuffixTest("Car", "Car(1)"); Assert.IsNull(msg, msg);
            msg = IncrementNameSuffixTest("Car(12)", "Car(13)"); Assert.IsNull(msg, msg);
            msg = IncrementNameSuffixTest("Car.xml", "Car(1).xml"); Assert.IsNull(msg, msg);
            msg = IncrementNameSuffixTest("Car(8).xml", "Car(9).xml"); Assert.IsNull(msg, msg);
            msg = IncrementNameSuffixTest("Car((8).xml", "Car((9).xml"); Assert.IsNull(msg, msg);
            msg = IncrementNameSuffixTest("(1)", "(2)"); Assert.IsNull(msg, msg); Assert.IsNull(msg, msg);
            msg = IncrementNameSuffixTest(")", ")(1)"); Assert.IsNull(msg, msg); Assert.IsNull(msg, msg);

            msg = IncrementNameSuffixTest("Car(string)(12)", "Car(string)(13)"); Assert.IsNull(msg, msg);

            // suffices are guids for the following.
            // if the last suffixed name from db is in the form 'name(x)' where x is not a number, we are not able to decide the next suffix, so it is guid
            string nameBase;
            var    actual = ContentNamingHelper.IncrementNameSuffix("Car(string)", out nameBase);

            Assert.IsTrue(SuffixIsGuid(actual));
            actual = ContentNamingHelper.IncrementNameSuffix("Car(8)).xml", out nameBase);
            Assert.IsTrue(SuffixIsGuid(actual));
            actual = ContentNamingHelper.IncrementNameSuffix("Car()", out nameBase);
            Assert.IsTrue(SuffixIsGuid(actual));
        }
예제 #2
0
        private string IncrementNameSuffixTest(string name, string expected)
        {
            var actual = ContentNamingHelper.IncrementNameSuffix(name);

            if (actual == expected)
            {
                return(null);
            }
            return(String.Format("Name is {0}, expected: {1}", actual, expected));
        }