public async Task GetLearningAimAsync_Calls_LearningAimService_GetLearningAim()
        {
            var frameworkCode = 1;
            var programType   = 2;
            var pathwayCode   = 3;

            var framework = new FrameworkModel
            {
                FrameworkCode = frameworkCode,
                ProgramType   = programType,
                PathwayCode   = pathwayCode
            };

            var serviceMock = new Mock <IFrameworkService>();

            serviceMock
            .Setup(m => m.GetFramework(frameworkCode, programType, pathwayCode))
            .ReturnsAsync(framework);

            var controller = new FrameworkController(serviceMock.Object);
            var result     = await controller.GetFramework(frameworkCode, programType, pathwayCode);

            serviceMock.Verify(m => m.GetFramework(frameworkCode, programType, pathwayCode), Times.Once);
            result.Should().BeEquivalentTo(framework);
        }
        public async Task GetFramework_Returns_Valid_Framework()
        {
            var frameworkCode = 1;
            var programType   = 2;
            var pathwayCode   = 3;

            var apiFramework = new FrameworkModel
            {
                FrameworkCode = frameworkCode,
                ProgramType   = programType,
                PathwayCode   = pathwayCode
            };

            _azureServiceMock
            .Setup(m => m.GetFramework(frameworkCode, programType, pathwayCode))
            .ReturnsAsync(apiFramework);

            var service = new FrameworkService(_azureServiceMock.Object, _searchCleaningServiceMock.Object);
            var result  = await service.GetFramework(frameworkCode, programType, pathwayCode);

            _azureServiceMock.Verify(m => m.GetFramework(frameworkCode, programType, pathwayCode), Times.Once);

            result.FrameworkCode.Should().Be(frameworkCode);
            result.ProgramType.Should().Be(programType);
            result.PathwayCode.Should().Be(pathwayCode);
        }
        public async Task GetFramework_Calls_Client_Get()
        {
            var frameworkCode = 1;
            var programType   = 2;
            var pathwayCode   = 3;

            var framework = new FrameworkModel
            {
                FrameworkCode = frameworkCode,
                ProgramType   = programType,
                PathwayCode   = pathwayCode
            };

            var parameters = new Dictionary <string, object>
            {
                { FrameworkCodeParameterName, frameworkCode },
                { ProgramTypeParameterName, programType },
                { PathwayCodeParameterName, pathwayCode }
            };

            var clientServiceMock = new Mock <IClientService>();

            clientServiceMock
            .Setup(m => m.GetAsync <FrameworkModel>(Url, parameters))
            .ReturnsAsync(framework);

            var service = new FrameworkApiService(clientServiceMock.Object);
            var result  = await service.GetFramework(frameworkCode, programType, pathwayCode);

            clientServiceMock.Verify(m => m.GetAsync <FrameworkModel>(Url, parameters), Times.Once);

            result.Should().BeEquivalentTo(framework);
        }
        public async Task GetFramework_Returns_Valid_Framework()
        {
            var frameworkCode = 1;
            var programType   = 2;
            var pathwayCode   = 3;

            var key = $"{frameworkCode}-{programType}-{pathwayCode}";

            var azureFramework = new FrameworkModel
            {
                FrameworkCode = frameworkCode,
                ProgramType   = programType,
                PathwayCode   = pathwayCode
            };
            var apiFramework = new Models.FrameworkModel
            {
                FrameworkCode = frameworkCode,
                ProgramType   = programType,
                PathwayCode   = pathwayCode
            };

            var mapperMock = new Mock <IMapper <FrameworkModel, Models.FrameworkModel> >();

            mapperMock.Setup(m => m.Map(azureFramework)).Returns(apiFramework);

            var telemetryMock = new Mock <ITelemetry>();

            var indexServiceMock = new Mock <IFrameworkIndexService>();

            var azureServiceMock = new Mock <IAzureService>();

            azureServiceMock
            .Setup(m => m.GetAsync <FrameworkModel>(It.IsAny <IFrameworkIndexService>(), key))
            .ReturnsAsync(azureFramework);

            var queryServiceMock = new Mock <IODataQueryService>();
            var searchTermFormattingServiceMock = new Mock <ISearchTermFormattingService>();

            var service = new AzureFrameworkService(
                telemetryMock.Object,
                indexServiceMock.Object,
                mapperMock.Object,
                azureServiceMock.Object,
                queryServiceMock.Object,
                searchTermFormattingServiceMock.Object);

            var result = await service.GetFramework(frameworkCode, programType, pathwayCode);

            azureServiceMock.Verify(m => m.GetAsync <FrameworkModel>(It.IsAny <IFrameworkIndexService>(), key), Times.Once);

            result.Should().BeSameAs(apiFramework);
        }
        public IList <FrameworkModel> PrepareFrameworkModels()
        {
            var frameworks = new List <FrameworkModel>();
            var rootPath   = hostingEnvironment.ContentRootPath;

            var dirs = Directory.EnumerateDirectories(Path.Combine(rootPath, "Pages"))
                       .Where(d => !String.Equals("Shared", new DirectoryInfo(d).Name))
                       .ToList();

            // Retrieve all frameworks.
            foreach (var frameworkDir in dirs)
            {
                var framework = new FrameworkModel
                {
                    Name = new DirectoryInfo(frameworkDir).Name
                };

                // Retrieve all versions.
                foreach (var versionPath in Directory.EnumerateDirectories(frameworkDir))
                {
                    var versionName = new DirectoryInfo(versionPath).Name;
                    var paths       = new List <string>();

                    // Retrieve all files in that version.
                    foreach (var filePath in Directory.EnumerateFiles(versionPath, "*.cshtml"))
                    {
                        var fileName = Path.GetFileNameWithoutExtension(filePath);

                        // Ignore all files that start with an '_'.
                        if (fileName.StartsWith('_'))
                        {
                            continue;
                        }

                        var webLink = $"/{framework.Name}/{versionName}/{fileName}";

                        if (paths.Contains(webLink))
                        {
                            continue;
                        }

                        paths.Add(webLink);
                    }

                    framework.VersionPathMap[versionName] = paths;
                }

                frameworks.Add(framework);
            }

            return(frameworks);
        }
        private void UpdateFrameworks(IEnumerable <ProjectModel> selectedProjects, FrameworkModel frameworkModel,
                                      Action <int, object> progressReport)
        {
            var count = selectedProjects.Count();
            var i     = 1;

            foreach (var projectModel in selectedProjects)
            {
                try
                {
                    projectModel.DteProject.Properties.Item("TargetFrameworkMoniker").Value = frameworkModel.Name;
                    progressReport(GetPercentage(i, count), $"Updating... {projectModel.Name} done");
                }
                catch (COMException e) //possible "project unavailable" for unknown reasons
                {
                    progressReport(-1, "COMException on " + projectModel.Name + e);
                }

                i++;
            }
        }
        public void Map_Returns_Valid_Model()
        {
            var model = new FrameworkModel
            {
                FrameworkCode              = 1,
                ProgramType                = 2,
                PathwayCode                = 0,
                PathwayName                = "nametest",
                FrameworkTitle             = "testtitle",
                EffectiveFrom              = new DateTime(2020, 1, 1),
                EffectiveTo                = new DateTime(2022, 1, 1),
                SectorSubjectAreaTier1     = "-1",
                SectorSubjectAreaTier1Desc = "testdesc1",
                SectorSubjectAreaTier2     = "-2",
                SectorSubjectAreaTier2Desc = "testdesc2",
                IssuingAuthority           = "1",
                IssuingAuthorityDesc       = "testauthdesc"
            };

            var aimMapperMock             = new Mock <IMapper <RelatedLearningAimModel, Models.RelatedLearningAimModel> >();
            var commonComponentMapperMock = new Mock <IMapper <CommonComponentModel, Models.CommonComponentModel> >();

            var mapper = new AzureFrameworkMapper(aimMapperMock.Object, commonComponentMapperMock.Object);
            var result = mapper.Map(model);

            result.FrameworkCode.Should().Be(model.FrameworkCode);
            result.PathwayCode.Should().Be(model.PathwayCode);
            result.ProgramType.Should().Be(model.ProgramType);
            result.PathwayName.Should().Be(model.PathwayName);
            result.FrameworkTitle.Should().Be(model.FrameworkTitle);
            result.EffectiveFrom.Should().Be(model.EffectiveFrom);
            result.EffectiveTo.Should().Be(model.EffectiveTo);
            result.SectorSubjectAreaTier1.Should().Be(model.SectorSubjectAreaTier1);
            result.SectorSubjectAreaTier1Desc.Should().Be(model.SectorSubjectAreaTier1Desc);
            result.SectorSubjectAreaTier2.Should().Be(model.SectorSubjectAreaTier2);
            result.SectorSubjectAreaTier2Desc.Should().Be(model.SectorSubjectAreaTier2Desc);
            result.IssuingAuthority.Should().Be(model.IssuingAuthority);
            result.IssuingAuthorityDesc.Should().Be(model.IssuingAuthorityDesc);
        }
 public PackageFolder(NuGetFramework targetFramework, FrameworkModel framework)
 {
     TargetFramework = targetFramework;
     Framework       = framework;
 }