internal static void SynchroniseEntityList <T>( List <T> upToDateList, System.Data.Objects.DataClasses.EntityCollection <T> oldList) where T : System.Data.Objects.DataClasses.EntityObject { try { if (!oldList.IsLoaded) { oldList.Load(); } List <T> toRemove = new List <T>(); foreach (T obj in oldList) { if (!upToDateList.Contains(obj)) { toRemove.Add(obj); } } foreach (T obj in toRemove) { oldList.Remove(obj); } foreach (T obj in upToDateList) { if (!oldList.Contains(obj)) { oldList.Add(obj); } } } catch { } }
public void CreatePoll(string pollQuestion, string[] pollOptions, int threadID) { System.Data.Objects.DataClasses.EntityCollection<PollOption> toadd = new System.Data.Objects.DataClasses.EntityCollection<PollOption>(); foreach (string po in pollOptions) { toadd.Add(new PollOption { Text = po, PollID = threadID }); } Poll ThePoll = new Poll { PollOptions = toadd, Question = pollQuestion, PollID = threadID }; _pollRepository.Add(ThePoll); Thread thread = _threadRepository.Get(threadID); thread.HasPoll = true; _threadRepository.Update(thread); _unitOfWork.Commit(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { System.Data.Objects.DataClasses.EntityCollection <Structure> two1 = (value as System.Data.Objects.DataClasses.EntityCollection <Structure>); string two = ((from e in two1 select e.Item1.Name).First <string>()); return(two); }
public void CreatePoll(string pollQuestion, string[] pollOptions, int threadID) { System.Data.Objects.DataClasses.EntityCollection <PollOption> toadd = new System.Data.Objects.DataClasses.EntityCollection <PollOption>(); foreach (string po in pollOptions) { toadd.Add(new PollOption { Text = po, PollID = threadID }); } Poll ThePoll = new Poll { PollOptions = toadd, Question = pollQuestion, PollID = threadID }; _pollRepository.Add(ThePoll); Thread thread = _threadRepository.Get(threadID); thread.HasPoll = true; _threadRepository.Update(thread); _unitOfWork.Commit(); }
public static List <T> GetPageContentList <T>(this System.Data.Objects.DataClasses.EntityCollection <T> pageContentList) where T : PageContent { if (!pageContentList.IsLoaded) { pageContentList.Load(); } return(pageContentList.ToList()); }
/// <summary> /// Maps an item and returns it in a collection /// </summary> /// <param name="source">Source Class</param> /// <returns>Collection of Mapped items</returns> /// <remarks>This method is used to wrap a single entity into a collection</remarks> public Complaint MapToCollection(System.Data.Objects.DataClasses.EntityCollection <SR.Complaint> source) { Complaint complaint = null; if (source.Count > 0) { complaint = this.Map(source.First()); } return(complaint); }
public static Html GetHtml <T>(this System.Data.Objects.DataClasses.EntityCollection <T> htmlList, string name) where T : Html { var htmls = (from html in htmlList where (html.Name.Equals(name)) select html); if (htmls == null) { return(null); } return(htmls.FirstOrDefault()); }
public void MustFillFirstAlertHeaderWithEntityObject() { //Arrange Mock<IFirstAlertView> mockView = new Mock<IFirstAlertView>(); Mock<FirstAlertModel> mockModel = new Mock<FirstAlertModel>(); System.Data.Objects.DataClasses.EntityCollection<CS_FirstAlertDivision> divisions = new System.Data.Objects.DataClasses.EntityCollection<CS_FirstAlertDivision>(); divisions.Add(new CS_FirstAlertDivision() { CS_Division = new CS_Division() {ID=1, Name="001"}}); divisions.Add(new CS_FirstAlertDivision() { CS_Division = new CS_Division() {ID=1, Name="002"}}); CS_FirstAlert firstAlertStub = new CS_FirstAlert() { ID=1, CS_Job = new CS_Job() { ID=1, Number = "1234"}, CS_Customer = new CS_Customer() {ID=2, Name = "Customer 1" }, CS_Employee_InCharge = new CS_Contact() { ID = 2, Name = "Peter", LastName = "Parker", Active = true}, CS_FirstAlertDivision = divisions, Date = new DateTime(2011, 7, 12, 5, 0, 0), CS_Country = new CS_Country() { ID = 1, Name = "USA" }, CS_State = new CS_State() { ID = 1, Name = "Florida" }, CS_City = new CS_City() { ID = 1, Name = "Miami" }, ReportedBy = "danilo", CS_Employee_CompletedBy = new CS_Employee() { ID = 1, FirstName = "Danilo", Name = "Ruziska" }, Details = "details", HasPoliceReport = true, PoliceAgency = "agency", PoliceReportNumber = "1234" } ; mockView.SetupProperty(e => e.FirstAlertID, 1); mockView.SetupProperty(e => e.FirstAlertEntity, null); mockModel.Setup(e => e.GetFirstAlertById(1)).Returns(firstAlertStub); FirstAlertPresenter presenter = new FirstAlertPresenter(mockView.Object, mockModel.Object); //Act presenter.FillFirstAlertHeaderFields(); //Assert Assert.AreEqual(firstAlertStub.CS_Job.Number, mockView.Object.FirstAlertEntity.CS_Job.Number); Assert.AreEqual(firstAlertStub.CS_Customer.ID, mockView.Object.FirstAlertEntity.CS_Customer.ID); Assert.AreEqual(firstAlertStub.CS_Employee_InCharge.ID, mockView.Object.FirstAlertEntity.CS_Employee_InCharge.ID); Assert.AreEqual(firstAlertStub.CS_FirstAlertDivision.Count, mockView.Object.FirstAlertEntity.CS_FirstAlertDivision.Count); Assert.AreEqual(firstAlertStub.Date, mockView.Object.FirstAlertEntity.Date); Assert.AreEqual(firstAlertStub.CS_Country.ID, mockView.Object.FirstAlertEntity.CS_Country.ID); Assert.AreEqual(firstAlertStub.CS_City.ID, mockView.Object.FirstAlertEntity.CS_City.ID); Assert.AreEqual(firstAlertStub.CS_State.ID, mockView.Object.FirstAlertEntity.CS_State.ID); Assert.AreEqual(firstAlertStub.ReportedBy, mockView.Object.FirstAlertEntity.ReportedBy); Assert.AreEqual(firstAlertStub.CS_Employee_CompletedBy.ID, mockView.Object.FirstAlertEntity.CS_Employee_CompletedBy.ID); Assert.AreEqual(firstAlertStub.ReportedBy, mockView.Object.FirstAlertEntity.ReportedBy); Assert.AreEqual(firstAlertStub.Details, mockView.Object.FirstAlertEntity.Details); Assert.AreEqual(firstAlertStub.HasPoliceReport, mockView.Object.FirstAlertEntity.HasPoliceReport); Assert.AreEqual(firstAlertStub.PoliceAgency, mockView.Object.FirstAlertEntity.PoliceAgency); Assert.AreEqual(firstAlertStub.PoliceReportNumber, mockView.Object.FirstAlertEntity.PoliceReportNumber); }
public static Content GetContent <T>(this System.Data.Objects.DataClasses.EntityCollection <T> contentList, string contentName) where T : Content { if (!contentList.IsLoaded) { contentList.Load(); } var contents = (from content in contentList where (content.Name.Equals(contentName)) select content); if (contents == null) { return(null); } return(contents.FirstOrDefault()); }
public static List <T> GetPageContentList <T>(this System.Data.Objects.DataClasses.EntityCollection <T> pageContentList, string placeHolder) where T : PageContent { if (!pageContentList.IsLoaded) { pageContentList.Load(); } var pageContents = (from pageContent in pageContentList where (pageContent.PlaceHolderName.Equals(placeHolder)) orderby pageContent.Ordinal select pageContent); if (pageContents == null) { return(null); } return(pageContents.ToList()); }
internal static System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.EmailLogo> ToEntityCollection(List <EmailLogoBO> bos, IndicoEntities context) { // build an EntityCollection of EmailLogo entities from the business objects List <Int32> ids = (from o in bos select o.ID).ToList <Int32>(); List <Indico.DAL.EmailLogo> el = (context.EmailLogo.Count() == 0) ? new List <Indico.DAL.EmailLogo>() : context.EmailLogo.Where(BuildContainsExpression <EmailLogo, int>(e => e.ID, ids)) .ToList <Indico.DAL.EmailLogo>(); System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.EmailLogo> ec = new System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.EmailLogo>(); foreach (Indico.DAL.EmailLogo r in el) { ec.Add(r); } return(ec); }
public void ConfigurateForStudent() { this.grid1.Visibility = System.Windows.Visibility.Visible; this.grid1.IsHitTestVisible = true; this.bCurWeek.Visibility = System.Windows.Visibility.Visible; this.bAllGroups.Visibility = System.Windows.Visibility.Visible; this.bMySchedule.Visibility = System.Windows.Visibility.Visible; this.bShowSchedule.Visibility = System.Windows.Visibility.Visible; this.bMySchedule2.Visibility = System.Windows.Visibility.Visible; this.selfScheduleAction = this.SelfSchedule_Student; if (DBController.Instance.User != null) { this.lessonCollection = DBController.Instance.User.studentsgroup.lessons; } this.ShowSchedule(true); }
internal static System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.AcquiredVisulaLayoutName> ToEntityCollection(List <AcquiredVisulaLayoutNameBO> bos, IndicoEntities context) { // build an EntityCollection of AcquiredVisulaLayoutName entities from the business objects List <Int32> ids = (from o in bos select o.ID).ToList <Int32>(); List <Indico.DAL.AcquiredVisulaLayoutName> el = (context.AcquiredVisulaLayoutName.Count() == 0) ? new List <Indico.DAL.AcquiredVisulaLayoutName>() : context.AcquiredVisulaLayoutName.Where(BuildContainsExpression <AcquiredVisulaLayoutName, int>(e => e.ID, ids)) .ToList <Indico.DAL.AcquiredVisulaLayoutName>(); System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.AcquiredVisulaLayoutName> ec = new System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.AcquiredVisulaLayoutName>(); foreach (Indico.DAL.AcquiredVisulaLayoutName r in el) { ec.Add(r); } return(ec); }
public Thread CreateThread( int forumID, int userID, string threadTitle, ThreadType threadType, string threadImage, string message, string pollText, string[] pollOptions, HttpPostedFileBase[] files) { Thread thread = new Thread { ForumID = forumID, Type = (int)threadType, Image = threadImage, Title = threadTitle, HasPoll = false }; string parsedMessage = _parseServices.ParseBBCodeText(message); var firstPost = new Post() { UserID = userID, Date = DateTime.UtcNow, ThreadID = thread.ThreadID, TextOnly = _parseServices.GetTextOnly(message), Text = message, ParsedText = parsedMessage }; thread.Posts.Add(firstPost); if (!string.IsNullOrWhiteSpace(pollText)) { Poll poll = new Poll { Question = pollText, PollID = thread.ThreadID }; thread.Poll = poll; var options = new System.Data.Objects.DataClasses.EntityCollection<PollOption>(); foreach (string po in pollOptions) { poll.PollOptions.Add(new PollOption { Text = po }); } thread.HasPoll = true; } if (files != null) { foreach (var file in files) { string savedName = _fileServices.UploadFile(file); firstPost.Attachments.Add(new Attachment() { Downloaded = 0, SavedName = savedName, DownloadName = file.FileName, Size = file.ContentLength, Type = file.ContentType }); } } _threadRepository.Add(thread); _unitOfWork.Commit(); return thread; }
public Thread CreateThread( int forumID, int userID, string threadTitle, ThreadType threadType, string threadImage, string message, string pollText, string[] pollOptions, HttpPostedFileBase[] files) { Thread thread = new Thread { ForumID = forumID, Type = (int)threadType, Image = threadImage, Title = threadTitle, HasPoll = false }; string parsedMessage = _parseServices.ParseBBCodeText(message); var firstPost = new Post() { UserID = userID, Date = DateTime.UtcNow, ThreadID = thread.ThreadID, TextOnly = _parseServices.GetTextOnly(message), Text = message, ParsedText = parsedMessage }; thread.Posts.Add(firstPost); if (!string.IsNullOrWhiteSpace(pollText)) { Poll poll = new Poll { Question = pollText, PollID = thread.ThreadID }; thread.Poll = poll; var options = new System.Data.Objects.DataClasses.EntityCollection <PollOption>(); foreach (string po in pollOptions) { poll.PollOptions.Add(new PollOption { Text = po }); } thread.HasPoll = true; } if (files != null) { foreach (var file in files) { string savedName = _fileServices.UploadFile(file); firstPost.Attachments.Add(new Attachment() { Downloaded = 0, SavedName = savedName, DownloadName = file.FileName, Size = file.ContentLength, Type = file.ContentType }); } } _threadRepository.Add(thread); _unitOfWork.Commit(); return(thread); }
internal static System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.FactoryPriceRemarks> ToEntityCollection(List <FactoryPriceRemarksBO> bos, IndicoEntities context) { // build an EntityCollection of FactoryPriceRemarks entities from the business objects List <Int32> ids = (from o in bos select o.ID).ToList <Int32>(); List <Indico.DAL.FactoryPriceRemarks> el = (context.FactoryPriceRemarks.Count() == 0) ? new List <Indico.DAL.FactoryPriceRemarks>() : context.FactoryPriceRemarks.Where(BuildContainsExpression <FactoryPriceRemarks, int>(e => e.ID, ids)) .ToList <Indico.DAL.FactoryPriceRemarks>(); System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.FactoryPriceRemarks> ec = new System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.FactoryPriceRemarks>(); foreach (Indico.DAL.FactoryPriceRemarks r in el) { ec.Add(r); } return(ec); }
internal static System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.PatternItemAttributeSub> ToEntityCollection(List <PatternItemAttributeSubBO> bos, IndicoEntities context) { // build an EntityCollection of PatternItemAttributeSub entities from the business objects List <Int32> ids = (from o in bos select o.ID).ToList <Int32>(); List <Indico.DAL.PatternItemAttributeSub> el = (context.PatternItemAttributeSub.Count() == 0) ? new List <Indico.DAL.PatternItemAttributeSub>() : context.PatternItemAttributeSub.Where(BuildContainsExpression <PatternItemAttributeSub, int>(e => e.ID, ids)) .ToList <Indico.DAL.PatternItemAttributeSub>(); System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.PatternItemAttributeSub> ec = new System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.PatternItemAttributeSub>(); foreach (Indico.DAL.PatternItemAttributeSub r in el) { ec.Add(r); } return(ec); }
public static List <GiftCertificateDetailsViewModel> GenerateListOfGiftCertificateDetailsViewModel(System.Data.Objects.DataClasses.EntityCollection <GiftCertificateDetail> entityCollection) { var details = new List <GiftCertificateDetailsViewModel>(); foreach (var giftDetail in entityCollection) { details.Add(GenerateGiftCertificateDetailsViewModel(giftDetail)); } return(details); }
void SelfSchedule_Student(Object data) { //Set this.lessonCollection to student.lessons and invoke ShowSchedule method if (DBController.Instance.User != null) { this.lessonCollection = DBController.Instance.User.studentsgroup.lessons; } this.ShowSchedule(true); }
internal static System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.DistributorPriceLevelCost> ToEntityCollection(List <DistributorPriceLevelCostBO> bos, IndicoEntities context) { // build an EntityCollection of DistributorPriceLevelCost entities from the business objects List <Int32> ids = (from o in bos select o.ID).ToList <Int32>(); List <Indico.DAL.DistributorPriceLevelCost> el = (context.DistributorPriceLevelCost.Count() == 0) ? new List <Indico.DAL.DistributorPriceLevelCost>() : context.DistributorPriceLevelCost.Where(BuildContainsExpression <DistributorPriceLevelCost, int>(e => e.ID, ids)) .ToList <Indico.DAL.DistributorPriceLevelCost>(); System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.DistributorPriceLevelCost> ec = new System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.DistributorPriceLevelCost>(); foreach (Indico.DAL.DistributorPriceLevelCost r in el) { ec.Add(r); } return(ec); }
internal static System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.VisualLayoutAccessory> ToEntityCollection(List <VisualLayoutAccessoryBO> bos, IndicoEntities context) { // build an EntityCollection of VisualLayoutAccessory entities from the business objects List <Int32> ids = (from o in bos select o.ID).ToList <Int32>(); List <Indico.DAL.VisualLayoutAccessory> el = (context.VisualLayoutAccessory.Count() == 0) ? new List <Indico.DAL.VisualLayoutAccessory>() : context.VisualLayoutAccessory.Where(BuildContainsExpression <VisualLayoutAccessory, int>(e => e.ID, ids)) .ToList <Indico.DAL.VisualLayoutAccessory>(); System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.VisualLayoutAccessory> ec = new System.Data.Objects.DataClasses.EntityCollection <Indico.DAL.VisualLayoutAccessory>(); foreach (Indico.DAL.VisualLayoutAccessory r in el) { ec.Add(r); } return(ec); }
public override void Run() { //记时器 System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); System.Data.Objects.DataClasses.EntityCollection <TygModel.文章表> docs = Book.文章表; int count = docs.Count; int index = 0; List <string> progress = new List <string>(); if (System.IO.File.Exists(ProgressFileName)) { progress = System.IO.File.ReadAllLines(ProgressFileName).ToList(); } //创建目录 if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(ProgressFileName))) { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(ProgressFileName)); } ///全部重新创建 if (IsCreateNew) { System.IO.File.WriteAllText(ProgressFileName, string.Empty); } watch.Reset(); System.Console.WriteLine(string.Format("{0},生成目录", Book.书名)); //重新生成目录 string urlIndex = string.Format(UrlIndex, Book.GUID); GetWebUrl(urlIndex); string dirserver = string.Format(createDirUrl, System.IO.Path.GetDirectoryName("/" + Book.GetHTMLFilePath())); //创建目录 string dic = GetWebDic(dirserver); if (!string.IsNullOrEmpty(dic)) { //生成没有成功 //移动当前工作目录 ftp.GotoDirectory(BaseFtpDic + Book.GetHTMLFilePath().Replace("/index.html", string.Empty), true); string dirindex = BaseWebSite + "HTML/" + Book.分类标识.Trim().ToPingYing() + "/" + Book.书名.Trim().ToPingYing() + "/index.html"; //ftp上传文件 if (Upload(dirindex)) { System.Console.WriteLine(string.Format("FTP {0},生成目录---------完成,用时{1}秒", Book.书名, Math.Round(watch.ElapsedMilliseconds / 1000.0, 2))); } } System.Console.WriteLine(string.Format("{0},生成目录---------完成,用时{1}秒", Book.书名, Math.Round(watch.ElapsedMilliseconds / 1000.0, 2))); //生成明细项 foreach (var item in docs) { //这里处理有点问题,他不能在上次关闭的时候接着生成 if (!IsCreateNew) { //如果有则不进行重新生成 if (progress.Contains(item.本记录GUID.ToString() + ((char)2) + item.章节名)) { index++; continue; } } //计时 watch.Reset(); string url = string.Format(UrlDoc, item.ID); GetWebUrl(url); //生成目录成功 if (!string.IsNullOrEmpty(dic)) { string dir = BaseWebSite + "HTML/" + Book.分类标识.Trim().ToPingYing() + "/" + Book.书名.Trim().ToPingYing() + "/" + item.ID + ".html"; //ftp上传文件 if (Upload(dir)) { //采集完成一个记录一个 System.IO.File.AppendAllLines(ProgressFileName, new string[] { item.本记录GUID.ToString() + ((char)2) + item.章节名 }); //输出当前进度 System.Console.WriteLine(string.Format("FTP {0},进度{1}/{2},名称:{3},url:{4},用时:{5}秒", Book.书名, index, count, item.章节名, url, Math.Round(watch.ElapsedMilliseconds / 1000.0, 0))); } } index++; watch.Stop(); //输出当前进度 System.Console.WriteLine(string.Format("{0},进度{1}/{2},名称:{3},url:{4},用时:{5}秒", Book.书名, index, count, item.章节名, url, Math.Round(watch.ElapsedMilliseconds / 1000.0, 0))); } ftp = null; }
void SelfSchedule_Teacher(Object data) { //Set this.lessonCollection to teacher.lessons and invoke ShowSchedule method if (DBController.Instance.User != null) { this.lessonCollection = DBController.Instance.User.lessons; } this.ShowSchedule(true); }
public static System.Data.Objects.DataClasses.EntityCollection<PMS.Model.Context.PMS_CYCLE_STAGE> MapCycleStageDTOsToEntities(List<PMS.Model.DTO.Cycle.Stage> dto) { System.Data.Objects.DataClasses.EntityCollection<PMS.Model.Context.PMS_CYCLE_STAGE> lst_entities = new System.Data.Objects.DataClasses.EntityCollection<Context.PMS_CYCLE_STAGE>(); foreach (PMS.Model.DTO.Cycle.Stage obj_entity in dto) { lst_entities.Add(MapCycleStageDTOToEntity(obj_entity)); } return lst_entities; }
void ShowSchedule(bool IsMine = false) { if (IsMine) { this.tbGroupName.Text = "Ваше расписание"; } else { studentsgroup sg = (studentsgroup)this.groupList.SelectedItem; if (sg != null) { this.lessonCollection = sg.lessons; this.tbGroupName.Text = "Группа " + sg.Name; } } this.timeTable.FirstDay = this.GetCurrentWeekMonday(); this.timeTable.FillTable(DBModel.Instance.GetLessonsByPeriodAndRef(this.lessonCollection, this.timeTable.FirstDay, this.timeTable.FirstDay.AddDays(14))); this.ShowTimeTable(); }
public void ConfigurateForTeacher() { this.grid1.Visibility = System.Windows.Visibility.Visible; this.grid1.IsHitTestVisible = true; this.bCurWeek.Visibility = System.Windows.Visibility.Visible; this.bAllGroups.Visibility = System.Windows.Visibility.Visible; this.bMySchedule.Visibility = System.Windows.Visibility.Visible; this.bShowSchedule.Visibility = System.Windows.Visibility.Visible; this.bMySchedule2.Visibility = System.Windows.Visibility.Visible; this.selfScheduleAction = this.SelfSchedule_Teacher; this.cellDoubleClickedAction = this.CellDoubleClicked_Teacher; if (DBController.Instance.User != null) { this.lessonCollection = DBController.Instance.User.lessons; } this.ShowSchedule(true); }
public void MustReturnEmployeeInfo() { //Arrange Mock<IEmployeeMaintenanceView> mockView = new Mock<IEmployeeMaintenanceView>(); Mock<EmployeeModel> mockModel = new Mock<EmployeeModel>(); System.Data.Objects.DataClasses.EntityCollection<CS_EmployeeEmergencyContact> employeeContacts = new System.Data.Objects.DataClasses.EntityCollection<CS_EmployeeEmergencyContact>(); employeeContacts.Add(new CS_EmployeeEmergencyContact() { Active = true, EmployeeID = 1, FirstName = "Margie", LastName = "Simpson", HomeAreaCode = "11", HomePhone = "89431267" }); CS_Employee employeeStub = new CS_Employee() { ID = 1, PersonID = "123", FirstName = "Danilo", Name = "Ruziska", HireDate = new DateTime(2011, 8, 31), Address = "Elm Street, 123", Address2 = "Third Floor", City = "Houston", StateProvinceCode = "TX", CountryCode = "USA", PostalCode = "12345", BusinessCardTitle = "Software Developer", CS_Division = new CS_Division() { ID = 1, Active = true, Name = "001" }, PassportNumber = "12345abc", CS_EmployeeEmergencyContact = employeeContacts, HomeAreaCode = "11", HomePhone = "123456", MobileAreaCode = "12", MobilePhone = "34567", OtherPhoneAreaCode = "13", OtherPhone = "98765", IsDentonPersonal = true, DriversLicenseNumber = "123", DriversLicenseClass = "A", DriversLicenseStateProvinceCode = "TX", DriversLicenseExpireDate = new DateTime(2012, 12, 21) }; mockView.SetupProperty(e => e.EmployeeId, 1); mockView.SetupProperty(e => e.EmployeeName, ""); mockView.SetupProperty(e => e.HireDate, null); mockView.SetupProperty(e => e.PersonID, ""); mockView.SetupProperty(e => e.Address, ""); mockView.SetupProperty(e => e.Address2, ""); mockView.SetupProperty(e => e.City, ""); mockView.SetupProperty(e => e.State, ""); mockView.SetupProperty(e => e.Country, ""); mockView.SetupProperty(e => e.PostalCode, ""); mockView.SetupProperty(e => e.Position, ""); mockView.SetupProperty(e => e.EmployeeDivision, ""); mockView.SetupProperty(e => e.PassportNumber, ""); mockView.SetupProperty(e => e.EmployeeContacts, null); mockView.SetupProperty(e => e.HomePhone, ""); mockView.SetupProperty(e => e.HomeAreaCode, ""); mockView.SetupProperty(e => e.MobileAreaCode, ""); mockView.SetupProperty(e => e.MobilePhone, ""); mockView.SetupProperty(e => e.OtherPhoneAreaCode, ""); mockView.SetupProperty(e => e.OtherPhone, ""); mockView.SetupProperty(e => e.IsDentonPersonal, false); mockView.SetupProperty(e => e.DriversLicenseNumber, ""); mockView.SetupProperty(e => e.DriversLicenseClass, ""); mockView.SetupProperty(e => e.DriversLicenseState, ""); mockView.SetupProperty(e => e.DriversLicenseExpireDate, null); mockModel.Setup(e => e.GetEmployee(1)).Returns(employeeStub); EmployeeMaintenancePresenter presenter = new EmployeeMaintenancePresenter(mockView.Object, mockModel.Object); //Act presenter.LoadEmployeeInfo(); //Assert Assert.AreEqual("Danilo,Ruziska", mockView.Object.EmployeeName); Assert.AreEqual(new DateTime(2011, 8, 31), mockView.Object.HireDate); Assert.AreEqual("123", mockView.Object.PersonID); Assert.AreEqual("Software Developer", mockView.Object.Position); Assert.AreEqual("001", mockView.Object.EmployeeDivision); Assert.AreEqual("12345abc", mockView.Object.PassportNumber); Assert.AreEqual(1, mockView.Object.EmployeeContacts.Count); Assert.AreEqual("Elm Street, 123", mockView.Object.Address); Assert.AreEqual("Third Floor", mockView.Object.Address2); Assert.AreEqual("Houston", mockView.Object.City); Assert.AreEqual("TX", mockView.Object.State); Assert.AreEqual("USA", mockView.Object.Country); Assert.AreEqual("12345", mockView.Object.PostalCode); Assert.AreEqual("11", mockView.Object.HomeAreaCode); Assert.AreEqual("123456", mockView.Object.HomePhone); Assert.AreEqual("12", mockView.Object.MobileAreaCode); Assert.AreEqual("34567", mockView.Object.MobilePhone); Assert.AreEqual("13", mockView.Object.OtherPhoneAreaCode); Assert.AreEqual("98765", mockView.Object.OtherPhone); Assert.IsTrue(mockView.Object.IsDentonPersonal); Assert.AreEqual("123", mockView.Object.DriversLicenseNumber); Assert.AreEqual("A", mockView.Object.DriversLicenseClass); Assert.AreEqual("TX", mockView.Object.DriversLicenseState); Assert.AreEqual(new DateTime(2012, 12, 21), mockView.Object.DriversLicenseExpireDate); }