Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Building WPF Applications with Self-Tracking Entity Generator - Project Setup

, 20 Feb 2012
This article describes the project setup of building a WPF sample application with Self-Tracking Entity Generator for WPF/Silverlight.
SchoolSample_20111201.zip
SchoolSample
Local.testsettings
SchoolSample.vsmdi
TraceAndTestImpact.testsettings
Assemblies
GalaSoft.MvvmLight.Extras.WPF4.dll
GalaSoft.MvvmLight.WPF4.dll
Moq.dll
System.Windows.Interactivity.dll
WPFToolkit.Extended.dll
ComponentModel.Composition.Initialization.Desktop
Microsoft
ComponentModel
Composition
Hosting
Internal
Properties
System
ComponentModel
Composition
Hosting
System.Windows.Controls.Data.Input
Common
Properties
Settings.settings
themes
Validation
Database
SchoolSample
SchoolSample.csproj.user
Asset
Control
Properties
Settings.settings
View
SchoolSample.Common
Model
Properties
Resource
SchoolSample.Data
EntityModel
Properties
Validation
SchoolSample.Data.Wcf
EntityModel
SchoolModel.edmx
Properties
Validation
SchoolSample.Model
Properties
SchoolSample.ViewModel
Properties
SchoolSample.Wcf
SchoolSample.Wcf.csproj.user
Properties
Service
SchoolService.svc
SchoolSample.WCFService
SchoolSample.WCFService.csproj.user
Properties
Service References
SchoolService
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
SchoolService.disco
SchoolService.wsdl
Test.SchoolSample.Model
Properties
Test References
SchoolSample.Model.accessor
Test.SchoolSample.ViewModel
Properties
Test References
SchoolSample.ViewModel.accessor
SchoolSample_20120117.zip
Local.testsettings
SchoolSample.vsmdi
TraceAndTestImpact.testsettings
GalaSoft.MvvmLight.Extras.WPF4.dll
GalaSoft.MvvmLight.WPF4.dll
Moq.dll
System.Windows.Interactivity.dll
WPFToolkit.Extended.dll
Settings.settings
SchoolSample.csproj.user
Settings.settings
SchoolModel.edmx
SchoolSample.Wcf.csproj.user
SchoolService.svc
SchoolSample.WCFService.csproj.user
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
SchoolService.disco
SchoolService.wsdl
SchoolSample.Model.accessor
SchoolSample.ViewModel.accessor
SchoolSample_20120216.zip
Local.testsettings
SchoolSample.vsmdi
TraceAndTestImpact.testsettings
GalaSoft.MvvmLight.Extras.WPF4.dll
GalaSoft.MvvmLight.WPF4.dll
Moq.dll
System.Windows.Interactivity.dll
WPFToolkit.Extended.dll
Settings.settings
SchoolSample.csproj.user
Settings.settings
SchoolModel.edmx
SchoolSample.Wcf.csproj.user
SchoolService.svc
SchoolSample.WCFService.csproj.user
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
SchoolService.disco
SchoolService.wsdl
SchoolSample.Model.accessor
SchoolSample.ViewModel.accessor
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Data;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using GalaSoft.MvvmLight.Command;
using Moq;
using SchoolSample.Common;
using SchoolSample.EntityModel;
using SchoolSample.ViewModel;

namespace Test.SchoolSample.ViewModel
{
    /// <summary>
    ///This is a test class for CoursePageViewModelTest and is intended
    ///to contain all CoursePageViewModelTest Unit Tests
    ///</summary>
    [TestClass]
    public class CoursePageViewModelTest
    {
        private TestContext testContextInstance;
        private Mock<ISchoolModel> schoolModelMock;

        /// <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

