示例#1
0
 public static IPostprocessComposer <Build> WithBuildConfigSummary(
     this IPostprocessComposer <Build> composer, BuildConfig buildConfig)
 {
     return(composer
            .With(x => x.BuildConfig, (BuildConfigSummary)buildConfig)
            .With(x => x.BuildTypeId, buildConfig.Id));
 }
示例#2
0
        public static IPostprocessComposer <Dream> WithImage(this IPostprocessComposer <Dream> postProcessComposer, int imageSize = 256)
        {
            var fixture  = new Fixture();
            var newImage = fixture.ImageBuilder(imageSize).Create();

            return(postProcessComposer.With(d => d.DreamImage, newImage));
        }
 public static IPostprocessComposer <T> Json <T, TProperty, TValue>(
     this IPostprocessComposer <T> composer,
     Expression <Func <T, TProperty> > propertyPicker,
     TValue value)
 {
     return(composer.With(propertyPicker, Serialize(value)));
 }
 public static IPostprocessComposer <T> With <T, TProperty, TValue>(
     this IPostprocessComposer <T> composer,
     Expression <Func <T, TProperty> > propertyPicker,
     TValue value)
 {
     return(composer.With(propertyPicker, Convert <TValue, TProperty>(value)));
 }
示例#5
0
 public static IPostprocessComposer <Project> WithBuildConfigSummary(
     this IPostprocessComposer <Project> composer, BuildConfig buildConfig)
 {
     return(composer.With(x => x.BuildConfigs, new List <BuildConfigSummary>()
     {
         (BuildConfigSummary)buildConfig
     }));
 }
示例#6
0
        public static IPostprocessComposer <OutputGroupModel> WithItems(
            this IPostprocessComposer <OutputGroupModel> composer, IDictionary <string, int> itemsDefinitions,
            IFixture fixture)
        {
            var items = itemsDefinitions?.Select(def => fixture.Build <OutputItemModel>()
                                                 .WithId(def.Key)
                                                 .WithCount(def.Value)
                                                 .Create());

            return(items != null?composer.With(m => m.Items, items) : composer);
        }
示例#7
0
        private static Estacion MakeEstacion(Coord?coord = null)
        {
            IPostprocessComposer <Estacion> builder = fixture.Build <Estacion>();

            if (coord != null)
            {
                builder = builder.With(e => e.Coord, coord.Value);
            }

            return(builder.Create());
        }
示例#8
0
 public static IPostprocessComposer <DependencyDefinition> WithPathRules(
     this IPostprocessComposer <DependencyDefinition> composer, string pathRules)
 {
     return(composer.With(x => x.Properties, new Properties()
     {
         Count = "1", Property = new PropertyList {
             new Property {
                 Name = "pathRules", Value = pathRules
             }
         }
     }));
 }
        public static IPostprocessComposer <QuestionnaireResponse> WithAllYesAnswers(
            this IPostprocessComposer <QuestionnaireResponse> composer)
        {
            var value = "Yes";

            return(composer
                   .With(x => x.WheelchairFriendlyAnswer, value)
                   .With(x => x.BuggyFriendlyAnswer, value)
                   .With(x => x.HasToiletsAnswer, value)
                   .With(x => x.DogsAllowedAnswer, value)
                   .With(x => x.CafeAnswer, value)
                   .With(x => x.PostRunCoffeeAnswer, value)
                   .With(x => x.DrinkingFountainsAnswer, value)
                   .With(x => x.ChangingRoomsAnswer, value)
                   .With(x => x.LockersAvailableAnswer, value)
                   .With(x => x.ShowersAvailableAnswer, value)
                   .With(x => x.BagDropAnswer, value)
                   .With(x => x.BabyChangingFacilitiesAnswer, value)
                   .With(x => x.VisuallyImpairedFriendlyAnswer, value));
        }
示例#10
0
 public static IPostprocessComposer <BuildConfig> WithProjectId(
     this IPostprocessComposer <BuildConfig> composer, string projectId)
 {
     return(composer.With(x => x.ProjectId, projectId));
 }
示例#11
0
 public static IPostprocessComposer <BuildConfig> WithId(
     this IPostprocessComposer <BuildConfig> composer, string id)
 {
     return(composer.With(x => x.Id, id));
 }
示例#12
0
 public static IPostprocessComposer <OutputItemModel> WithCount(
     this IPostprocessComposer <OutputItemModel> composer, int count)
 {
     return(composer.With(m => m.Count, count));
 }
 public static IPostprocessComposer <T> With <T, TProperty>(
     this IPostprocessComposer <T> @this,
     Expression <Func <T, TProperty> > propertyPicker,
     Func <Faker, TProperty> valueFactory) =>
 @this.With(propertyPicker, () => valueFactory(faker));
示例#14
0
 public static IPostprocessComposer <BuildConfig> WithTemplates(
     this IPostprocessComposer <BuildConfig> composer, Templates templates)
 {
     templates.Count = templates.BuildType.Count;
     return(composer.With(x => x.Templates, templates));
 }
