Exemplo n.º 1
0
        public void AddAnswers(LinkPdpSetView linkPdpSetView)
        {
            var listItems = GetListItems();


            linkPdpSetView.Answers.AddRange(new List <LinkPdpAnswerView> {
                new LinkPdpAnswerView {
                    Answer            = "Added Test answer 1",
                    LinkPdpQuestionId = 4,
                    LinkPdpSetId      = linkPdpSetView.Id,
                    Question          = listItems.First(e => e.Id == 4),
                    CreatedDate       = DateTime.Today.AddMinutes(10),
                    PdpQuestionGroup  = linkPdpSetView.PdpQuestionGroup.First(w => w.SectionId == 1)
                },
                new LinkPdpAnswerView {
                    Answer            = "Added Test answer 2",
                    LinkPdpQuestionId = 5,
                    LinkPdpSetId      = linkPdpSetView.Id,
                    Question          = listItems.First(e => e.Id == 5),
                    CreatedDate       = DateTime.Today.AddMinutes(10),
                    PdpQuestionGroup  = linkPdpSetView.PdpQuestionGroup.First(w => w.SectionId == 1)
                },
                new LinkPdpAnswerView {
                    Answer            = "Added Test answer 3",
                    LinkPdpQuestionId = 6,
                    LinkPdpSetId      = linkPdpSetView.Id,
                    Question          = listItems.First(e => e.Id == 6),
                    CreatedDate       = DateTime.Today.AddMinutes(10),
                    PdpQuestionGroup  = linkPdpSetView.PdpQuestionGroup.First(w => w.SectionId == 1)
                },
                new LinkPdpAnswerView {
                    Answer            = "Added Test answer 1",
                    LinkPdpQuestionId = 7,
                    LinkPdpSetId      = linkPdpSetView.Id,
                    Question          = listItems.First(e => e.Id == 7),
                    CreatedDate       = DateTime.Today.AddMinutes(10),
                    PdpQuestionGroup  = linkPdpSetView.PdpQuestionGroup.First(w => w.SectionId == 2)
                },
                new LinkPdpAnswerView {
                    Answer            = "Added Test answer 2",
                    LinkPdpQuestionId = 8,
                    LinkPdpSetId      = linkPdpSetView.Id,
                    Question          = listItems.First(e => e.Id == 8),
                    CreatedDate       = DateTime.Today.AddMinutes(10),
                    PdpQuestionGroup  = linkPdpSetView.PdpQuestionGroup.First(w => w.SectionId == 2)
                },
                new LinkPdpAnswerView {
                    Answer            = "Added Test answer 3",
                    LinkPdpQuestionId = 9,
                    LinkPdpSetId      = linkPdpSetView.Id,
                    Question          = listItems.First(e => e.Id == 9),
                    CreatedDate       = DateTime.Today.AddMinutes(10),
                    PdpQuestionGroup  = linkPdpSetView.PdpQuestionGroup.First(w => w.SectionId == 2)
                }
            });
        }
Exemplo n.º 2
0
        public static LinkPdpSetView InsertTestData(LinkPdpSetView linkPdpSet)
        {
            var newPdpSet = AutoMapper.Mapper.Map <LinkPdpSetView, LinkPdpSet>(linkPdpSet);

            using (var db = new RepositoryContext())
            {
                db.LinkPdpSet.Add(newPdpSet);

                db.SaveChanges();
            }

            return(AutoMapper.Mapper.Map <LinkPdpSet, LinkPdpSetView>(newPdpSet));
        }
