public static ReviewDraft DefaultReviewDraftWithTarget(ReviewDraft draft, IReference target)
        {
            var reviewDraft = DefaultReviewDraft(draft);

            reviewDraft.Target = target;
            return(reviewDraft);
        }
Exemple #2
0
        public Review CreateReview(ReviewDraft reviewDraft)
        {
            IClient commerceToolsClient = this.GetService <IClient>();
            var     review = commerceToolsClient.ExecuteAsync(new CreateCommand <Review>(reviewDraft)).Result;

            return(review);
        }
        public static ReviewDraft DefaultReviewDraftWithKey(ReviewDraft draft, string key)
        {
            var reviewDraft = DefaultReviewDraft(draft);

            reviewDraft.Key = key;
            return(reviewDraft);
        }
        public static ReviewDraft DefaultReviewDraft(ReviewDraft reviewDraft)
        {
            var random = TestingUtility.RandomInt(1, 100);

            reviewDraft.Title  = $"ReviewTitle_{random}";
            reviewDraft.Text   = $"ReviewText_{random}";
            reviewDraft.Rating = random;
            reviewDraft.Key    = TestingUtility.RandomString();
            return(reviewDraft);
        }
Exemple #5
0
        public void IsValidTextSearchModelValidLocale()
        {
            IModelValidator modelValidator = new ModelValidator();
            ReviewDraft     reviewDraft    = new ReviewDraft
            {
                Locale = "en-US"
            };
            var result = modelValidator.IsValid(reviewDraft);

            Assert.Empty(result);
        }
        public void SerializeReviewDraftInvalidLocale()
        {
            ISerializerService serializerService = this.serializationFixture.SerializerService;
            ReviewDraft        reviewDraft       = new ReviewDraft()
            {
                Locale = "en-ZZZ"
            };
            ValidationException exception = Assert.Throws <ValidationException>(() => serializerService.Serialize(reviewDraft));

            Assert.Single(exception.Errors);
        }
        public static ReviewDraft DefaultReviewDraftWithCustomType(ReviewDraft draft, Type type, Fields fields)
        {
            var customFieldsDraft = new CustomFieldsDraft
            {
                Type   = type.ToKeyResourceIdentifier(),
                Fields = fields
            };

            var reviewDraft = DefaultReviewDraft(draft);

            reviewDraft.Custom = customFieldsDraft;

            return(reviewDraft);
        }
Exemple #8
0
        public Review CreateProductReview(string productKey, int rating)
        {
            var reviewDraft = new ReviewDraft
            {
                Rating = rating,
                Target = new ResourceIdentifier <Product> {
                    Key = productKey
                }
            };
            var review = this.reviewFixture.CreateReview(reviewDraft);

            this.reviewFixture.ReviewsToDelete.Add(review);
            return(review);
        }
        public void SerializationWithoutValidation()
        {
            var services = new ServiceCollection();

            services.UseRegistration();
            services.UseDomain();
            services.UseSerialization();
            var serviceProvider   = services.BuildServiceProvider();
            var serializerService = serviceProvider.GetService <ISerializerService>();

            ReviewDraft reviewDraft = new ReviewDraft()
            {
                Locale = "en-ZZZ"
            };
            var draft = serializerService.Serialize(reviewDraft);

            Assert.Equal("{\"locale\":\"en-ZZZ\"}", draft);
        }