示例#15
0
        public static IPostprocessComposer <User> WithPassword(this IPostprocessComposer <User> postProcessComposer, string password)
        {
            var hasher = new PasswordHasher <User>();

            return(postProcessComposer.With(u => u.PasswordHash, hasher.HashPassword(null, password)));
        }
示例#16
0
 public static IPostprocessComposer <Invitation> WithStatus(this IPostprocessComposer <Invitation> postProcessComposer, InvitationStateEnum status)
 {
     return(postProcessComposer.With(i => i.Status, status));
 }
示例#17
0
 public static IPostprocessComposer <GetDependenciesOptions> WithForce(
     this IPostprocessComposer <GetDependenciesOptions> composer, string buildConfigId)
 {
     return(composer.With(x => x.BuildConfigId, buildConfigId).With(x => x.Force, true));
 }
示例#18
0
 public static IPostprocessComposer <BuildConfig> WithName(
     this IPostprocessComposer <BuildConfig> composer, string name)
 {
     return(composer.With(x => x.Name, name));
 }
示例#19
0
 public static IPostprocessComposer <BuildConfig> WithParameters(
     this IPostprocessComposer <BuildConfig> composer, Properties buildParameters)
 {
     return(composer.With(x => x.Parameters, buildParameters));
 }
示例#20
0
 public static IPostprocessComposer <Build> WithId(
     this IPostprocessComposer <Build> composer, long id)
 {
     return(composer.With(x => x.Id, id));
 }
示例#21
0
 public static IPostprocessComposer <Project> WithId(
     this IPostprocessComposer <Project> composer, string id)
 {
     return(composer.With(x => x.Id, id));
 }
示例#22
0
 public static IPostprocessComposer <Build> WithBuildTypeId(
     this IPostprocessComposer <Build> composer, string id)
 {
     return(composer.With(x => x.BuildTypeId, id));
 }
示例#23
0
 public static IPostprocessComposer <Dream> WithCategory(this IPostprocessComposer <Dream> postProcessComposer, DreamCategory category)
 {
     return(postProcessComposer.With(d => d.DreamCategory, category));
 }
        public void GivenCsvRowDataCollection_WhenContainsExtension_ShouldCallServicesWithCorrectlyFormattedData(int contentId, int articleId, int externalContentId, int externalArticleId, string externalContentName)
        {
            // Fixture setup
            var contentRepository = _fixture.Freeze <Mock <IContentRepository> >();
            var fieldRepository   = _fixture.Freeze <Mock <IFieldRepository> >();
            var articleService    = _fixture.Freeze <Mock <IBatchUpdateService> >();
            var sut = _fixture.Create <CsvDbUpdateService>();

            var dbFields        = _fixture.CreateMany <Field>().ToList();
            var simpleRowFields = CsvDbUpdateTestHelpers.GenerateCsvRowFields(articleId, dbFields, _fixture);

            var classifierDbField = _postProcessFieldComposer.With(f => f.IsClassifier, true).Create();
            var clasifierCsvField = _fixture.Build <CsvDbUpdateFieldModel>()
                                    .With(f => f.Name, classifierDbField.Name)
                                    .With(f => f.Value, externalContentId.ToString())
                                    .Create();

            dbFields.Add(classifierDbField);
            simpleRowFields.Add(clasifierCsvField);

            var externalDbFields  = _fixture.CreateMany <Field>().ToList();
            var externalRowFields = CsvDbUpdateTestHelpers.GenerateCsvRowFields(externalArticleId, externalDbFields, _fixture, externalContentName);

            var csvRowFields = simpleRowFields.Concat(externalRowFields).ToList();
            var csvData      = CsvDbUpdateTestHelpers.GenerateCsvDbUpdateModel(contentId, csvRowFields, _fixture);

            fieldRepository
            .Setup(m => m.GetByNames(contentId, It.Is(CsvDbUpdateTestHelpers.CompareStringCollections(csvRowFields.Select(csvf => csvf.Name)))))
            .Returns(dbFields)
            .Verifiable();

            fieldRepository
            .Setup(m => m.GetByNames(externalContentId, It.Is(CsvDbUpdateTestHelpers.CompareStringCollections(externalRowFields.Select(csvf => CsvDbUpdateTestHelpers.FilterFromPrefix(csvf.Name, externalContentName))))))
            .Returns(externalDbFields)
            .Verifiable();

            contentRepository
            .Setup(m => m.GetById(externalContentId))
            .Returns(new Content {
                Name = externalContentName
            })
            .Verifiable();

            var expectedResult = new List <ArticleData>
            {
                new ArticleData
                {
                    Id        = -articleId,
                    ContentId = contentId,
                    Fields    = dbFields.Zip(simpleRowFields.Skip(1), (dbf, csvf) => new FieldData
                    {
                        Id         = dbf.Id,
                        Value      = csvf.Value,
                        ArticleIds = dbf.IsClassifier ? new[] { -externalArticleId } : Enumerable.Empty <int>().ToArray()
                    }).ToList()
                },
                new ArticleData
                {
                    Id        = -externalArticleId,
                    ContentId = externalContentId,
                    Fields    = externalDbFields.Zip(externalRowFields.Skip(1), (dbf, csvf) => new FieldData
                    {
                        Id         = dbf.Id,
                        Value      = csvf.Value,
                        ArticleIds = Enumerable.Empty <int>().ToArray()
                    }).ToList()
                }
            };

            // Exercise system
            sut.Process(csvData);

            // Verify outcome
            fieldRepository.Verify();
            contentRepository.Verify(m => m.GetById(It.IsAny <int>()), Times.Exactly(2));
            articleService.Verify(m => m.BatchUpdate(It.Is(CsvDbUpdateTestHelpers.CompareArticleDataCollections(expectedResult))));
        }