Exemplo n.º 3
0
        public PdpServiceTestFixture()
        {
            _pdpSet = new LinkPdpSetView
            {
                ColleagueId      = ColleagueServiceTestFixture.ColleagueId,
                CreatedDate      = DateTime.Today,
                SharedDate       = DateTime.Today,
                UpdatedDate      = DateTime.Today,
                Id               = 9999,
                PdpQuestionGroup = new List <PdpQuestionGroupView>(),
            };
            PdpQuestionGroupView group1 = new PdpQuestionGroupView
            {
                CreatedDate  = DateTime.Today,
                LinkPdpSetId = _pdpSet.Id,
                SectionId    = 1
            };
            PdpQuestionGroupView group2 = new PdpQuestionGroupView
            {
                CreatedDate  = DateTime.Today,
                LinkPdpSetId = _pdpSet.Id,
                SectionId    = 2
            };
            PdpQuestionGroupView group3 = new PdpQuestionGroupView
            {
                CreatedDate  = DateTime.Today,
                LinkPdpSetId = _pdpSet.Id,
                SectionId    = 10
            };

            _pdpSet.PdpQuestionGroup.Add(group1);
            _pdpSet.PdpQuestionGroup.Add(group2);
            _pdpSet.PdpQuestionGroup.Add(group3);

            var Answers = new List <LinkPdpAnswerView> {
                new LinkPdpAnswerView {
                    Answer            = "Test answer 1",
                    LinkPdpQuestionId = 4,
                    LinkPdpSetId      = _pdpSet.Id,
                    CreatedDate       = DateTime.Today,
                    PdpQuestionGroup  = _pdpSet.PdpQuestionGroup.First(f => f.SectionId == 1)
                },
                new LinkPdpAnswerView {
                    Answer            = "Test answer 2",
                    LinkPdpQuestionId = 5,
                    LinkPdpSetId      = _pdpSet.Id,
                    CreatedDate       = DateTime.Today,
                    PdpQuestionGroup  = _pdpSet.PdpQuestionGroup.First(f => f.SectionId == 1)
                },
                new LinkPdpAnswerView {
                    Answer            = "Test answer 3",
                    LinkPdpQuestionId = 6,
                    LinkPdpSetId      = _pdpSet.Id,
                    CreatedDate       = DateTime.Today,
                    PdpQuestionGroup  = _pdpSet.PdpQuestionGroup.First(f => f.SectionId == 1)
                },

                new LinkPdpAnswerView {
                    Answer            = "Test answer 4",
                    LinkPdpQuestionId = 11,
                    LinkPdpSetId      = _pdpSet.Id,
                    CreatedDate       = DateTime.Today.AddMinutes(1),
                    PdpQuestionGroup  = _pdpSet.PdpQuestionGroup.First(f => f.SectionId == 10)
                },
                new LinkPdpAnswerView {
                    Answer            = "Test answer 5",
                    LinkPdpQuestionId = 12,
                    LinkPdpSetId      = _pdpSet.Id,
                    CreatedDate       = DateTime.Today.AddMinutes(1),
                    PdpQuestionGroup  = _pdpSet.PdpQuestionGroup.First(f => f.SectionId == 10)
                },
                new LinkPdpAnswerView {
                    Answer            = "Test answer 6",
                    LinkPdpQuestionId = 13,
                    LinkPdpSetId      = _pdpSet.Id,
                    CreatedDate       = DateTime.Today.AddMinutes(1),
                    PdpQuestionGroup  = _pdpSet.PdpQuestionGroup.First(f => f.SectionId == 10)
                }
            };

            _pdpSet.Answers = Answers;

            _notificationServiceMock = new Mock <INotificationService>();
            _colleagueServiceMock    = new Mock <IColleagueService>();
            _notificationBuilderMock = new Mock <INotificationBuilder>();
            _staticServiceMock       = new Mock <IStaticService>();

            _pdpService = new PdpService(
                new RepositoryContext(),
                _notificationServiceMock.Object,
                _colleagueServiceMock.Object,
                _notificationBuilderMock.Object,
                _staticServiceMock.Object);
        }
Exemplo n.º 4
0
        public LinkPdpSetView BuildPdpSetTestDataWithUnorderedAnswers()
        {
            var listItems = GetListItems();



            var testLinkset = new LinkPdpSetView
            {
                ColleagueId      = ColleagueServiceTestFixture.ColleagueId,
                CreatedDate      = DateTime.Today,
                SharedDate       = DateTime.Today,
                UpdatedDate      = DateTime.Today,
                Id               = 1,
                PdpQuestionGroup = new List <PdpQuestionGroupView>()
            };
            PdpQuestionGroupView group1 = new PdpQuestionGroupView
            {
                CreatedDate  = DateTime.Today,
                LinkPdpSetId = testLinkset.Id,
                SectionId    = 1
            };
            PdpQuestionGroupView group2 = new PdpQuestionGroupView
            {
                CreatedDate  = DateTime.Today,
                LinkPdpSetId = testLinkset.Id,
                SectionId    = 2
            };

            testLinkset.PdpQuestionGroup.Add(group1);
            testLinkset.PdpQuestionGroup.Add(group2);



            //the order is deliberately different
            var Answers = new List <LinkPdpAnswerView> {
                new LinkPdpAnswerView {
                    Answer            = "Test answer 1",
                    LinkPdpQuestionId = 5,
                    LinkPdpSetId      = 1,
                    Question          = listItems.First(e => e.Id == 5),
                    CreatedDate       = DateTime.Today,
                    PdpQuestionGroup  = testLinkset.PdpQuestionGroup.First(f => f.SectionId == 1)
                },
                new LinkPdpAnswerView {
                    Answer            = "Test answer 2",
                    LinkPdpQuestionId = 4,
                    LinkPdpSetId      = 1,
                    Question          = listItems.First(e => e.Id == 4),
                    CreatedDate       = DateTime.Today,
                    PdpQuestionGroup  = testLinkset.PdpQuestionGroup.First(f => f.SectionId == 1)
                },
                new LinkPdpAnswerView {
                    Answer            = "Test answer 1",
                    LinkPdpQuestionId = 5,
                    LinkPdpSetId      = 1,
                    Question          = listItems.First(e => e.Id == 5),
                    CreatedDate       = DateTime.Today.AddMinutes(1),
                    PdpQuestionGroup  = testLinkset.PdpQuestionGroup.First(f => f.SectionId == 2)
                },
                new LinkPdpAnswerView {
                    Answer            = "Test answer 2",
                    LinkPdpQuestionId = 4,
                    LinkPdpSetId      = 1,
                    Question          = listItems.First(e => e.Id == 4),
                    CreatedDate       = DateTime.Today.AddMinutes(1),
                    PdpQuestionGroup  = testLinkset.PdpQuestionGroup.First(f => f.SectionId == 2)
                }
            };

            testLinkset.Answers = Answers;
            return(testLinkset);
        }