        //Use TestInitialize to run code before running each test
        [TestInitialize]
        public void MyTestInitialize()
        {
            schoolModelMock = new Mock<ISchoolModel>();
            var studentList = new List<Student>
                                  {
                                      new Student
                                          {
                                              PersonId = 1,
                                              Name = "Test Student One"
                                          },
                                      new Student
                                          {
                                              PersonId = 2,
                                              Name = "Test Student Two"
                                          },
                                      new Student
                                          {
                                              PersonId = 3,
                                              Name = "Test Student Three"
                                          }
                                  };
            schoolModelMock.Setup(n => n.GetStudentsAsync("None", "CoursePage"))
                .Raises(n => n.GetStudentsCompleted += null,
                        new ResultsArgs<Student>(studentList, null, false, "CoursePage"));
            var instructorList = new List<Instructor>
                                     {
                                         new Instructor
                                             {
                                                 PersonId = 1,
                                                 Name = "Test Instructor One"
                                             },
                                         new Instructor
                                             {
                                                 PersonId = 2,
                                                 Name = "Test Instructor Two"
                                             },
                                         new Instructor
                                             {
                                                 PersonId = 3,
                                                 Name = "Test Instructor Three"
                                             }
                                     };
            schoolModelMock.Setup(n => n.GetInstructorsAsync("None", "CoursePage"))
                .Raises(n => n.GetInstructorsCompleted += null,
                        new ResultsArgs<Instructor>(instructorList, null, false, "CoursePage"));
            var courseList = new List<Course>
                                 {
                                     new Course
                                         {
                                             CourseId = 1,
                                             InstructorId = 1,
                                             Title = "Test Course One",
                                             Enrollments = new TrackableCollection<Enrollment>
                                                               {
                                                                   new Enrollment
                                                                       {
                                                                           EnrollmentId = 1,
                                                                           CourseId = 1,
                                                                           StudentId = 1
                                                                       }
                                                               }
                                         },
                                     new Course
                                         {
                                             CourseId = 2,
                                             InstructorId = 1,
                                             Title = "Test Course Two",
                                             Enrollments = new TrackableCollection<Enrollment>
                                                               {
                                                                   new Enrollment
                                                                       {
                                                                           EnrollmentId = 1,
                                                                           CourseId = 2,
                                                                           StudentId = 2
                                                                       }
                                                               }
                                         },
                                     new Course
                                         {
                                             CourseId = 3,
                                             InstructorId = 1,
                                             Title = "Test Course Three",
                                             Enrollments = new TrackableCollection<Enrollment>
                                                               {
                                                                   new Enrollment
                                                                       {
                                                                           EnrollmentId = 1,
                                                                           CourseId = 3,
                                                                           StudentId = 3
                                                                       }
                                                               }
                                         },
                                 };
            schoolModelMock.Setup(n => n.GetCoursesAsync("CoursePage"))
                .Raises(n => n.GetCoursesCompleted += null,
                        new ResultsArgs<Course>(courseList, null, false, "CoursePage"));
            schoolModelMock.SetupAllProperties();
        }

        //Use TestCleanup to run code after each test has run
        [TestCleanup]
        public void MyTestCleanup()
        {
            schoolModelMock = null;
        }
        
        #endregion


        /// <summary>
        ///A test for CoursePageViewModel Constructor
        ///</summary>
        [TestMethod]
        public void CoursePageViewModelConstructorTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            schoolModelMock.Verify(n => n.GetStudentsAsync("None", "CoursePage"), Times.Once());
            schoolModelMock.Verify(n => n.GetInstructorsAsync("None", "CoursePage"), Times.Once());
            schoolModelMock.Verify(n => n.GetCoursesAsync("CoursePage"), Times.Once());
            Assert.IsFalse(target.CourseFormInEdit);
            Assert.IsFalse(target.EnrollmentFormInEdit);
        }

