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);
 }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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 { }
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        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);
        }
        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);
        }
Ejemplo n.º 7
0
        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);
        }
        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);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
 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;
 }
        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);
        }