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

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

, 20 Feb 2012 CPOL
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;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using SchoolSample.EntityModel;
using SchoolSample.Model;
using SchoolSample.WCFService.SchoolService;

namespace Test.SchoolSample.Model
{
    /// <summary>
    ///This is a test class for SchoolModelTest and is intended
    ///to contain all SchoolModelTest Unit Tests
    ///</summary>
    [TestClass]
    public class SchoolModelTest
    {
        private TestContext testContextInstance;
        private Mock<ISchoolServiceClient> schoolServiceMock;
        private AsyncCallback callback;
        private IAsyncResult ar = new Mock<IAsyncResult>().Object;
        private AsyncResult courseAsyncResult;
        private AsyncResult studentAsyncResult;
        private AsyncResult instructorAsyncResult;
        private List<Course> courseList;
        private List<Student> studentList;
        private List<Student> trimmedStudentList;
        private List<Instructor> instructorList;
        private List<Instructor> trimmedInstructorList;

        /// <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()
        {
            // set up courseList
            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
                                                                   }
                                                           }
                                     },
                             };
            // set up in studentList
            studentList = new List<Student>
                              {
                                  new Student
                                      {
                                          PersonId = 1,
                                          Name = "Test Student One",
                                          Enrollments = new TrackableCollection<Enrollment>
                                                            {
                                                                new Enrollment
                                                                    {
                                                                        EnrollmentId = 1,
                                                                        CourseId = 1,
                                                                        StudentId = 1
                                                                    },
                                                                new Enrollment
                                                                    {
                                                                        EnrollmentId = 2,
                                                                        CourseId = 2,
                                                                        StudentId = 1
                                                                    },
                                                                new Enrollment
                                                                    {
                                                                        EnrollmentId = 3,
                                                                        CourseId = 3,
                                                                        StudentId = 1
                                                                    },
                                                            }
                                      },
                                  new Student
                                      {
                                          PersonId = 2,
                                          Name = "Test Student Two",
                                          Enrollments = new TrackableCollection<Enrollment>
                                                            {
                                                                new Enrollment
                                                                    {
                                                                        EnrollmentId = 4,
                                                                        CourseId = 1,
                                                                        StudentId = 2
                                                                    },
                                                                new Enrollment
                                                                    {
                                                                        EnrollmentId = 5,
                                                                        CourseId = 2,
                                                                        StudentId = 2
                                                                    },
                                                                new Enrollment
                                                                    {
                                                                        EnrollmentId = 6,
                                                                        CourseId = 3,
                                                                        StudentId = 2
                                                                    },
                                                            }
                                      },
                                  new Student
                                      {
                                          PersonId = 3,
                                          Name = "Test Student Three",
                                          Enrollments = new TrackableCollection<Enrollment>
                                                            {
                                                                new Enrollment
                                                                    {
                                                                        EnrollmentId = 7,
                                                                        CourseId = 1,
                                                                        StudentId = 3
                                                                    },
                                                                new Enrollment
                                                                    {
                                                                        EnrollmentId = 8,
                                                                        CourseId = 2,
                                                                        StudentId = 3
                                                                    },
                                                                new Enrollment
                                                                    {
                                                                        EnrollmentId = 9,
                                                                        CourseId = 3,
                                                                        StudentId = 3
                                                                    },
                                                            }
                                      }
                              };
            foreach (var enrollment in studentList.SelectMany(n => n.Enrollments))
                enrollment.MarkAsUnchanged();
            trimmedStudentList = new List<Student>(studentList);
            for (int index = 0; index < trimmedStudentList.Count; index++)
                trimmedStudentList[index] = (Student) trimmedStudentList[index].GetObjectGraphChanges();

            // set up instructorList
            instructorList = new List<Instructor>
                                 {
                                     new Instructor
                                         {
                                             PersonId = 1,
                                             Name = "Test Instructor One",
                                             Salary = 0,
                                             Courses = new TrackableCollection<Course>
                                                           {
                                                               new Course
                                                                   {
                                                                       CourseId = 1,
                                                                       InstructorId = 1,
                                                                       Title = "Test Course One"
                                                                   },
                                                               new Course
                                                                   {
                                                                       CourseId = 2,
                                                                       InstructorId = 1,
                                                                       Title = "Test Course Two"
                                                                   }
                                                           }
                                         },
                                     new Instructor
                                         {
                                             PersonId = 2,
                                             Name = "Test Instructor Two",
                                             Salary = 0,
                                             Courses = new TrackableCollection<Course>
                                                           {
                                                               new Course
                                                                   {
                                                                       CourseId = 3,
                                                                       InstructorId = 2,
                                                                       Title = "Test Course Three"
                                                                   },
                                                               new Course
                                                                   {
                                                                       CourseId = 4,
                                                                       InstructorId = 2,
                                                                       Title = "Test Course Four"
                                                                   }
                                                           }
                                         },
                                     new Instructor
                                         {
                                             PersonId = 3,
                                             Name = "Test Instructor Three",
                                             Salary = 0,
                                             Courses = new TrackableCollection<Course>
                                                           {
                                                               new Course
                                                                   {
                                                                       CourseId = 5,
                                                                       InstructorId = 3,
                                                                       Title = "Test Course Five"
                                                                   },
                                                               new Course
                                                                   {
                                                                       CourseId = 6,
                                                                       InstructorId = 3,
                                                                       Title = "Test Course Six"
                                                                   }
                                                           }
                                         }
                                 };
            foreach (var c in instructorList.SelectMany(n => n.Courses))
                c.MarkAsUnchanged();
            trimmedInstructorList = new List<Instructor>(instructorList);
            for (int index = 0; index < trimmedInstructorList.Count; index++)
                trimmedInstructorList[index] = (Instructor) trimmedInstructorList[index].GetObjectGraphChanges();

            schoolServiceMock = new Mock<ISchoolServiceClient>();

            schoolServiceMock.Setup(n => n.BeginGetCourses(It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<AsyncCallback, object>((cb, asyncState) => callback = cb);
            schoolServiceMock.Setup(n => n.EndGetCourses(It.IsAny<IAsyncResult>()))
                .Returns(courseList);

            schoolServiceMock.Setup(
                n => n.BeginGetCourseById(It.IsAny<int>(), It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<int, AsyncCallback, object>((courseId, cb, asyncState) => callback = cb);
            schoolServiceMock.Setup(n => n.EndGetCourseById(It.IsAny<IAsyncResult>()))
                .Returns(courseList[0]);

            schoolServiceMock.Setup(
                n => n.BeginGetStudents(It.IsAny<string>(), It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<string, AsyncCallback, object>((includeOption, cb, asyncState) => callback = cb);
            schoolServiceMock.Setup(n => n.EndGetStudents(It.IsAny<IAsyncResult>()))
                .Returns(studentList);

            schoolServiceMock.Setup(
                n => n.BeginGetStudentById(It.IsAny<int>(), It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<int, AsyncCallback, object>((courseId, cb, asyncState) => callback = cb);
            schoolServiceMock.Setup(n => n.EndGetStudentById(It.IsAny<IAsyncResult>()))
                .Returns(studentList[0]);

            schoolServiceMock.Setup(
                n => n.BeginGetInstructors(It.IsAny<string>(), It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<string, AsyncCallback, object>((includeOption, cb, asyncState) => callback = cb);
            schoolServiceMock.Setup(n => n.EndGetInstructors(It.IsAny<IAsyncResult>()))
                .Returns(instructorList);

            schoolServiceMock.Setup(
                n => n.BeginGetInstructorById(It.IsAny<int>(), It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<int, AsyncCallback, object>((courseId, cb, asyncState) => callback = cb);
            schoolServiceMock.Setup(n => n.EndGetInstructorById(It.IsAny<IAsyncResult>()))
                .Returns(instructorList[0]);

            schoolServiceMock.Setup(
                n => n.BeginUpdateCourse(courseList[0], It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<Course, AsyncCallback, object>((c, cb, asyncState) =>
                                                             {
                                                                 var asyncResult =
                                                                     new AsyncResult(courseList[0].CourseId);

                                                                 schoolServiceMock.Setup(
                                                                     n =>
                                                                     n.EndUpdateCourse(asyncResult))
                                                                     .Returns(new List<object> {string.Empty, 1});

                                                                 callback = cb;
                                                                 callback(asyncResult);
                                                             });
            schoolServiceMock.Setup(
                n => n.BeginUpdateCourse(courseList[1], It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<Course, AsyncCallback, object>((c, cb, asyncState) =>
                                                             {
                                                                 var asyncResult =
                                                                     new AsyncResult(courseList[1].CourseId);

                                                                 schoolServiceMock.Setup(
                                                                     n =>
                                                                     n.EndUpdateCourse(asyncResult))
                                                                     .Returns(new List<object> {string.Empty, 2});

                                                                 callback = cb;
                                                                 callback(asyncResult);
                                                             });
            schoolServiceMock.Setup(
                n => n.BeginUpdateCourse(courseList[2], It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<Course, AsyncCallback, object>((c, cb, asyncState) =>
                                                             {
                                                                 var asyncResult =
                                                                     new AsyncResult(courseList[2].CourseId);

                                                                 schoolServiceMock.Setup(
                                                                     n =>
                                                                     n.EndUpdateCourse(asyncResult))
                                                                     .Returns(new List<object> {string.Empty, 3});

                                                                 callback = cb;
                                                                 callback(asyncResult);
                                                             });
            courseAsyncResult = new AsyncResult(courseList[2].CourseId);
            schoolServiceMock.Setup(n => n.EndUpdateCourse(courseAsyncResult))
                .Returns(new List<object> {string.Empty, 3});

            schoolServiceMock.Setup(
                n => n.BeginUpdateStudent(trimmedStudentList[0], It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<Student, AsyncCallback, object>((c, cb, asyncState) =>
                                                              {
                                                                  var asyncResult =
                                                                      new AsyncResult(trimmedStudentList[0].PersonId);

                                                                  schoolServiceMock.Setup(
                                                                      n =>
                                                                      n.EndUpdateStudent(asyncResult))
                                                                      .Returns(new List<object> {string.Empty, 1});

                                                                  callback = cb;
                                                                  callback(asyncResult);
                                                              });
            schoolServiceMock.Setup(
                n => n.BeginUpdateStudent(trimmedStudentList[1], It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<Student, AsyncCallback, object>((c, cb, asyncState) =>
                                                              {
                                                                  var asyncResult =
                                                                      new AsyncResult(trimmedStudentList[1].PersonId);

                                                                  schoolServiceMock.Setup(
                                                                      n =>
                                                                      n.EndUpdateStudent(asyncResult))
                                                                      .Returns(new List<object> {string.Empty, 2});

                                                                  callback = cb;
                                                                  callback(asyncResult);
                                                              });
            schoolServiceMock.Setup(
                n => n.BeginUpdateStudent(trimmedStudentList[2], It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<Student, AsyncCallback, object>((c, cb, asyncState) =>
                                                              {
                                                                  var asyncResult =
                                                                      new AsyncResult(trimmedStudentList[2].PersonId);

                                                                  schoolServiceMock.Setup(
                                                                      n =>
                                                                      n.EndUpdateStudent(asyncResult))
                                                                      .Returns(new List<object> {string.Empty, 3});

                                                                  callback = cb;
                                                                  callback(asyncResult);
                                                              });
            studentAsyncResult = new AsyncResult(studentList[2].PersonId);
            schoolServiceMock.Setup(n => n.EndUpdateStudent(studentAsyncResult))
                .Returns(new List<object> {string.Empty, 3});

            schoolServiceMock.Setup(
                n => n.BeginUpdateInstructor(trimmedInstructorList[0], It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<Instructor, AsyncCallback, object>((c, cb, asyncState) =>
                                                                 {
                                                                     var asyncResult =
                                                                         new AsyncResult(
                                                                             trimmedInstructorList[0].PersonId);

                                                                     schoolServiceMock.Setup(
                                                                         n =>
                                                                         n.EndUpdateInstructor(asyncResult))
                                                                         .Returns(new List<object> {string.Empty, 1});

                                                                     callback = cb;
                                                                     callback(asyncResult);
                                                                 });
            schoolServiceMock.Setup(
                n => n.BeginUpdateInstructor(trimmedInstructorList[1], It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<Instructor, AsyncCallback, object>((c, cb, asyncState) =>
                                                                 {
                                                                     var asyncResult =
                                                                         new AsyncResult(
                                                                             trimmedInstructorList[1].PersonId);

                                                                     schoolServiceMock.Setup(
                                                                         n =>
                                                                         n.EndUpdateInstructor(asyncResult))
                                                                         .Returns(new List<object> {string.Empty, 2});

                                                                     callback = cb;
                                                                     callback(asyncResult);
                                                                 });
            schoolServiceMock.Setup(
                n => n.BeginUpdateInstructor(trimmedInstructorList[2], It.IsAny<AsyncCallback>(), It.IsAny<object>()))
                .Returns(ar)
                .Callback<Instructor, AsyncCallback, object>((c, cb, asyncState) =>
                                                                 {
                                                                     var asyncResult =
                                                                         new AsyncResult(
                                                                             trimmedInstructorList[2].PersonId);

                                                                     schoolServiceMock.Setup(
                                                                         n =>
                                                                         n.EndUpdateInstructor(asyncResult))
                                                                         .Returns(new List<object> {string.Empty, 3});

                                                                     callback = cb;
                                                                     callback(asyncResult);
                                                                 });
            instructorAsyncResult = new AsyncResult(instructorList[2].PersonId);
            schoolServiceMock.Setup(n => n.EndUpdateInstructor(instructorAsyncResult))
                .Returns(new List<object> {string.Empty, 3});
        }

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

        #endregion


        /// <summary>
        ///A test for SchoolModel Constructor
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void SchoolModelConstructorTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            Assert.IsNotNull(target._proxy);
            Assert.IsNotNull(target._actionQueue);
        }

        /// <summary>
        ///A test for BeginGetCourseByIdComplete
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void BeginGetCourseByIdCompleteTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            IAsyncResult result = ar;
            target.BeginGetCourseByIdComplete(result);
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.EndGetCourseById(It.IsAny<IAsyncResult>()), Times.Once());
        }

        /// <summary>
        ///A test for BeginGetCoursesComplete
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void BeginGetCoursesCompleteTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            IAsyncResult result = ar;
            target.BeginGetCoursesComplete(result);
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.EndGetCourses(It.IsAny<IAsyncResult>()), Times.Once());
        }

        /// <summary>
        ///A test for BeginGetInstructorByIdComplete
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void BeginGetInstructorByIdCompleteTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            IAsyncResult result = ar;
            target.BeginGetInstructorByIdComplete(result);
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.EndGetInstructorById(It.IsAny<IAsyncResult>()), Times.Once());
        }

        /// <summary>
        ///A test for BeginGetInstructorsComplete
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void BeginGetInstructorsCompleteTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            IAsyncResult result = ar;
            target.BeginGetInstructorsComplete(result);
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.EndGetInstructors(It.IsAny<IAsyncResult>()), Times.Once());
        }

        /// <summary>
        ///A test for BeginGetStudentByIdComplete
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void BeginGetStudentByIdCompleteTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            IAsyncResult result = ar;
            target.BeginGetStudentByIdComplete(result);
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.EndGetStudentById(It.IsAny<IAsyncResult>()), Times.Once());
        }

        /// <summary>
        ///A test for BeginGetStudentsComplete
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void BeginGetStudentsCompleteTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            IAsyncResult result = ar;
            target.BeginGetStudentsComplete(result);
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.EndGetStudents(It.IsAny<IAsyncResult>()), Times.Once());
        }

        /// <summary>
        ///A test for BeginUpdateCourseComplete
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void BeginUpdateCourseCompleteTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            target.CoursesList = new ObservableCollection<Course>(courseList);
            target.BeginUpdateCourseComplete(courseAsyncResult);
            schoolServiceMock.Verify(n => n.EndUpdateCourse(courseAsyncResult), Times.Once());
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
        }

        /// <summary>
        ///A test for BeginUpdateInstructorComplete
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void BeginUpdateInstructorCompleteTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            target.InstructorsList = new ObservableCollection<Instructor>(instructorList);
            target.BeginUpdateInstructorComplete(instructorAsyncResult);
            schoolServiceMock.Verify(n => n.EndUpdateInstructor(instructorAsyncResult), Times.Once());
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
        }

        /// <summary>
        ///A test for BeginUpdateStudentComplete
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void BeginUpdateStudentCompleteTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            target.StudentsList = new ObservableCollection<Student>(studentList);
            target.BeginUpdateStudentComplete(studentAsyncResult);
            schoolServiceMock.Verify(n => n.EndUpdateStudent(studentAsyncResult), Times.Once());
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
        }

        /// <summary>
        ///A test for GetCourseByIdAsync
        ///</summary>
        [TestMethod]
        public void GetCourseByIdAsyncTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            Course course = null;
            target.GetCourseByIdCompleted += (sender, e) =>
                                                 {
                                                     course = e.Results;
                                                 };
            int courseId = 1;
            target.GetCourseByIdAsync(courseId);
            callback(ar);
            schoolServiceMock.Verify(n => n.IncrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.BeginGetCourseById(courseId, It.IsAny<AsyncCallback>(), null), Times.Once());
            schoolServiceMock.Verify(n => n.EndGetCourseById(It.IsAny<IAsyncResult>()), Times.Once());
            Assert.IsTrue(course.CourseId == 1);
        }

        /// <summary>
        ///A test for GetCoursesAsync
        ///</summary>
        [TestMethod]
        public void GetCoursesAsyncTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            List<Course> courses = null;
            target.GetCoursesCompleted += (sender, e) =>
                                              {
                                                  courses = new List<Course>(e.Results);
                                              };
            string screenName = "CoursePage";
            target.GetCoursesAsync(screenName);
            callback(ar);
            schoolServiceMock.Verify(n => n.IncrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.BeginGetCourses(It.IsAny<AsyncCallback>(), screenName), Times.Once());
            schoolServiceMock.Verify(n => n.EndGetCourses(It.IsAny<IAsyncResult>()), Times.Once());
            Assert.IsTrue(courses.Count == 3);
        }

        /// <summary>
        ///A test for GetInstructorByIdAsync
        ///</summary>
        [TestMethod]
        public void GetInstructorByIdAsyncTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            Instructor instructor = null;
            target.GetInstructorByIdCompleted += (sender, e) =>
                                                     {
                                                         instructor = e.Results;
                                                     };
            int instructorId = 1;
            target.GetInstructorByIdAsync(instructorId);
            callback(ar);
            schoolServiceMock.Verify(n => n.IncrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.BeginGetInstructorById(instructorId, It.IsAny<AsyncCallback>(), null),
                                     Times.Once());
            schoolServiceMock.Verify(n => n.EndGetInstructorById(It.IsAny<IAsyncResult>()), Times.Once());
            Assert.IsTrue(instructor.PersonId == 1);
        }

        /// <summary>
        ///A test for GetInstructorsAsync
        ///</summary>
        [TestMethod]
        public void GetInstructorsAsyncTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            List<Instructor> instructors = null;
            target.GetInstructorsCompleted += (sender, e) =>
                                                  {
                                                      instructors = new List<Instructor>(e.Results);
                                                  };
            string includeOption = "None";
            string screenName = "CoursePage";
            target.GetInstructorsAsync(includeOption, screenName);
            callback(ar);
            schoolServiceMock.Verify(n => n.IncrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.BeginGetInstructors(includeOption, It.IsAny<AsyncCallback>(), screenName),
                                     Times.Once());
            schoolServiceMock.Verify(n => n.EndGetInstructors(It.IsAny<IAsyncResult>()), Times.Once());
            Assert.IsTrue(instructors.Count == 3);
        }

        /// <summary>
        ///A test for GetStudentByIdAsync
        ///</summary>
        [TestMethod]
        public void GetStudentByIdAsyncTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            Student student = null;
            target.GetStudentByIdCompleted += (sender, e) =>
                                                  {
                                                      student = e.Results;
                                                  };
            int studentId = 1;
            target.GetStudentByIdAsync(studentId);
            callback(ar);
            schoolServiceMock.Verify(n => n.IncrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.BeginGetStudentById(studentId, It.IsAny<AsyncCallback>(), null),
                                     Times.Once());
            schoolServiceMock.Verify(n => n.EndGetStudentById(It.IsAny<IAsyncResult>()), Times.Once());
            Assert.IsTrue(student.PersonId == 1);
        }

        /// <summary>
        ///A test for GetStudentsAsync
        ///</summary>
        [TestMethod]
        public void GetStudentsAsyncTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            List<Student> students = null;
            target.GetStudentsCompleted += (sender, e) =>
                                               {
                                                   students = new List<Student>(e.Results);
                                               };
            string includeOption = "None";
            string screenName = "CoursePage";
            target.GetStudentsAsync(includeOption, screenName);
            callback(ar);
            schoolServiceMock.Verify(n => n.IncrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            schoolServiceMock.Verify(n => n.BeginGetStudents(includeOption, It.IsAny<AsyncCallback>(), screenName),
                                     Times.Once());
            schoolServiceMock.Verify(n => n.EndGetStudents(It.IsAny<IAsyncResult>()), Times.Once());
            Assert.IsTrue(students.Count == 3);
        }

        /// <summary>
        ///A test for RejectCourseChanges
        ///</summary>
        [TestMethod]
        public void RejectCourseChanges_allItemsIsTrueTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {
                                         CoursesList = new ObservableCollection<Course>(courseList)
                                     };
            target.RejectCourseChanges();
            Assert.IsFalse(target.CoursesListHasChanges);
            Assert.IsTrue(target.CoursesList.Count == 0);
        }

        /// <summary>
        ///A test for RejectCourseChanges
        ///</summary>
        [TestMethod]
        public void RejectCourseChanges_allItemsIsFalseTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {
                                         CoursesList = new ObservableCollection<Course>(courseList),
                                         CurrentCourse = courseList[0]
                                     };
            target.RejectCourseChanges(false);
            Assert.IsFalse(target.CurrentCourseHasChanges);
            Assert.IsTrue(target.CoursesListHasChanges);
            Assert.IsTrue(target.CoursesList.Count == 2);
        }

        /// <summary>
        ///A test for RejectInstructorChanges
        ///</summary>
        [TestMethod]
        public void RejectInstructorChanges_allItemsIsTrueTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {
                                         InstructorsList = new ObservableCollection<Instructor>(instructorList)
                                     };
            target.RejectInstructorChanges();
            Assert.IsFalse(target.InstructorsListHasChanges);
            Assert.IsTrue(target.InstructorsList.Count == 0);
        }

        /// <summary>
        ///A test for RejectInstructorChanges
        ///</summary>
        [TestMethod]
        public void RejectInstructorChanges_allItemsIsFalseTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {
                                         InstructorsList = new ObservableCollection<Instructor>(instructorList),
                                         CurrentInstructor = instructorList[0]
                                     };
            target.RejectInstructorChanges(false);
            Assert.IsFalse(target.CurrentInstructorHasChanges);
            Assert.IsTrue(target.InstructorsListHasChanges);
            Assert.IsTrue(target.InstructorsList.Count == 2);
        }

        /// <summary>
        ///A test for RejectStudentChanges
        ///</summary>
        [TestMethod]
        public void RejectStudentChanges_allItemsIsTrueTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {
                                         StudentsList = new ObservableCollection<Student>(studentList)
                                     };
            target.RejectStudentChanges();
            Assert.IsFalse(target.StudentsListHasChanges);
            Assert.IsTrue(target.StudentsList.Count == 0);
        }

        /// <summary>
        ///A test for RejectStudentChanges
        ///</summary>
        [TestMethod]
        public void RejectStudentChanges_allItemsIsFalseTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {
                                         StudentsList = new ObservableCollection<Student>(studentList),
                                         CurrentStudent = studentList[0]
                                     };
            target.RejectStudentChanges(false);
            Assert.IsFalse(target.CurrentStudentHasChanges);
            Assert.IsTrue(target.StudentsListHasChanges);
            Assert.IsTrue(target.StudentsList.Count == 2);
        }

        /// <summary>
        ///A test for SaveCourseChangesAsync
        ///</summary>
        [TestMethod]
        public void SaveCourseChangesAsync_allItemsIsTrueTest()
        {
            string warningMessage = "warning";
            bool hasError = true;
            EventWaitHandle waitHandle = new ManualResetEvent(false);

            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {
                                         CoursesList = new ObservableCollection<Course>(courseList)
                                     };
            target.SaveCourseChangesCompleted += (sender, e) =>
                                                     {
                                                         warningMessage = e.Results;
                                                         hasError = e.HasError;
                                                         waitHandle.Set();
                                                     };
            target.SaveCourseChangesAsync();
            waitHandle.WaitOne();
            schoolServiceMock.Verify(n => n.IncrementCallCount(), Times.Once());
            schoolServiceMock.Verify(
                n => n.BeginUpdateCourse(It.IsAny<Course>(), It.IsAny<AsyncCallback>(), It.IsAny<object>()),
                Times.Exactly(3));
            schoolServiceMock.Verify(n => n.EndUpdateCourse(It.IsAny<IAsyncResult>()), Times.Exactly(3));
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            Assert.IsTrue(string.IsNullOrEmpty(warningMessage));
            Assert.IsFalse(hasError);
        }

        /// <summary>
        ///A test for SaveCourseChangesAsync
        ///</summary>
        [TestMethod]
        public void SaveCourseChangesAsync_allItemsIsFalseTest()
        {
            string warningMessage = "warning";
            bool hasError = true;
            EventWaitHandle waitHandle = new ManualResetEvent(false);

            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {
                                         CoursesList = new ObservableCollection<Course>(courseList),
                                         CurrentCourse = courseList[2]
                                     };
            target.SaveCourseChangesCompleted += (sender, e) =>
                                                     {
                                                         warningMessage = e.Results;
                                                         hasError = e.HasError;
                                                         waitHandle.Set();
                                                     };
            target.SaveCourseChangesAsync(false);
            waitHandle.WaitOne();
            schoolServiceMock.Verify(n => n.IncrementCallCount(), Times.Once());
            schoolServiceMock.Verify(
                n => n.BeginUpdateCourse(courseList[2], It.IsAny<AsyncCallback>(), It.IsAny<object>()), Times.Once());
            schoolServiceMock.Verify(n => n.EndUpdateCourse(It.IsAny<IAsyncResult>()), Times.Once());
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            Assert.IsTrue(string.IsNullOrEmpty(warningMessage));
            Assert.IsFalse(hasError);
        }

        /// <summary>
        ///A test for SaveInstructorChangesAsync
        ///</summary>
        [TestMethod]
        public void SaveInstructorChangesAsync_allItemsIsTrueTest()
        {
            string warningMessage = "warning";
            bool hasError = true;
            EventWaitHandle waitHandle = new ManualResetEvent(false);

            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {
                                         InstructorsList = new ObservableCollection<Instructor>(trimmedInstructorList)
                                     };
            target.SaveInstructorChangesCompleted += (sender, e) =>
                                                         {
                                                             warningMessage = e.Results;
                                                             hasError = e.HasError;
                                                             waitHandle.Set();
                                                         };
            target.SaveInstructorChangesAsync();
            waitHandle.WaitOne();
            schoolServiceMock.Verify(n => n.IncrementCallCount(), Times.Once());
            schoolServiceMock.Verify(
                n => n.BeginUpdateInstructor(It.IsAny<Instructor>(), It.IsAny<AsyncCallback>(), It.IsAny<object>()),
                Times.Exactly(3));
            schoolServiceMock.Verify(n => n.EndUpdateInstructor(It.IsAny<IAsyncResult>()), Times.Exactly(3));
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            Assert.IsTrue(string.IsNullOrEmpty(warningMessage));
            Assert.IsFalse(hasError);
        }

        /// <summary>
        ///A test for SaveInstructorChangesAsync
        ///</summary>
        [TestMethod]
        public void SaveInstructorChangesAsync_allItemsIsFalseTest()
        {
            string warningMessage = "warning";
            bool hasError = true;
            EventWaitHandle waitHandle = new ManualResetEvent(false);

            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {
                                         InstructorsList = new ObservableCollection<Instructor>(trimmedInstructorList),
                                         CurrentInstructor = trimmedInstructorList[2]
                                     };
            target.SaveInstructorChangesCompleted += (sender, e) =>
                                                         {
                                                             warningMessage = e.Results;
                                                             hasError = e.HasError;
                                                             waitHandle.Set();
                                                         };
            target.SaveInstructorChangesAsync(false);
            waitHandle.WaitOne();
            schoolServiceMock.Verify(n => n.IncrementCallCount(), Times.Once());
            schoolServiceMock.Verify(
                n => n.BeginUpdateInstructor(trimmedInstructorList[2], It.IsAny<AsyncCallback>(), It.IsAny<object>()),
                Times.Once());
            schoolServiceMock.Verify(n => n.EndUpdateInstructor(It.IsAny<IAsyncResult>()), Times.Once());
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            Assert.IsTrue(string.IsNullOrEmpty(warningMessage));
            Assert.IsFalse(hasError);
        }

        /// <summary>
        ///A test for SaveStudentChangesAsync
        ///</summary>
        [TestMethod]
        public void SaveStudentChangesAsync_allItemsIsTrueTest()
        {
            string warningMessage = "warning";
            bool hasError = true;
            EventWaitHandle waitHandle = new ManualResetEvent(false);

            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {
                                         StudentsList = new ObservableCollection<Student>(trimmedStudentList)
                                     };
            target.SaveStudentChangesCompleted += (sender, e) =>
                                                      {
                                                          warningMessage = e.Results;
                                                          hasError = e.HasError;
                                                          waitHandle.Set();
                                                      };
            target.SaveStudentChangesAsync();
            waitHandle.WaitOne();
            schoolServiceMock.Verify(n => n.IncrementCallCount(), Times.Once());
            schoolServiceMock.Verify(
                n => n.BeginUpdateStudent(It.IsAny<Student>(), It.IsAny<AsyncCallback>(), It.IsAny<object>()),
                Times.Exactly(3));
            schoolServiceMock.Verify(n => n.EndUpdateStudent(It.IsAny<IAsyncResult>()), Times.Exactly(3));
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            Assert.IsTrue(string.IsNullOrEmpty(warningMessage));
            Assert.IsFalse(hasError);
        }

        /// <summary>
        ///A test for SaveStudentChangesAsync
        ///</summary>
        [TestMethod]
        public void SaveStudentChangesAsync_allItemsIsFalseTest()
        {
            string warningMessage = "warning";
            bool hasError = true;
            EventWaitHandle waitHandle = new ManualResetEvent(false);

            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {
                                         StudentsList = new ObservableCollection<Student>(trimmedStudentList),
                                         CurrentStudent = trimmedStudentList[2]
                                     };
            target.SaveStudentChangesCompleted += (sender, e) =>
                                                      {
                                                          warningMessage = e.Results;
                                                          hasError = e.HasError;
                                                          waitHandle.Set();
                                                      };
            target.SaveStudentChangesAsync(false);
            waitHandle.WaitOne();
            schoolServiceMock.Verify(n => n.IncrementCallCount(), Times.Once());
            schoolServiceMock.Verify(
                n => n.BeginUpdateStudent(trimmedStudentList[2], It.IsAny<AsyncCallback>(), It.IsAny<object>()),
                Times.Once());
            schoolServiceMock.Verify(n => n.EndUpdateStudent(It.IsAny<IAsyncResult>()), Times.Once());
            schoolServiceMock.Verify(n => n.DecrementCallCount(), Times.Once());
            Assert.IsTrue(string.IsNullOrEmpty(warningMessage));
            Assert.IsFalse(hasError);
        }

        /// <summary>
        ///A test for ReCalculateCoursesListHasChanges
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void ReCalculateCoursesListHasChangesTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            Assert.IsFalse(target.CoursesListHasChanges);
            target.CoursesList = new ObservableCollection<Course>(courseList);
            target.ReCalculateCoursesListHasChanges();
            Assert.IsTrue(target.CoursesListHasChanges);
        }

        /// <summary>
        ///A test for ReCalculateCurrentCourseHasChanges
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void ReCalculateCurrentCourseHasChangesTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            Assert.IsFalse(target.CurrentCourseHasChanges);
            target.CurrentCourse = courseList[0];
            target.ReCalculateCurrentCourseHasChanges();
            Assert.IsTrue(target.CurrentCourseHasChanges);
        }

        /// <summary>
        ///A test for ReCalculateCurrentInstructorHasChanges
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void ReCalculateCurrentInstructorHasChangesTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            Assert.IsFalse(target.CurrentInstructorHasChanges);
            target.CurrentInstructor = instructorList[0];
            target.ReCalculateCurrentInstructorHasChanges();
            Assert.IsTrue(target.CurrentInstructorHasChanges);
        }

        /// <summary>
        ///A test for ReCalculateCurrentStudentHasChanges
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void ReCalculateCurrentStudentHasChangesTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            Assert.IsFalse(target.CurrentStudentHasChanges);
            target.CurrentStudent = studentList[0];
            target.ReCalculateCurrentStudentHasChanges();
            Assert.IsTrue(target.CurrentStudentHasChanges);
        }

        /// <summary>
        ///A test for ReCalculateInstructorsListHasChanges
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void ReCalculateInstructorsListHasChangesTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            Assert.IsFalse(target.InstructorsListHasChanges);
            target.InstructorsList = new ObservableCollection<Instructor>(instructorList);
            target.ReCalculateInstructorsListHasChanges();
            Assert.IsTrue(target.InstructorsListHasChanges);
        }

        /// <summary>
        ///A test for ReCalculateStudentsListHasChanges
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void ReCalculateStudentsListHasChangesTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            Assert.IsFalse(target.StudentsListHasChanges);
            target.StudentsList = new ObservableCollection<Student>(studentList);
            target.ReCalculateStudentsListHasChanges();
            Assert.IsTrue(target.StudentsListHasChanges);
        }

        /// <summary>
        ///A test for Enrollments_CollectionChanged
        ///</summary>
        [TestMethod]
        public void Enrollments_CollectionChangedTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            var newCourse = new Course
                                {
                                    CourseId = 1,
                                    InstructorId = 1,
                                    Title = "Test Course One"
                                };
            var newEnrollment = new Enrollment
                                    {
                                        EnrollmentId = 1,
                                        CourseId = 1,
                                        StudentId = 1
                                    };

            target.CurrentCourse = newCourse;
            newCourse.Enrollments.Add(newEnrollment);
            newEnrollment.MarkAsUnchanged();
            newCourse.MarkAsUnchanged();
            Assert.IsFalse(target.CurrentCourseHasChanges);
            newEnrollment.StudentId = 2;
            Assert.IsTrue(target.CurrentCourseHasChanges);
        }

        /// <summary>
        ///A test for EntityModel_PropertyChanged
        ///</summary>
        [TestMethod]
        public void EntityModel_PropertyChangedTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            var newCourse = new Course
                                {
                                    CourseId = 1,
                                    InstructorId = 1,
                                    Title = "Test Course One"
                                };
            target.CurrentCourse = newCourse;
            Assert.IsTrue(target.CurrentCourseHasChanges);
            newCourse.MarkAsUnchanged();
            Assert.IsFalse(target.CurrentCourseHasChanges);
        }

        /// <summary>
        ///A test for OnPropertyChanged
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void OnPropertyChangedTest()
        {
            string propertyName = string.Empty;
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            target.add_PropertyChanged((sender, e) =>
                                           {
                                               propertyName = e.PropertyName;
                                           });
            target.OnPropertyChanged("TestPropertyName");
            Assert.IsTrue(propertyName == "TestPropertyName");
        }

        /// <summary>
        ///A test for _coursesList_CollectionChanged
        ///</summary>
        [TestMethod]
        public void _coursesList_CollectionChangedTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {CoursesList = new ObservableCollection<Course>()};
            Assert.IsFalse(target.CoursesListHasChanges);
            target.CoursesList.Add(courseList[0]);
            Assert.IsTrue(target.CoursesListHasChanges);
        }

        /// <summary>
        ///A test for _instructorsList_CollectionChanged
        ///</summary>
        [TestMethod]
        public void _instructorsList_CollectionChangedTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {InstructorsList = new ObservableCollection<Instructor>()};
            Assert.IsFalse(target.InstructorsListHasChanges);
            target.InstructorsList.Add(instructorList[0]);
            Assert.IsTrue(target.InstructorsListHasChanges);
        }

        /// <summary>
        ///A test for _studentsList_CollectionChanged
        ///</summary>
        [TestMethod]
        public void _studentsList_CollectionChangedTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object)
                                     {StudentsList = new ObservableCollection<Student>()};
            Assert.IsFalse(target.StudentsListHasChanges);
            target.StudentsList.Add(studentList[0]);
            Assert.IsTrue(target.StudentsListHasChanges);
        }

        /// <summary>
        ///A test for _proxy_PropertyChanged
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void _proxy_PropertyChangedTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            PropertyChangedEventArgs e = new PropertyChangedEventArgs("ActiveCallCount");
            target._proxy_PropertyChanged(null, e);
            schoolServiceMock.Verify(n => n.ActiveCallCount, Times.Once());
        }

        /// <summary>
        ///A test for ClearLastError
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void ClearLastErrorTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            target._lastError = new Exception();
            target.ClearLastError();
            Assert.IsNull(target._lastError);
        }

        /// <summary>
        ///A test for GetLastError
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void GetLastErrorTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            Exception expected = new Exception();
            target._lastError = expected;
            Exception actual = target.GetLastError();
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for AllowMultipleErrors
        ///</summary>
        [TestMethod]
        public void AllowMultipleErrorsTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            target.AllowMultipleErrors = true;
            bool actual = target.AllowMultipleErrors;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for CoursesList
        ///</summary>
        [TestMethod]
        public void CoursesListTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            ObservableCollection<Course> expected = new ObservableCollection<Course>(courseList);
            target.CoursesList = expected;
            ObservableCollection<Course> actual = target.CoursesList;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for CoursesListHasChanges
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void CoursesListHasChangesTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            target.CoursesListHasChanges = true;
            bool actual = target.CoursesListHasChanges;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for CurrentCourse
        ///</summary>
        [TestMethod]
        public void CurrentCourseTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            Course expected = courseList[0];
            target.CurrentCourse = expected;
            Course actual = target.CurrentCourse;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for CurrentCourseHasChanges
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void CurrentCourseHasChangesTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            target.CurrentCourseHasChanges = true;
            bool actual = target.CurrentCourseHasChanges;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for InstructorsList
        ///</summary>
        [TestMethod]
        public void InstructorsListTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            ObservableCollection<Instructor> expected = new ObservableCollection<Instructor>(instructorList);
            target.InstructorsList = expected;
            ObservableCollection<Instructor> actual = target.InstructorsList;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for InstructorsListHasChanges
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void InstructorsListHasChangesTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            target.InstructorsListHasChanges = true;
            bool actual = target.InstructorsListHasChanges;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for CurrentInstructor
        ///</summary>
        [TestMethod]
        public void CurrentInstructorTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            Instructor expected = instructorList[0];
            target.CurrentInstructor = expected;
            Instructor actual = target.CurrentInstructor;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for CurrentInstructorHasChanges
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void CurrentInstructorHasChangesTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            target.CurrentInstructorHasChanges = true;
            bool actual = target.CurrentInstructorHasChanges;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for StudentsList
        ///</summary>
        [TestMethod]
        public void StudentsListTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            ObservableCollection<Student> expected = new ObservableCollection<Student>(studentList);
            target.StudentsList = expected;
            ObservableCollection<Student> actual = target.StudentsList;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for StudentsListHasChanges
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void StudentsListHasChangesTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            target.StudentsListHasChanges = true;
            bool actual = target.StudentsListHasChanges;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for CurrentStudent
        ///</summary>
        [TestMethod]
        public void CurrentStudentTest()
        {
            SchoolModel target = new SchoolModel(schoolServiceMock.Object);
            Student expected = studentList[0];
            target.CurrentStudent = expected;
            Student actual = target.CurrentStudent;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for CurrentStudentHasChanges
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void CurrentStudentHasChangesTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            target.CurrentStudentHasChanges = true;
            bool actual = target.CurrentStudentHasChanges;
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for IsBusy
        ///</summary>
        [TestMethod]
        [DeploymentItem("SchoolSample.Model.dll")]
        public void IsBusyTest()
        {
            SchoolModel_Accessor target = new SchoolModel_Accessor(schoolServiceMock.Object);
            target.IsBusy = true;
            bool actual = target.IsBusy;
            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
Web04 | 2.8.141022.2 | Last Updated 20 Feb 2012
Article Copyright 2011 by Weidong Shen
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid