Beispiel #1
0
        public void ShouldGetsASinglePaymentItemFromASlug()
        {
            // Arrange
            const string slug = "any-payment";

            var rawPayment = new ContentfulPaymentBuilder().Slug(slug).Build();
            var collection = new ContentfulCollection <ContentfulPayment>();

            collection.Items = new List <ContentfulPayment> {
                rawPayment
            };

            var builder = new QueryBuilder <ContentfulPayment>().ContentTypeIs("payment").FieldEquals("fields.slug", slug).Include(1);

            _contentfulClient.Setup(o => o.GetEntries(
                                        It.Is <QueryBuilder <ContentfulPayment> >(
                                            q => q.Build() == builder.Build()),
                                        It.IsAny <CancellationToken>()))
            .ReturnsAsync(collection);

            // Act
            var response    = AsyncTestHelper.Resolve(_repository.GetPayment(slug));
            var paymentItem = response.Get <Payment>();

            // Assert
            response.StatusCode.Should().Be(HttpStatusCode.OK);
            paymentItem.Description.Should().Be(rawPayment.Description);
            paymentItem.Title.Should().Be(rawPayment.Title);
            paymentItem.Teaser.Should().Be(rawPayment.Teaser);
            paymentItem.Slug.Should().Be(rawPayment.Slug);
            paymentItem.PaymentDetailsText.Should().Be(rawPayment.PaymentDetailsText);
            paymentItem.ParisReference.Should().Be(rawPayment.ParisReference);
            paymentItem.Breadcrumbs.First().Title.Should().Be("title");
        }
        public void ShouldCreateAPaymentFromAContentfulPayment()
        {
            var contentfulPayment = new ContentfulPaymentBuilder()
                                    .Slug("payment-slug")
                                    .Title("payment title")
                                    .Teaser("payment teaser")
                                    .ReferenceLabel("reference label")
                                    .Build();

            _alertFactory = new Mock <IContentfulFactory <ContentfulAlert, Alert> >();
            _timeProvider = new Mock <ITimeProvider>();
            _crumbFactory = new Mock <IContentfulFactory <ContentfulReference, Crumb> >();
            var contentfulFactory = new PaymentContentfulFactory(_alertFactory.Object, _timeProvider.Object, _crumbFactory.Object);

            var payment = contentfulFactory.ToModel(contentfulPayment);

            payment.Slug.Should().Be("payment-slug");
            payment.Title.Should().Be("payment title");
            payment.Teaser.Should().Be("payment teaser");
            payment.ReferenceLabel.Should().Be("reference label");
            payment.MetaDescription.Should().Be("metaDescription");
        }