Click here to Skip to main content
15,887,683 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.6K   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 StudentPageFilterViewModelTest and is intended
    ///to contain all StudentPageFilterViewModelTest Unit Tests
    ///</summary>
    [TestClass]
    public class StudentPageFilterViewModelTest
    {
        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 StudentPageFilterViewModel Constructor
        ///</summary>
        [TestMethod]
        public void StudentPageFilterViewModelConstructorTest()
        {
            var target = new StudentPageFilterViewModel();
            Assert.IsNotNull(target.ListSortDirectionCollection);
            Assert.IsNotNull(target.JointConditionCollection);
            Assert.IsNotNull(target.StudentStatusCollection);
            Assert.IsNotNull(target.CompareOperator);
            Assert.IsNotNull(target.StatusCompareOperator);
        }

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

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

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

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

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

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

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

        /// <summary>
        ///A test for Status
        ///</summary>
        [TestMethod]
        public void StatusTest()
        {
            var propertyNameChanged = false;
            var target = new StudentPageFilterViewModel();
            target.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "Status")
                    {
                        propertyNameChanged = true;
                    }
                };
            StatusEnum? expected = StatusEnum.PartTime;
            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 StudentPageFilterViewModel();
            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 StudentPageFilterViewModel();
            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 StudentPageFilterViewModel();
            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 StudentPageFilterViewModel();
            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 StudentPageFilterViewModel();
            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 DialogResult
        ///</summary>
        [TestMethod]
        public void DialogResultTest()
        {
            var propertyNameChanged = false;
            var target = new StudentPageFilterViewModel();
            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 StudentPageFilterViewModel();
            RelayCommand actual = target.OkCommand;
            Assert.IsNotNull(actual);
        }

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

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

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

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

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

        /// <summary>
        ///A test for StatusSortDirectionSelectionChangedCommand
        ///</summary>
        [TestMethod]
        public void StatusSortDirectionSelectionChangedCommandTest()
        {
            var target = new StudentPageFilterViewModel();
            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