Click here to Skip to main content
15,891,375 members
Articles / Web Development / HTML

A WPF Template solution using MVVM and Castle Windsor

Rate me:
Please Sign up or sign in to vote.
4.78/5 (11 votes)
18 Nov 2013CPOL5 min read 34.9K   1.2K   19  
A WPF application base solution using Castle Windsor and commonly used utilities.
using CommonData;
using CommonUtilities;
using HiveStudios.EventBroker;
using Interfaces;
using Map;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MapUnitTest
{
    
    
    /// <summary>
    ///This is a test class for MapModelTest and is intended
    ///to contain all MapModelTest Unit Tests
    ///</summary>
    [TestClass()]
    public class MapModelTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for MapModel Constructor
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Map.dll")]
        public void MapModelConstructorTest()
        {
            MapModel_Accessor target = new MapModel_Accessor(new CommonThreadsManager()); 
            Assert.IsNotNull(target.MapData);
            Assert.IsTrue(EventBroker.ExecutionMethods.Contains(CommonEventsMessages.MapThreadStarted));
            Assert.IsTrue(EventBroker.ExecutionMethods.Contains(CommonEventsMessages.MapThreadStopped));
            Assert.IsTrue(EventBroker.ExecutionMethods.Contains(CommonEventsMessages.UpdateMapData));
        }
        /// <summary>
        ///A test for ThreadStarted
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Map.dll")]
        public void ThreadStartedTest()
        {
            MapModel_Accessor target = new MapModel_Accessor(new CommonThreadsManager());
            object sender = null; 
            GlobalEventEventArgs e = new GlobalEventEventArgs(new ThreadsCreateData());
            target.ThreadStarted(sender, e);
        }

        /// <summary>
        ///A test for ThreadStopped
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Map.dll")]
        public void ThreadStoppedTest()
        {
            MapModel_Accessor target = new MapModel_Accessor(new CommonThreadsManager()); 
            object sender = null; 
            GlobalEventEventArgs e = new GlobalEventEventArgs(new ThreadsCreateData());
            target.ThreadStopped(sender, e);
        }

        /// <summary>
        ///A test for UpdateData
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Map.dll")]
        public void UpdateDataTest()
        {
            MapModel_Accessor target = new MapModel_Accessor(new CommonThreadsManager());
            object sender = null; 
            GlobalEventEventArgs e = new GlobalEventEventArgs(new MapData()); 
            target.UpdateData(sender, e);
        }

        /// <summary>
        ///A test for MapData
        ///</summary>
        [TestMethod()]
        public void MapDataTest()
        {
            MapModel target = new MapModel(new CommonThreadsManager()); // TODO: Initialize to an appropriate value
            IMapData expected = new MapData("Map Init", "00:00:00"); // TODO: Initialize to an appropriate value
            IMapData actual;
            target.MapData = expected;
            actual = target.MapData;
            Assert.AreEqual(expected, actual);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Scodix
Israel Israel
Project Manager and Application Developer, in a wide variety of business applications. Particularly interested in client/server and Graphical User Interface design using Visual C#.

Specialties: 13 Y'rs in C#, 10 Y'rs experience in C++ Highly experienced in wide technologies, IT projects, military projects etc'.

Comments and Discussions