        /// <summary>
        ///A test for AllCoursesSourceView_CurrentChanged
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void AllCoursesSourceView_CurrentChangedTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.AllCoursesSourceView_CurrentChanged(null, null);
            Assert.IsNotNull(target.EnrollmentsSource);
        }

        /// <summary>
        ///A test for CourseFormBeginEdit
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void CourseFormBeginEditTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.CourseFormInEdit = false;
            target.CourseFormBeginEdit();
            Assert.IsTrue(target.CourseFormInEdit);
        }

        /// <summary>
        ///A test for CourseFormCancelEdit
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void CourseFormCancelEditTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.CourseFormInEdit = true;
            target.CourseFormCancelEdit();
            Assert.IsFalse(target.CourseFormInEdit);
        }

        /// <summary>
        ///A test for CourseFormEndEdit
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void CourseFormEndEditTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.CourseFormInEdit = true;
            target.CourseFormEndEdit();
            Assert.IsFalse(target.CourseFormInEdit);
        }

        /// <summary>
        ///A test for CoursePageViewModel_PropertyChanged
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void CoursePageViewModel_PropertyChangedTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            PropertyChangedEventArgs e = new PropertyChangedEventArgs("EnrollmentFormInEdit");
            target.EnrollmentFormInEdit = true;
            target.CoursePageViewModel_PropertyChanged(null, e);
            Assert.IsFalse(target.CourseListIsEnabled);
            Assert.IsFalse(target.EnrollmentListIsEnabled);
            Assert.IsTrue(target.StudentComboIsEditable);
        }

        /// <summary>
        ///A test for EnrollmentFormBeginEdit
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void EnrollmentFormBeginEditTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.EnrollmentFormInEdit = false;
            target.EnrollmentFormBeginEdit();
            Assert.IsTrue(target.EnrollmentFormInEdit);
        }

        /// <summary>
        ///A test for EnrollmentFormCancelEdit
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void EnrollmentFormCancelEditTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.EnrollmentFormInEdit = true;
            target.EnrollmentFormCancelEdit();
            Assert.IsFalse(target.EnrollmentFormInEdit);
        }

        /// <summary>
        ///A test for EnrollmentFormEndEdit
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void EnrollmentFormEndEditTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.EnrollmentFormInEdit = true;
            target.EnrollmentFormEndEdit();
            Assert.IsFalse(target.EnrollmentFormInEdit);
        }

        /// <summary>
        ///A test for EnrollmentsSourceView_CurrentChanged
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void EnrollmentsSourceView_CurrentChangedTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.CurrentEnrollment = null;
            target.EnrollmentsSourceView_CurrentChanged(null, null);
            Assert.IsNotNull(target.CurrentEnrollment);
        }

        /// <summary>
        ///A test for OnAddCourseCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnAddCourseCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.OnAddCourseCommand();
            Assert.IsTrue(target.CurrentCourse.CourseId < 0);
            Assert.IsNull(target.CurrentEnrollment);
        }

        /// <summary>
        ///A test for OnAddEnrollmentCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnAddEnrollmentCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.CurrentEnrollment = null;
            target.OnAddEnrollmentCommand();
            Assert.IsNotNull(target.CurrentEnrollment);
        }

        /// <summary>
        ///A test for OnCancelEditCourseCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnCancelEditCourseCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.CourseFormInEdit = true;
            target.OnCancelEditCourseCommand();
            Assert.IsFalse(target.CourseFormInEdit);
        }

        /// <summary>
        ///A test for OnCancelEditEnrollmentCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnCancelEditEnrollmentCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.EnrollmentFormInEdit = true;
            target.OnCancelEditEnrollmentCommand();
            Assert.IsFalse(target.EnrollmentFormInEdit);
        }

        /// <summary>
        ///A test for OnDeleteEnrollmentCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnDeleteEnrollmentCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.OnDeleteEnrollmentCommand();
            Assert.IsTrue(target.CurrentEnrollment.ChangeTracker.State == ObjectState.Deleted);
        }

        /// <summary>
        ///A test for OnEditCommitCourseCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnEditCommitCourseCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.CourseFormInEdit = true;
            target.OnEditCommitCourseCommand();
            Assert.IsFalse(target.CourseFormInEdit);
        }

        /// <summary>
        ///A test for OnEditCommitEnrollmentCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnEditCommitEnrollmentCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.EnrollmentFormInEdit = true;
            target.OnEditCommitEnrollmentCommand();
            Assert.IsFalse(target.EnrollmentFormInEdit);
        }

        /// <summary>
        ///A test for OnPageLoadedCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnPageLoadedCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            schoolModelMock.Object.CoursesList = null;
            schoolModelMock.Object.CurrentCourse = null;
            target.OnPageLoadedCommand();
            Assert.IsNotNull(schoolModelMock.Object.CoursesList);
            Assert.IsNotNull(schoolModelMock.Object.CurrentCourse);
        }

        /// <summary>
        ///A test for OnPageUnLoadedCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnPageUnLoadedCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.OnPageUnLoadedCommand();
            Assert.IsNull(schoolModelMock.Object.CoursesList);
            Assert.IsNull(schoolModelMock.Object.CurrentCourse);
        }

        /// <summary>
        ///A test for OnRefreshAllCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnRefreshAllCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.OnRefreshAllCommand();
            schoolModelMock.Verify(n => n.GetStudentsAsync("None", "CoursePage"), Times.Exactly(2));
            schoolModelMock.Verify(n => n.GetInstructorsAsync("None", "CoursePage"), Times.Exactly(2));
            schoolModelMock.Verify(n => n.GetCoursesAsync("CoursePage"), Times.Exactly(2));
        }

        /// <summary>
        ///A test for OnRefreshCourseCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnRefreshCourseCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.OnRefreshCourseCommand();
            schoolModelMock.Verify(n => n.GetCourseByIdAsync(It.IsAny<int>()), Times.Once());
        }

        /// <summary>
        ///A test for OnSubmitAllChangeCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnSubmitAllChangeCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.OnSubmitAllChangeCommand();
            schoolModelMock.Verify(n => n.SaveCourseChangesAsync(true), Times.Once());
        }

        /// <summary>
        ///A test for OnSubmitCourseChangeCommand
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void OnSubmitCourseChangeCommandTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.OnSubmitCourseChangeCommand();
            schoolModelMock.Verify(n => n.SaveCourseChangesAsync(false), Times.Once());
        }

        /// <summary>
        ///A test for UpdateCourseListIsEnabled
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void UpdateCourseListIsEnabledTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.CourseFormInEdit = true;
            target.EnrollmentFormInEdit = false;
            target.UpdateCourseListIsEnabled();
            Assert.IsFalse(target.CourseListIsEnabled);
        }

        /// <summary>
        ///A test for UpdateEnrollmentListIsEnabled
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void UpdateEnrollmentListIsEnabledTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.EnrollmentFormInEdit = true;
            target.UpdateEnrollmentListIsEnabled();
            Assert.IsFalse(target.EnrollmentListIsEnabled);
        }

        /// <summary>
        ///A test for UpdateStudentComboIsEditable
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void UpdateStudentComboIsEditableTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.EnrollmentFormInEdit = true;
            target.UpdateStudentComboIsEditable();
            Assert.IsTrue(target.StudentComboIsEditable);
        }

        /// <summary>
        ///A test for _schoolModel_GetCourseByIdCompleted
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void _schoolModel_GetCourseByIdCompletedTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            ResultArgs<Course> e = new ResultArgs<Course>(
                new Course
                {
                    CourseId = 1,
                    InstructorId = 1,
                    Title = "Test Course One",
                    Enrollments = new TrackableCollection<Enrollment>()
                }
                , null, false, null);
            target._schoolModel_GetCourseByIdCompleted(null, e);
            Assert.IsTrue(target.CurrentCourse.Enrollments.Count == 0);
        }

        /// <summary>
        ///A test for _schoolModel_GetCoursesCompleted
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void _schoolModel_GetCoursesCompletedTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            ResultsArgs<Course> e = new ResultsArgs<Course>(new List<Course>(), null, false, "CoursePage");
            target._schoolModel_GetCoursesCompleted(null, e);
            Assert.IsNull(target.CurrentCourse);
            Assert.IsNull(target.CurrentEnrollment);
        }

        /// <summary>
        ///A test for _schoolModel_GetInstructorsCompleted
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void _schoolModel_GetInstructorsCompletedTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            ResultsArgs<Instructor> e = new ResultsArgs<Instructor>(new List<Instructor>(), null, false, "CoursePage");
            target._schoolModel_GetInstructorsCompleted(null, e);
            Assert.IsTrue(target._allInstructors.Count == 0);
        }

        /// <summary>
        ///A test for _schoolModel_GetStudentsCompleted
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void _schoolModel_GetStudentsCompletedTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            ResultsArgs<Student> e = new ResultsArgs<Student>(new List<Student>(), null, false, "CoursePage");
            target._schoolModel_GetStudentsCompleted(null, e);
            Assert.IsTrue(target._allStudents.Count == 0);
        }

        /// <summary>
        ///A test for _schoolModel_SaveCourseChangesCompleted
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void _schoolModel_SaveCourseChangesCompletedTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            ResultArgs<string> e = new ResultArgs<string>(string.Empty, null, false, null);
            target._schoolModel_SaveCourseChangesCompleted(null, e);
            schoolModelMock.Verify(n => n.GetStudentsAsync("None", "CoursePage"), Times.Exactly(2));
            schoolModelMock.Verify(n => n.GetInstructorsAsync("None", "CoursePage"), Times.Exactly(2));
            schoolModelMock.Verify(n => n.GetCoursesAsync("CoursePage"), Times.Exactly(2));
        }

        /// <summary>
        ///A test for AllCourses
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void AllCoursesTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            ObservableCollection<Course> expected = new ObservableCollection<Course>();
            target.AllCourses = expected;
            ObservableCollection<Course> actual = target.AllCourses;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for AllCoursesSource
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void AllCoursesSourceTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            CollectionViewSource expected = new CollectionViewSource();
            target.AllCoursesSource = expected;
            CollectionViewSource actual = target.AllCoursesSource;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for AllInstructorsSource
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void AllInstructorsSourceTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            CollectionViewSource expected = new CollectionViewSource();
            target.AllInstructorsSource = expected;
            CollectionViewSource actual = target.AllInstructorsSource;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for AllStudentsSource
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void AllStudentsSourceTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            CollectionViewSource expected = new CollectionViewSource();
            target.AllStudentsSource = expected;
            CollectionViewSource actual = target.AllStudentsSource;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for EnrollmentsSource
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void EnrollmentsSourceTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            CollectionViewSource expected = new CollectionViewSource();
            target.EnrollmentsSource = expected;
            CollectionViewSource actual = target.EnrollmentsSource;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for AddCourseCommand
        ///</summary>
        [TestMethod]
        public void AddCourseCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.AddCourseCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for AddEnrollmentCommand
        ///</summary>
        [TestMethod]
        public void AddEnrollmentCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.AddEnrollmentCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for CancelAllChangeCommand
        ///</summary>
        [TestMethod]
        public void CancelAllChangeCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.CancelAllChangeCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for CancelCourseChangeCommand
        ///</summary>
        [TestMethod]
        public void CancelCourseChangeCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.CancelCourseChangeCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for CancelEditCourseCommand
        ///</summary>
        [TestMethod]
        public void CancelEditCourseCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.CancelEditCourseCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for CancelEditEnrollmentCommand
        ///</summary>
        [TestMethod]
        public void CancelEditEnrollmentCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.CancelEditEnrollmentCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for DeleteCourseCommand
        ///</summary>
        [TestMethod]
        public void DeleteCourseCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.DeleteCourseCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for DeleteEnrollmentCommand
        ///</summary>
        [TestMethod]
        public void DeleteEnrollmentCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.DeleteEnrollmentCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for EditCommitCourseCommand
        ///</summary>
        [TestMethod]
        public void EditCommitCourseCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.EditCommitCourseCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for EditCommitEnrollmentCommand
        ///</summary>
        [TestMethod]
        public void EditCommitEnrollmentCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.EditCommitEnrollmentCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for PageLoadedCommand
        ///</summary>
        [TestMethod]
        public void PageLoadedCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.PageLoadedCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for PageUnLoadedCommand
        ///</summary>
        [TestMethod]
        public void PageUnLoadedCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.PageUnLoadedCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for RefreshAllCommand
        ///</summary>
        [TestMethod]
        public void RefreshAllCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.RefreshAllCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for RefreshCourseCommand
        ///</summary>
        [TestMethod]
        public void RefreshCourseCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.RefreshCourseCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for SubmitAllChangeCommand
        ///</summary>
        [TestMethod]
        public void SubmitAllChangeCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.SubmitAllChangeCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for SubmitCourseChangeCommand
        ///</summary>
        [TestMethod]
        public void SubmitCourseChangeCommandTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            RelayCommand actual = target.SubmitCourseChangeCommand;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for CourseFormInEdit
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void CourseFormInEditTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.CourseFormInEdit = true;
            bool actual = target.CourseFormInEdit;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for CourseListIsEnabled
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void CourseListIsEnabledTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.CourseListIsEnabled = true;
            bool actual = target.CourseListIsEnabled;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for CurrentCourse
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void CurrentCourseTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            Course expected = new Course();
            target.CurrentCourse = expected;
            Course actual = target.CurrentCourse;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for CurrentCourseHasErrors
        ///</summary>
        [TestMethod]
        public void CurrentCourseHasErrorsTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            target.CurrentCourseHasErrors = true;
            bool actual = target.CurrentCourseHasErrors;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for CurrentEnrollment
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void CurrentEnrollmentTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            Enrollment expected = new Enrollment();
            target.CurrentEnrollment = expected;
            Enrollment actual = target.CurrentEnrollment;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for CurrentEnrollmentHasErrors
        ///</summary>
        [TestMethod]
        public void CurrentEnrollmentHasErrorsTest()
        {
            CoursePageViewModel target = new CoursePageViewModel(schoolModelMock.Object);
            target.CurrentEnrollmentHasErrors = true;
            bool actual = target.CurrentEnrollmentHasErrors;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for EnrollmentFormInEdit
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void EnrollmentFormInEditTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.EnrollmentFormInEdit = true;
            bool actual = target.EnrollmentFormInEdit;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for EnrollmentListIsEnabled
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void EnrollmentListIsEnabledTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.EnrollmentListIsEnabled = true;
            bool actual = target.EnrollmentListIsEnabled;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for StudentComboIsEditable
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.ViewModel.dll")]
        public void StudentComboIsEditableTest()
        {
            CoursePageViewModel_Accessor target = new CoursePageViewModel_Accessor(schoolModelMock.Object);
            target.StudentComboIsEditable = true;
            bool actual = target.StudentComboIsEditable;
            Assert.IsTrue(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)

Share

About the Author

Weidong Shen
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

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 20 Feb 2012
Article Copyright 2011 by Weidong Shen
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid