コード例 #1
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);
        }
コード例 #2
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);
        }