Esempio n. 1
0
        public ItemControllerTests()
        {
            bankKey = 234343;
            itemKey = 485954;

            SampleItem digest = SampleItem.Create
                                (
                bankKey: bankKey,
                itemKey: itemKey,
                grade: GradeLevels.NA
                                );
            ItemCardViewModel card = digest.ToItemCardViewModel();

            var aboutThisItemVM = new AboutThisItemViewModel(
                rubrics: ImmutableArray.Create <Rubric>(),
                itemCard: card,
                depthOfKnowledge: "",
                targetDescription: "",
                commonCoreStandardsDescription: "");


            SampleItem digestCookie = SampleItem.Create
                                      (
                bankKey: bankKey,
                itemKey: 0,
                grade: GradeLevels.NA
                                      );
            ItemCardViewModel cardCookie = digest.ToItemCardViewModel();

            var aboutItemCookie = new AboutThisItemViewModel(
                rubrics: ImmutableArray.Create <Rubric>(),
                itemCard: cardCookie,
                depthOfKnowledge: "",
                targetDescription: "",
                commonCoreStandardsDescription: "");



            iSAAP = "TDS_test;TDS_test2;";

            string accCookieName = "accessibilitycookie";

            var accessibilityResourceGroups = new List <AccessibilityResourceGroup>();

            var appSettings = new AppSettings()
            {
                SettingsConfig = new SettingsConfig()
                {
                    AccessibilityCookie = accCookieName
                }
            };

            itemViewModel = new ItemViewModel(
                itemViewerServiceUrl: $"http://itemviewerservice.cass.oregonstate.edu/item/{bankKey}-{itemKey}",
                accessibilityCookieName: accCookieName,
                isPerformanceItem: false,
                accResourceGroups: default(ImmutableArray <AccessibilityResourceGroup>),
                subject: "MATH",
                moreLikeThisVM: default(MoreLikeThisViewModel),
                brailleItemCodes: new ImmutableArray <string>(),
                braillePassageCodes: new ImmutableArray <string>(),
                brailleItem: null,
                nonBrailleItem: null);

            itemViewModelCookie = new ItemViewModel(
                itemViewerServiceUrl: string.Empty,
                accessibilityCookieName: string.Empty,
                isPerformanceItem: false,
                subject: "MATH",
                accResourceGroups: accessibilityResourceGroups.ToImmutableArray(),
                moreLikeThisVM: default(MoreLikeThisViewModel),
                brailleItemCodes: new ImmutableArray <string>(),
                braillePassageCodes: new ImmutableArray <string>(),
                brailleItem: null,
                nonBrailleItem: null);

            var itemViewRepoMock = new Mock <IItemViewRepo>();

            itemViewRepoMock
            .Setup(repo =>
                   repo.GetItemViewModel(bankKey, itemKey, It.Is <string[]>(strings => strings.Length == 0), It.IsAny <Dictionary <string, string> >()))
            .Returns(itemViewModel);

            itemViewRepoMock
            .Setup(repo =>
                   repo.GetItemViewModel(
                       bankKey,
                       itemKey,
                       It.Is <string[]>(ss => Enumerable.SequenceEqual(ss, iSAAP.Split(';'))),
                       It.IsAny <Dictionary <string, string> >()))
            .Returns(itemViewModel);

            var loggerFactory = new Mock <ILoggerFactory>();
            var logger        = new Mock <ILogger>();

            loggerFactory.Setup(lf => lf.CreateLogger(It.IsAny <string>())).Returns(logger.Object);

            controller = new ItemController(itemViewRepoMock.Object, appSettings, loggerFactory.Object);
        }