Click here to Skip to main content
15,886,110 members
Articles / Desktop Programming / WPF

Building WPF Applications with Self-Tracking Entity Generator and Visual Studio 2012 - Project Setup

Rate me:
Please Sign up or sign in to vote.
5.00/5 (14 votes)
17 Mar 2013CPOL8 min read 68.5K   3.5K   44  
This article describes the project setup of building a WPF sample application with Self-Tracking Entity Generator and Visual Studio 2012.
using SchoolSample.ViewModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using GalaSoft.MvvmLight.Command;
using SchoolSample.EntityModel;

namespace Test.SchoolSample.ViewModel
{
    /// <summary>
    ///This is a test class for InstructorPageFilterViewModelTest and is intended
    ///to contain all InstructorPageFilterViewModelTest Unit Tests
    ///</summary>
    [TestClass]
    public class InstructorPageFilterViewModelTest
    {
        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 InstructorPageFilterViewModel Constructor
        ///</summary>
        [TestMethod]
        public void InstructorPageFilterViewModelConstructorTest()
        {
            var target = new InstructorPageFilterViewModel();
            Assert.IsNotNull(target.ListSortDirectionCollection);
            Assert.IsNotNull(target.JointConditionCollection);
            Assert.IsNotNull(target.InstructorStatusCollection);
            Assert.IsNotNull(target.CompareOperator);
            Assert.IsNotNull(target.StatusCompareOperator);
        }

