Ejemplo n.º 1
0
        private string IncrementNameSuffixTest(string name, string expected)
        {
            var actual = ContentNamingProvider.IncrementNameSuffix(name);

            if (actual == expected)
            {
                return(null);
            }
            return(String.Format("Name is {0}, expected: {1}", actual, expected));
        }
Ejemplo n.º 2
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
            var actual = ContentNamingProvider.IncrementNameSuffix("Car(string)");

            Assert.AreEqual("Car(string)(1)", actual);
            actual = ContentNamingProvider.IncrementNameSuffix("Car(8)).xml");
            Assert.AreEqual("Car(8))(1).xml", actual);
            actual = ContentNamingProvider.IncrementNameSuffix("Car()");
            Assert.AreEqual("Car()(1)", actual);
        }