コード例 #1
0
        public void ToStringTest()
        {
            ExtensionConfiguration extensionConfiguration = new ExtensionConfiguration();
            extensionConfiguration.Name = "cs";

            string str = extensionConfiguration.ToString();

            Assert.AreEqual("Extension: cs", str, "Unexpected string representation.");
        }
コード例 #2
0
        public void CreateTest()
        {
            ExtensionConfiguration extensionConfiguration = new ExtensionConfiguration();

            //
            // Verify default state
            //
            Assert.IsNull(extensionConfiguration.Name, "Unexpected default value for Name.");
        }
コード例 #3
0
        /// <summary>
        /// Creates a clone of this instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public object Clone()
        {
            ExtensionConfiguration clone = new ExtensionConfiguration();

            clone._name = _name;

            if (_filterBy != null)
            {
                FilterBy filterByClone = _filterBy.Clone() as FilterBy;
                clone._filterBy = filterByClone;
            }

            return(clone);
        }
コード例 #4
0
        /// <summary>
        /// Creates a clone of this instance.
        /// </summary>
        /// <returns>Clone of the instance.</returns>
        protected override HandlerConfiguration DoClone()
        {
            ProjectHandlerConfiguration clone = new ProjectHandlerConfiguration();

            clone._parserType = _parserType;

            foreach (ExtensionConfiguration extension in ProjectExtensions)
            {
                ExtensionConfiguration extensionClone = extension.Clone() as ExtensionConfiguration;
                clone.ProjectExtensions.Add(extensionClone);
            }

            return(clone);
        }
コード例 #5
0
        /// <summary>
        /// Creates a clone of this instance.
        /// </summary>
        /// <returns>Clone of the instance.</returns>
        protected override HandlerConfiguration DoClone()
        {
            SourceHandlerConfiguration clone = new SourceHandlerConfiguration();

            clone._language = _language;

            foreach (ExtensionConfiguration extension in SourceExtensions)
            {
                ExtensionConfiguration extensionClone = extension.Clone() as ExtensionConfiguration;
                clone.SourceExtensions.Add(extensionClone);
            }

            return(clone);
        }
コード例 #6
0
        public void CloneTest()
        {
            ExtensionConfiguration extensionConfiguration = new ExtensionConfiguration();
            extensionConfiguration.Name = "cs";

            FilterBy filter = new FilterBy();
            filter.Condition = "$(File.Name) != 'Test.cs'";
            extensionConfiguration.FilterBy = filter;

            ExtensionConfiguration clone = extensionConfiguration.Clone() as ExtensionConfiguration;
            Assert.IsNotNull(clone, "Clone did not return a valid instance.");

            Assert.AreEqual(extensionConfiguration.Name, clone.Name);
            Assert.IsNotNull(clone.FilterBy, "FilterBy was not cloned.");
            Assert.AreEqual(extensionConfiguration.FilterBy.Condition, clone.FilterBy.Condition);
        }
コード例 #7
0
        /// <summary>
        /// Creates a clone of this instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public object Clone()
        {
            ExtensionConfiguration clone = new ExtensionConfiguration();

            clone._name = _name;

            if (_filterBy != null)
            {
                FilterBy filterByClone = _filterBy.Clone() as FilterBy;
                clone._filterBy = filterByClone;
            }

            return clone;
        }
コード例 #8
0
        public void UpgradeProjectExtensionsTest()
        {
            string filename = Path.GetTempFileName();
            try
            {
                CodeConfiguration oldConfiguration = new CodeConfiguration();

                SourceHandlerConfiguration sourceHandler = new SourceHandlerConfiguration();
                ExtensionConfiguration oldExtension = new ExtensionConfiguration();
                oldExtension.Name = "csproj";
                sourceHandler.ProjectExtensions.Add(oldExtension);
                oldConfiguration.Handlers.Add(sourceHandler);
                oldConfiguration.Save(filename);

                CodeConfiguration newConfiguration = CodeConfiguration.Load(filename);
                Assert.AreEqual(2, newConfiguration.Handlers.Count, "New handler was not created.");
                ProjectHandlerConfiguration projectHandlerConfiguration =
                    newConfiguration.Handlers[0] as ProjectHandlerConfiguration;
                Assert.IsNotNull(projectHandlerConfiguration, "Expected a project handler config to be created.");
                Assert.IsNull(projectHandlerConfiguration.AssemblyName);
                Assert.AreEqual(typeof(MSBuildProjectParser).FullName, projectHandlerConfiguration.ParserType);
                Assert.AreEqual(1, projectHandlerConfiguration.ProjectExtensions.Count, "Unexpected number of project extensions.");
                Assert.AreEqual(oldExtension.Name, projectHandlerConfiguration.ProjectExtensions[0].Name);
            }
            finally
            {
                try
                {
                    File.Delete(filename);
                }
                catch
                {
                }
            }
        }