EditorFactoryNotifyForProjectAttributeTest.cs :  » Development » StyleCop » Microsoft » VisualStudio » Shell » RegistrationAttributes » UnitTests » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Development » StyleCop 
StyleCop » Microsoft » VisualStudio » Shell » RegistrationAttributes » UnitTests » EditorFactoryNotifyForProjectAttributeTest.cs
/***************************************************************************

Copyright (c) Microsoft Corporation. All rights reserved.
This code is licensed under the Visual Studio SDK license terms.
THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.

***************************************************************************/

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.VisualStudio.Shell.RegistrationAttributes.UnitTests{
    /// <summary>
    ///EditorFactoryNotifyForProjectAttribute class unit tests 
    ///</summary>
    [TestClass()]
    public class EditorFactoryNotifyForProjectAttributeTest
    {
        private object projectType;
        private string fileExtension;
        private object factoryType;

        #region Initialization
        /// <summary>
        /// Creates XmlDocument with one node = rootNodeName
        /// </summary>
        [TestInitialize()]
        public void InitializeParameters()
        {
            projectType = "{8a333fe3-2e11-42d9-8f6b-ae761e3b0588}";
            fileExtension = "TXT";
            factoryType = new Guid("{3e8702a1-d26f-4b91-bdc2-7ea0022b696c}");
        }
        #endregion Initialization

        /// <summary>
        /// Verify that the constructor throws a ArgumentNullException if the
        /// projectType is not set.
        /// </summary>
        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ConstructorWithProjectTypeNullArgTest()
        {
            projectType = null;
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            Assert.IsNotNull(target, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute");
        }

        /// <summary>
        /// Verify that the constructor throws a ArgumentNullException if the
        /// projectType is not set.
        /// </summary>
        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ConstructorWithFactoryTypeNullArgTest()
        {
            factoryType = null;
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            Assert.IsNotNull(target, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute");
        }

        /// <summary>
        ///A test for EditorFactoryNotifyForProjectAttribute (object, string, object)
        ///</summary>
        [TestMethod()]
        public void ConstructorTest()
        {
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            Assert.IsNotNull(target, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute");

            String factoryTypeString = "{3e8702a1-d26f-4b91-bdc2-7ea0022b696c}";
            projectType = new Guid("{3e8702a1-d26f-4b91-bdc2-7ea0022b696c}");
            EditorFactoryNotifyForProjectAttribute targetFromString = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryTypeString);
            Assert.IsNotNull(targetFromString, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute from String");

            Int32 integ = new Int32();
            factoryType = integ.GetType();
            projectType = integ.GetType();

            EditorFactoryNotifyForProjectAttribute targetFromType = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            Assert.IsNotNull(targetFromType, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute from Type");
        }

        /// <summary>
        /// A test for EditorFactoryNotifyForProjectAttribute (object, string, object)
        /// </summary>
        [TestMethod()]
        public void ConstructorTest1()
        {
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            Assert.IsNotNull(target, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute");

            String factoryTypeString = "{3e8702a1-d26f-4b91-bdc2-7ea0022b696c}";
            projectType = new Guid("{3e8702a1-d26f-4b91-bdc2-7ea0022b696c}");
            EditorFactoryNotifyForProjectAttribute targetFromString = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryTypeString);
            Assert.IsNotNull(targetFromString, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute from String");

            factoryType = typeof(int);
            projectType = typeof(int);

            EditorFactoryNotifyForProjectAttribute targetFromType = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            Assert.IsNotNull(targetFromType, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute from Type");
        }

        /// <summary>
        ///A test for EditorFactoryNotifyForProjectAttribute (object, string, object)
        /// Wrong cunxtructor parameter type test.
        ///</summary>
        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void ConstructorTestArgumentException()
        {
            object projectType = typeof(int); // TODO: Initialize to an appropriate value
            string fileExtension = null; // TODO: Initialize to an appropriate value
            object factoryType = (int)0; // TODO: Initialize to an appropriate value

            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            Assert.IsNotNull(target, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute");
        }

        /// <summary>
        ///A test for EditorFactoryNotifyForProjectAttribute (object, string, object)
        /// Wrong cunxtructor parameter type test.
        ///</summary>
        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void ConstructorTestArgumentException1()
        {
            object projectType = (int)0; // TODO: Initialize to an appropriate value
            string fileExtension = null; // TODO: Initialize to an appropriate value
            object factoryType = typeof(int); // TODO: Initialize to an appropriate value

            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            Assert.IsNotNull(target, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute");
        }


        /// <summary>
        ///A test for FactoryType
        ///</summary>
        [TestMethod()]
        public void FactoryTypeTest()
        {
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType,
            fileExtension, factoryType);
            Guid val = new Guid("{3e8702a1-d26f-4b91-bdc2-7ea0022b696c}");

            Assert.AreEqual(val, target.FactoryType, "Microsoft.Samples.VisualStudio.SynchronousXmlDesigner.Attributes.EditorFactoryNotify" +
            "ForProjectAttribute.FactoryType was not set correctly.");
        }

        /// <summary>
        ///A test for FileExtension
        ///</summary>
        [TestMethod()]
        public void FileExtensionTest()
        {
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            string val = "TXT";

            Assert.AreEqual(val, target.FileExtension, "Microsoft.Samples.VisualStudio.SynchronousXmlDesigner.Attributes.EditorFactoryNotify" +
                    "ForProjectAttribute.FileExtension was not set correctly.");
        }

        /// <summary>
        ///A test for ProjectFileExtensionPath
        ///</summary>        
        [TestMethod()]
        public void ProjectFileExtensionPathTest()
        {
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            string extension = "TXT";

            Assert.AreEqual(extension, target.FileExtension,
            "Microsoft.Samples.VisualStudio.SynchronousXmlDesigner.Attributes.EditorFactoryNotify" +
                    "ForProjectAttribute.ProjectFileExtensionPath was not set correctly.");
        }

        /// <summary>
        /// A test for ProjectType
        /// </summary>
        [TestMethod()]
        public void ProjectTypeTest()
        {
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            Guid val = new Guid("{8a333fe3-2e11-42d9-8f6b-ae761e3b0588}");

            Assert.AreEqual(val, target.ProjectType, "Microsoft.Samples.VisualStudio.SynchronousXmlDesigner.Attributes.EditorFactoryNotify" +
                    "ForProjectAttribute.ProjectType was not set correctly.");
        }

        /// <summary>
        /// A test for Register (RegistrationContext)
        /// </summary>
        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void RegisterWithNullArgTest()
        {
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            MockRegistrationContext context = null;
            target.Register(context);
        }

        /// <summary>
        /// A test for Register (RegistrationContext)
        /// </summary>
        [TestMethod()]
        public void RegisterTest()
        {
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            using (MockRegistrationContext context = new MockRegistrationContext())
            {
                target.Register(context);
            }
        }

        /// <summary>
        /// A test for Unregister (RegistrationContext)
        /// </summary>
        [TestMethod()]
        public void UnregisterWithNullArgTest()
        {
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            MockRegistrationContext context = null;
            target.Unregister(context);
        }

        /// <summary>
        /// A test for Unregister (RegistrationContext)
        /// </summary>
        [TestMethod()]
        public void UnregisterTest()
        {
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            using (MockRegistrationContext context = new MockRegistrationContext())
            {
                target.Unregister(context);
            }
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.