public EventContentfulFactoryTest()
        {
            _contentfulEvent = new ContentfulEventBuilder().Build();

            _documentFactory      = new Mock <IContentfulFactory <Asset, Document> >();
            _alertFactory         = new Mock <IContentfulFactory <ContentfulAlert, Alert> >();
            _groupFactory         = new Mock <IContentfulFactory <ContentfulGroup, Group> >();
            _eventCategoryFactory = new Mock <IContentfulFactory <ContentfulEventCategory, EventCategory> >();
            _timeProvider         = new Mock <ITimeProvider>();

            _timeProvider.Setup(o => o.Now()).Returns(new DateTime(2017, 01, 01));

            _alertFactory.Setup(o => o.ToModel(It.IsAny <ContentfulAlert>())).Returns(new Alert("title", "subHeading", "body",
                                                                                                "severity", new DateTime(0001, 1, 1, 0, 0, 0, DateTimeKind.Utc),
                                                                                                new DateTime(9999, 9, 9, 0, 0, 0, DateTimeKind.Utc), "slug", false));

            _eventContentfulFactory = new EventContentfulFactory(_documentFactory.Object, _groupFactory.Object, _eventCategoryFactory.Object, _alertFactory.Object, _timeProvider.Object);
        }
Ejemplo n.º 2
0
        public void ShouldSetDefaultsOnModel()
        {
            var actual = new ContentfulEvent();

            var expected = new ContentfulEvent
            {
                Title  = string.Empty,
                Slug   = string.Empty,
                Teaser = string.Empty,
                Image  = new Asset {
                    File = new File {
                        Url = string.Empty
                    }, SystemProperties = new SystemProperties {
                        Type = "Asset"
                    }
                },
                Description        = string.Empty,
                Fee                = string.Empty,
                Location           = string.Empty,
                SubmittedBy        = string.Empty,
                EventDate          = DateTime.MinValue.ToUniversalTime(),
                StartTime          = string.Empty,
                EndTime            = string.Empty,
                Occurences         = 0,
                Frequency          = EventFrequency.None,
                Documents          = new List <Asset>(),
                MapPosition        = new MapPosition(),
                BookingInformation = string.Empty,
                Featured           = false,
                Sys                = new SystemProperties(),
                Tags               = new List <string>(),
                Alerts             = new List <ContentfulAlert>()
            };

            actual.Should().BeEquivalentTo(expected);
        }
Ejemplo n.º 3
0
        private ManagementEvent ConvertToManagementEvent(Event eventDetail, List <ContentfulEventCategory> categories, ContentfulEvent existingEvent)
        {
            var contentfulEvent = _mapper.Map <ContentfulEvent>(eventDetail);

            contentfulEvent.EventCategories = categories;
            contentfulEvent.Image           = existingEvent.Image;
            contentfulEvent.Group           = existingEvent.Group;
            contentfulEvent.Documents       = existingEvent.Documents;
            var managementEvent = new ManagementEvent();

            _mapper.Map(contentfulEvent, managementEvent);
            return(managementEvent);
        }