        /// <summary>
        ///A test for InstructorName
        ///</summary>
        [TestMethod]
        public void InstructorNameTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "InstructorName")
                    {
                        propertyNameChanged = true;
                    }
                };
            const string expected = "Instructor One";
            target.InstructorName = expected;
            string actual = target.InstructorName;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for InstructorNameSortDirectionIndex
        ///</summary>
        [TestMethod]
        public void InstructorNameSortDirectionIndexTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "InstructorNameSortDirectionIndex")
                    {
                        propertyNameChanged = true;
                    }
                };
            const int expected = 2;
            target.InstructorNameSortDirectionIndex = expected;
            int actual = target.InstructorNameSortDirectionIndex;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for InstructorNameSortOrder
        ///</summary>
        [TestMethod]
        public void InstructorNameSortOrderTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "InstructorNameSortOrder")
                    {
                        propertyNameChanged = true;
                    }
                };
            int? expected = 2;
            target.InstructorNameSortOrder = expected;
            int? actual = target.InstructorNameSortOrder;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for HireDate
        ///</summary>
        [TestMethod]
        public void HireDateTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "HireDate")
                    {
                        propertyNameChanged = true;
                    }
                };
            DateTime? expected = DateTime.Now;
            target.HireDate = expected;
            DateTime? actual = target.HireDate;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for HireDateCompareOperatorIndex
        ///</summary>
        [TestMethod]
        public void HireDateCompareOperatorIndexTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "HireDateCompareOperatorIndex")
                    {
                        propertyNameChanged = true;
                    }
                };
            const int expected = 1;
            target.HireDateCompareOperatorIndex = expected;
            int actual = target.HireDateCompareOperatorIndex;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for HireDateSortDirectionIndex
        ///</summary>
        [TestMethod]
        public void HireDateSortDirectionIndexTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "HireDateSortDirectionIndex")
                    {
                        propertyNameChanged = true;
                    }
                };
            const int expected = 2;
            target.HireDateSortDirectionIndex = expected;
            int actual = target.HireDateSortDirectionIndex;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for HireDateSortOrder
        ///</summary>
        [TestMethod]
        public void HireDateSortOrderTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "HireDateSortOrder")
                    {
                        propertyNameChanged = true;
                    }
                };
            int? expected = 2;
            target.HireDateSortOrder = expected;
            int? actual = target.HireDateSortOrder;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for Salary
        ///</summary>
        [TestMethod]
        public void SalaryTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "Salary")
                    {
                        propertyNameChanged = true;
                    }
                };
            var expected = (decimal?) 1234.56;
            target.Salary = expected;
            decimal? actual = target.Salary;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for SalaryCompareOperatorIndex
        ///</summary>
        [TestMethod]
        public void SalaryCompareOperatorIndexTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "SalaryCompareOperatorIndex")
                    {
                        propertyNameChanged = true;
                    }
                };
            const int expected = 1;
            target.SalaryCompareOperatorIndex = expected;
            int actual = target.SalaryCompareOperatorIndex;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for SalarySortDirectionIndex
        ///</summary>
        [TestMethod]
        public void SalarySortDirectionIndexTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "SalarySortDirectionIndex")
                    {
                        propertyNameChanged = true;
                    }
                };
            const int expected = 2;
            target.SalarySortDirectionIndex = expected;
            int actual = target.SalarySortDirectionIndex;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for SalarySortOrder
        ///</summary>
        [TestMethod]
        public void SalarySortOrderTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "SalarySortOrder")
                    {
                        propertyNameChanged = true;
                    }
                };
            int? expected = 2;
            target.SalarySortOrder = expected;
            int? actual = target.SalarySortOrder;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for Status
        ///</summary>
        [TestMethod]
        public void StatusTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "Status")
                    {
                        propertyNameChanged = true;
                    }
                };
            StatusEnum? expected = StatusEnum.FullTime;
            target.Status = expected;
            StatusEnum? actual = target.Status;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for StatusCompareOperatorIndex
        ///</summary>
        [TestMethod]
        public void StatusCompareOperatorIndexTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "StatusCompareOperatorIndex")
                    {
                        propertyNameChanged = true;
                    }
                };
            const int expected = 1;
            target.StatusCompareOperatorIndex = expected;
            int actual = target.StatusCompareOperatorIndex;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for StatusSortDirectionIndex
        ///</summary>
        [TestMethod]
        public void StatusSortDirectionIndexTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "StatusSortDirectionIndex")
                    {
                        propertyNameChanged = true;
                    }
                };
            const int expected = 2;
            target.StatusSortDirectionIndex = expected;
            int actual = target.StatusSortDirectionIndex;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for StatusSortOrder
        ///</summary>
        [TestMethod]
        public void StatusSortOrderTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "StatusSortOrder")
                    {
                        propertyNameChanged = true;
                    }
                };
            int? expected = 2;
            target.StatusSortOrder = expected;
            int? actual = target.StatusSortOrder;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for JointCondition1Index
        ///</summary>
        [TestMethod]
        public void JointCondition1IndexTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "JointCondition1Index")
                    {
                        propertyNameChanged = true;
                    }
                };
            const int expected = 1;
            target.JointCondition1Index = expected;
            int actual = target.JointCondition1Index;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for JointCondition2Index
        ///</summary>
        [TestMethod]
        public void JointCondition2IndexTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "JointCondition2Index")
                    {
                        propertyNameChanged = true;
                    }
                };
            const int expected = 1;
            target.JointCondition2Index = expected;
            int actual = target.JointCondition2Index;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for JointCondition3Index
        ///</summary>
        [TestMethod]
        public void JointCondition3IndexTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "JointCondition3Index")
                    {
                        propertyNameChanged = true;
                    }
                };
            const int expected = 1;
            target.JointCondition3Index = expected;
            int actual = target.JointCondition3Index;
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for DialogResult
        ///</summary>
        [TestMethod]
        public void DialogResultTest()
        {
            var propertyNameChanged = false;
            var target = new InstructorPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "DialogResult")
                    {
                        propertyNameChanged = true;
                    }
                };
            target.DialogResult = true;
            bool? actual = target.DialogResult;
            Assert.IsTrue((bool) actual);
            Assert.IsTrue(propertyNameChanged);
        }

        /// <summary>
        ///A test for OkCommand
        ///</summary>
        [TestMethod]
        public void OkCommandTest()
        {
            var target = new InstructorPageFilterViewModel();
            RelayCommand actual = target.OkCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for CancelCommand
        ///</summary>
        [TestMethod]
        public void CancelCommandTest()
        {
            var target = new InstructorPageFilterViewModel();
            RelayCommand actual = target.CancelCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for ResetCommand
        ///</summary>
        [TestMethod]
        public void ResetCommandTest()
        {
            var target = new InstructorPageFilterViewModel();
            RelayCommand actual = target.ResetCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for SaveDefaultCommand
        ///</summary>
        [TestMethod]
        public void SaveDefaultCommandTest()
        {
            var target = new InstructorPageFilterViewModel();
            RelayCommand actual = target.SaveDefaultCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for InstructorNameSortDirectionSelectionChangedCommand
        ///</summary>
        [TestMethod]
        public void InstructorNameSortDirectionSelectionChangedCommandTest()
        {
            var target = new InstructorPageFilterViewModel();
            RelayCommand actual = target.InstructorNameSortDirectionSelectionChangedCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for HireDateSortDirectionSelectionChangedCommand
        ///</summary>
        [TestMethod]
        public void HireDateSortDirectionSelectionChangedCommandTest()
        {
            var target = new InstructorPageFilterViewModel();
            RelayCommand actual = target.HireDateSortDirectionSelectionChangedCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for SalarySortDirectionSelectionChangedCommand
        ///</summary>
        [TestMethod]
        public void SalarySortDirectionSelectionChangedCommandTest()
        {
            var target = new InstructorPageFilterViewModel();
            RelayCommand actual = target.SalarySortDirectionSelectionChangedCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for StatusSortDirectionSelectionChangedCommand
        ///</summary>
        [TestMethod]
        public void StatusSortDirectionSelectionChangedCommandTest()
        {
            var target = new InstructorPageFilterViewModel();
            RelayCommand actual = target.StatusSortDirectionSelectionChangedCommand;
            Assert.IsNotNull(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)
United States United States
Weidong has been an information system professional since 1990. He has a Master's degree in Computer Science, and is currently a MCSD .NET

Comments and Discussions