Ejemplo n.º 1
0
        public void FromAnswerModel_ToAnswerViewModel_WithoutParentsAndChildren()
        {
            // arrange
            var from = new AnswerModel
            {
                Id          = 1,
                RegionId    = 2,
                GenderId    = 3,
                SchoolingId = 4,
                EthnicityId = 5,
                FirstName   = "First Name",
                LastName    = "Last Name",
                Parents     = new List <AnswerParentChildModel>()
                {
                    new AnswerParentChildModel
                    {
                        Parent = new AnswerModel()
                        {
                            Id          = 6,
                            RegionId    = 7,
                            GenderId    = 8,
                            SchoolingId = 9,
                            EthnicityId = 10,
                            FirstName   = "First Name Parent",
                            LastName    = "Last Name Parent",
                        }
                    }
                },
                Children = new List <AnswerParentChildModel>()
                {
                    new AnswerParentChildModel
                    {
                        Child = new AnswerModel()
                        {
                            Id          = 11,
                            RegionId    = 12,
                            GenderId    = 13,
                            SchoolingId = 14,
                            EthnicityId = 15,
                            FirstName   = "First Name Children",
                            LastName    = "Last Name Children",
                        }
                    }
                }
            };

            // act
            var result = from.ToAnswerViewModel(false);

            // assert
            Assert.Equal(result.Info.Id, from.Id);
            Assert.Equal(result.Info.EthnicityCode, from.EthnicityId);
            Assert.Equal(result.Info.GenderCode, from.GenderId);
            Assert.Equal(result.Info.SchoolingCode, from.SchoolingId);
            Assert.Equal(result.Info.RegionCode, from.RegionId);
            Assert.Equal(result.Info.FirstName, from.FirstName);
            Assert.Equal(result.Info.LastName, from.LastName);

            Assert.Null(result.ChildrenInfo);
            Assert.Null(result.ParentsInfo);
        }
Ejemplo n.º 2
0
        public void FromAnwserModel_ToAnswerViewModel_WithParentsAndChildren()
        {
            // arrange
            var from = new AnswerModel
            {
                Id          = 1,
                RegionId    = 2,
                GenderId    = 3,
                SchoolingId = 4,
                EthnicityId = 5,
                FirstName   = "First Name",
                LastName    = "Last Name",
                Parents     = new List <AnswerParentChildModel>()
                {
                    new AnswerParentChildModel
                    {
                        Parent = new AnswerModel()
                        {
                            Id          = 6,
                            RegionId    = 7,
                            GenderId    = 8,
                            SchoolingId = 9,
                            EthnicityId = 10,
                            FirstName   = "First Name Parent",
                            LastName    = "Last Name Parent",
                        }
                    }
                },
                Children = new List <AnswerParentChildModel>()
                {
                    new AnswerParentChildModel
                    {
                        Child = new AnswerModel()
                        {
                            Id          = 11,
                            RegionId    = 12,
                            GenderId    = 13,
                            SchoolingId = 14,
                            EthnicityId = 15,
                            FirstName   = "First Name Children",
                            LastName    = "Last Name Children",
                        }
                    }
                }
            };

            // act
            var result = from.ToAnswerViewModel();

            // assert
            var childrenInfo = result.ChildrenInfo.ToList();
            var parentInfo   = result.ParentsInfo.ToList();

            Assert.Equal(result.Info.Id, from.Id);
            Assert.Equal(result.Info.EthnicityCode, from.EthnicityId);
            Assert.Equal(result.Info.GenderCode, from.GenderId);
            Assert.Equal(result.Info.SchoolingCode, from.SchoolingId);
            Assert.Equal(result.Info.RegionCode, from.RegionId);
            Assert.Equal(result.Info.FirstName, from.FirstName);
            Assert.Equal(result.Info.LastName, from.LastName);

            Assert.Equal(childrenInfo[0].Id, from.Children[0].Child.Id);
            Assert.Equal(childrenInfo[0].EthnicityCode, from.Children[0].Child.EthnicityId);
            Assert.Equal(childrenInfo[0].GenderCode, from.Children[0].Child.GenderId);
            Assert.Equal(childrenInfo[0].SchoolingCode, from.Children[0].Child.SchoolingId);
            Assert.Equal(childrenInfo[0].RegionCode, from.Children[0].Child.RegionId);
            Assert.Equal(childrenInfo[0].FirstName, from.Children[0].Child.FirstName);
            Assert.Equal(childrenInfo[0].LastName, from.Children[0].Child.LastName);

            Assert.Equal(parentInfo[0].Id, from.Parents[0].Parent.Id);
            Assert.Equal(parentInfo[0].EthnicityCode, from.Parents[0].Parent.EthnicityId);
            Assert.Equal(parentInfo[0].GenderCode, from.Parents[0].Parent.GenderId);
            Assert.Equal(parentInfo[0].SchoolingCode, from.Parents[0].Parent.SchoolingId);
            Assert.Equal(parentInfo[0].RegionCode, from.Parents[0].Parent.RegionId);
            Assert.Equal(parentInfo[0].FirstName, from.Parents[0].Parent.FirstName);
            Assert.Equal(parentInfo[0].LastName, from.Parents[0].Parent.LastName);
        }