public void ShouldGetsASinglePaymentItemFromASlug() { // Arrange const string slug = "any-payment"; var rawPayment = new ContentfulServicePayPaymentBuilder().Slug(slug).AccountReference("accountRef").CatalogueId("catId").Build(); var collection = new ContentfulCollection <ContentfulServicePayPayment> { Items = new List <ContentfulServicePayPayment> { rawPayment } }; var builder = new QueryBuilder <ContentfulServicePayPayment>().ContentTypeIs("servicePayPayment").FieldEquals("fields.slug", slug).Include(1); _contentfulClient.Setup(o => o.GetEntries( It.Is <QueryBuilder <ContentfulServicePayPayment> >( q => q.Build() == builder.Build()), It.IsAny <CancellationToken>())) .ReturnsAsync(collection); // Act var response = AsyncTestHelper.Resolve(_repository.GetPayment(slug)); var paymentItem = response.Get <ServicePayPayment>(); // 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.Breadcrumbs.First().Title.Should().Be("title"); }
public void ShouldCreateAServicePayPaymentFromAContentfulServicePayPayment() { var contentfulPayment = new ContentfulServicePayPaymentBuilder() .Slug("payment-slug") .Title("payment title") .Teaser("payment teaser") .ReferenceLabel("reference label") .PaymentAmount("15.23") .Build(); _alertFactory = new Mock <IContentfulFactory <ContentfulAlert, Alert> >(); _timeProvider = new Mock <ITimeProvider>(); _crumbFactory = new Mock <IContentfulFactory <ContentfulReference, Crumb> >(); var contentfulFactory = new ServicePayPaymentContentfulFactory(_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"); payment.PaymentAmount.Should().Be("15.23"); }