示例#1
0
        public void GetAllTest(IReadOnlyCollection <DFC_GDSTranlations> setupDbSetData, IReadOnlyCollection <content_model_reference> contentModelSetupData, IReadOnlyCollection <DFC_GDSCombinations> combinationSetupData, IReadOnlyCollection <FrameworkSkill> mappedReturnDbSetData)
        {
            var fakeDbContext      = A.Fake <OnetSkillsFramework>();
            var fakeTransDataDbSet = A.Fake <DbSet <DFC_GDSTranlations> >(c => c
                                                                          .Implements(typeof(IQueryable <DFC_GDSTranlations>))
                                                                          .Implements(typeof(IDbAsyncEnumerable <DFC_GDSTranlations>))).SetupData(setupDbSetData.ToList());
            var fakeContentDbSet = A.Fake <DbSet <content_model_reference> >(c => c
                                                                             .Implements(typeof(IQueryable <content_model_reference>))
                                                                             .Implements(typeof(IDbAsyncEnumerable <content_model_reference>)))
                                   .SetupData(contentModelSetupData.ToList());
            var fakeCombinationDbSet = A.Fake <DbSet <DFC_GDSCombinations> >(c => c
                                                                             .Implements(typeof(IQueryable <DFC_GDSCombinations>))
                                                                             .Implements(typeof(IDbAsyncEnumerable <DFC_GDSCombinations>)))
                                       .SetupData(combinationSetupData.ToList());

            //Act
            A.CallTo(() => fakeDbContext.DFC_GDSTranlations).Returns(fakeTransDataDbSet);
            A.CallTo(() => fakeDbContext.content_model_reference).Returns(fakeContentDbSet);
            A.CallTo(() => fakeDbContext.DFC_GDSCombinations).Returns(fakeCombinationDbSet);
            var repo = new TranslationQueryRepository(fakeDbContext);

            //Assert
            var result = repo.GetAll();

            if (mappedReturnDbSetData == null || result == null)
            {
                Xunit.Assert.True(false, "The mapped data should not be null ");
            }
            else
            {
                result.Should().BeEquivalentTo(mappedReturnDbSetData);
            }
        }
示例#2
0
        public void GetTranslationById(string onetElementId)
        {
            using (OnetSkillsFramework dbcontext = new OnetSkillsFramework())
            {
                var repository = new TranslationQueryRepository(dbcontext);

                var single = repository.GetById(onetElementId);
                single.Should().NotBeNull();
                single.ONetElementId.Should().Be(onetElementId);
            }
        }
示例#3
0
        public void GetTranslationsMany(string field1, string field2)
        {
            using (OnetSkillsFramework dbcontext = new OnetSkillsFramework())
            {
                var repository = new TranslationQueryRepository(dbcontext);


                var single = repository.GetMany(x => x.ONetElementId == field1 && x.Description == field2);
                single.Should().NotBeNull();
                single.Should().Contain(x => x.ONetElementId == field1);
            }
        }
示例#4
0
        public void GetAllTransalations()
        {
            using (OnetSkillsFramework dbcontext = new OnetSkillsFramework())
            {
                var repository = new TranslationQueryRepository(dbcontext);
                var all        = repository.GetAll().ToList();
                all.Should().NotBeNull();
                all.Count.Should().BeGreaterThan(0);

                var single = repository.GetById("1.A.1.a");
                single.Should().NotBeNull();
                single.ONetElementId.Should().Be("1.A.1.a");

                var singleByExpression = repository.Get(s => s.ONetElementId == "1.A.1.a");
                singleByExpression.Should().NotBeNull();
                singleByExpression.ONetElementId.Should().Be("1.A.1.a");

                var manyByExpression = repository.GetMany(s => s.ONetElementId.StartsWith("1.A.", StringComparison.Ordinal));
                manyByExpression.Should().NotBeNull();
            }
        }