示例#25
0
 public IPostprocessComposer <T> With <TProperty>(Expression <Func <T, TProperty> > propertyPicker) => _builder = _builder.With(propertyPicker);
示例#26
0
 public static IPostprocessComposer <OutputItemModel> WithId(
     this IPostprocessComposer <OutputItemModel> composer, string id)
 {
     return(composer.With(m => m.Id, id));
 }
示例#27
0
 public static IPostprocessComposer <Build> WithDependencies(
     this IPostprocessComposer <Build> composer, params Dependency[] dependencies)
 {
     return(composer.With(x => x.ArtifactDependencies, new List <Dependency>(dependencies)));
 }
示例#28
0
 public static IPostprocessComposer <BuildConfig> WithDependencies(
     this IPostprocessComposer <BuildConfig> composer, params DependencyDefinition[] dependencyDefinitions)
 {
     return(composer.With(x => x.ArtifactDependencies, new List <DependencyDefinition>(dependencyDefinitions)));
 }
        public void GivenCsvRowDataCollection_WhenWithDbRelations_ShouldCallServicesWithCorrectlyFormattedData(
            int contentId,
            int articleId,
            int relatedArticleId,
            Generator <FieldExactTypes> fetGenerator)
        {
            // Fixture setup
            var articleRepository = _fixture.Freeze <Mock <IArticleRepository> >();
            var fieldRepository   = _fixture.Freeze <Mock <IFieldRepository> >();
            var articleService    = _fixture.Freeze <Mock <IBatchUpdateService> >();
            var sut = _fixture.Create <CsvDbUpdateService>();

            var dbFields     = _fixture.CreateMany <Field>().ToList();
            var csvRowFields = CsvDbUpdateTestHelpers.GenerateCsvRowFields(articleId, dbFields, _fixture);
            var m2mDbField   = _postProcessFieldComposer.With(f => f.ExactType, fetGenerator.First(fet => new[]
            {
                FieldExactTypes.O2MRelation,
                FieldExactTypes.M2ORelation,
                FieldExactTypes.M2MRelation
            }.Contains(fet))).Create();

            var m2mCsvField = _fixture.Build <CsvDbUpdateFieldModel>()
                              .With(f => f.Name, m2mDbField.Name)
                              .With(f => f.Value, relatedArticleId.ToString())
                              .Create();

            dbFields.Add(m2mDbField);
            csvRowFields.Add(m2mCsvField);
            var csvData = CsvDbUpdateTestHelpers.GenerateCsvDbUpdateModel(contentId, csvRowFields, _fixture);

            fieldRepository
            .Setup(m => m.GetByNames(contentId, It.Is(CsvDbUpdateTestHelpers.CompareStringCollections(csvRowFields.Select(csvf => csvf.Name)))))
            .Returns(dbFields)
            .Verifiable();

            articleRepository
            .Setup(m => m.IsExist(relatedArticleId))
            .Returns(true)
            .Verifiable();

            var expectedResult = new List <ArticleData>
            {
                new ArticleData
                {
                    Id        = -articleId,
                    ContentId = contentId,
                    Fields    = dbFields.Zip(csvRowFields.Skip(1), (dbf, csvf) => new FieldData
                    {
                        Id         = dbf.Id,
                        Value      = csvf.Value,
                        ArticleIds = dbf.ExactType == m2mDbField.ExactType ? new[] { relatedArticleId } : Enumerable.Empty <int>().ToArray()
                    }).ToList()
                }
            };

            // Exercise system
            sut.Process(csvData, false);

            // Verify outcome
            fieldRepository.Verify();
            articleRepository.Verify();
            articleService.Verify(m => m.BatchUpdate(It.Is(CsvDbUpdateTestHelpers.CompareArticleDataCollections(expectedResult)), false));
        }
示例#30
0
 public static IPostprocessComposer <OutputGroupModel> WithWarehouseName(
     this IPostprocessComposer <OutputGroupModel> composer, string warehouseName)
 {
     return(composer.With(m => m.WarehouseName, warehouseName));
 }