コード例 #1
0
        public EventRepositoryTest()
        {
            // Arrange
            _config = new ContentfulConfig("test")
                      .Add("DELIVERY_URL", "https://fake.url")
                      .Add("TEST_SPACE", "SPACE")
                      .Add("TEST_ACCESS_KEY", "KEY")
                      .Add("TEST_MANAGEMENT_KEY", "KEY")
                      .Build();

            // Mock
            _mockTimeProvider.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), string.Empty, false));

            // TODO: Make this into a mock instead of concrete class, will need refactor to tests with this also
            var contentfulFactory    = new EventContentfulFactory(_documentFactory.Object, _groupFactory.Object, _eventCategoryFactory.Object, _alertFactory.Object, _mockTimeProvider.Object);
            var eventHomepageFactory = new EventHomepageContentfulFactory(_mockTimeProvider.Object);

            _contentfulClientManager.Setup(o => o.GetClient(_config)).Returns(_contentfulClient.Object);
            _eventCategoryFactory.Setup(o => o.ToModel(It.IsAny <ContentfulEventCategory>())).Returns(new EventCategory("", "", ""));
            _configuration.Setup(_ => _["redisExpiryTimes:Articles"]).Returns("60");
            _configuration.Setup(_ => _["redisExpiryTimes:Events"]).Returns("60");

            _repository = new EventRepository(_config, _contentfulClientManager.Object,
                                              _mockTimeProvider.Object, contentfulFactory, eventHomepageFactory, _cacheWrapper.Object, _logger.Object, _configuration.Object);
        }
コード例 #2
0
        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);
        }