示例#5
0
        public void GetAllSocMapping()
        {
            var mapperConfig = new MapperConfiguration(cfg => cfg.AddProfile(new SkillsFrameworkMapper()));
            var mapper       = mapperConfig.CreateMapper();
            var fakeLogger   = A.Fake <IApplicationLogger>();
            var fakeFrameworkSkillSuppression = A.Fake <IQueryRepository <FrameworkSkillSuppression> >();
            var fakeContentReference          = A.Fake <IQueryRepository <FrameWorkContent> >();
            var fakeCombinationSkill          = A.Fake <IQueryRepository <FrameWorkSkillCombination> >();

            IQueryRepository <SocCode>        socCodeRepository       = new SocMappingsQueryRepository(new OnetSkillsFramework(), mapper);
            IQueryRepository <DigitalSkill>   digitalSkillsRepository = new DigitalSkillsQueryRepository(new OnetSkillsFramework());
            IQueryRepository <FrameworkSkill> frameWorkRepository     = new TranslationQueryRepository(new OnetSkillsFramework());
            ISkillsRepository skillsRepository = new SkillsOueryRepository(new OnetSkillsFramework());

            ISkillFrameworkBusinessRuleEngine ruleEngine = new SkillFrameworkBusinessRuleEngine(skillsRepository, fakeFrameworkSkillSuppression, fakeCombinationSkill, fakeContentReference);

            ISkillsFrameworkService skillService = new SkillsFrameworkService(fakeLogger, socCodeRepository, digitalSkillsRepository, frameWorkRepository, ruleEngine);

            var level = skillService.GetAllSocMappings().ToList();

            level.Should().NotBeNull();
        }
示例#6
0
        public void GetTest(IReadOnlyCollection <DFC_GDSTranlations> setupDbSetData, IReadOnlyCollection <content_model_reference> contentModelSetupData, IReadOnlyCollection <DFC_GDSCombinations> combinationSetupData, FrameworkSkill mappedWhatitTakesData, string onetElementId)
        {
            //InProgress as have to yield single object against collection
            //Arrange
            var fakeDbContext        = A.Fake <OnetSkillsFramework>();
            var fakeTranslationDbSet = A.Fake <DbSet <DFC_GDSTranlations> >(c => c
                                                                            .Implements(typeof(IQueryable <DFC_GDSTranlations>))
                                                                            .Implements(typeof(IDbAsyncEnumerable <DFC_GDSTranlations>))).SetupData(setupDbSetData.ToList());
            var fakeContentDbSet = A.Fake <DbSet <content_model_reference> >(c => c
                                                                             .Implements(typeof(IQueryable <content_model_reference>))
                                                                             .Implements(typeof(IDbAsyncEnumerable <content_model_reference>)))
                                   .SetupData(contentModelSetupData.ToList());
            var fakeCombinationDbSet = A.Fake <DbSet <DFC_GDSCombinations> >(c => c
                                                                             .Implements(typeof(IQueryable <DFC_GDSCombinations>))
                                                                             .Implements(typeof(IDbAsyncEnumerable <DFC_GDSCombinations>)))
                                       .SetupData(combinationSetupData.ToList());

            //Act
            A.CallTo(() => fakeDbContext.DFC_GDSTranlations).Returns(fakeTranslationDbSet);
            A.CallTo(() => fakeDbContext.content_model_reference).Returns(fakeContentDbSet);
            A.CallTo(() => fakeDbContext.DFC_GDSCombinations).Returns(fakeCombinationDbSet);
            var repo = new TranslationQueryRepository(fakeDbContext);

            //Assert
            var result = repo.Get(x => x.ONetElementId == onetElementId);

            result.Should().NotBeNull();
            if (mappedWhatitTakesData == null || result == null)
            {
                Xunit.Assert.True(false, "The mapped data should not be null ");
            }
            else
            {
                result.Should().BeEquivalentTo(mappedWhatitTakesData);
                result.ONetElementId.Should().Be(onetElementId);
            }
        }