public AtoZRepository(ContentfulConfig config, IContentfulClientManager clientManager, IContentfulFactory <ContentfulAtoZ, AtoZ> contentfulAtoZFactory, ITimeProvider timeProvider, ICache cache, IConfiguration configuration, ILogger logger) { _client = clientManager.GetClient(config); _contentfulApiUrl = config.ContentfulUrl.ToString(); _contentfulAtoZFactory = contentfulAtoZFactory; _dateComparer = new DateComparer(timeProvider); _cache = cache; _configuration = configuration; _logger = logger; int.TryParse(_configuration["redisExpiryTimes:AtoZ"], out _atoZTimeout); }
public void Compare7() { DateComparer comparer = DateComparer.DefaultInvariant as DateComparer; ExceptionAssert.Throws <FormatException>(() => comparer.Compare("10/31/2006", "abc123")); ExceptionAssert.Throws <FormatException>(() => comparer.Compare("abc123", "10/31/2006")); ExceptionAssert.Throws <FormatException>(() => comparer.Compare("10/31/2006", String.Empty)); ExceptionAssert.Throws <FormatException>(() => comparer.Compare(String.Empty, "10/31/2006")); ExceptionAssert.Throws <ArgumentNullException>(() => comparer.Compare("10/31/2006", null)).WithParameter("y"); ExceptionAssert.Throws <ArgumentNullException>(() => comparer.Compare(null, "10/31/2006")).WithParameter("x"); ExceptionAssert.Throws <ArgumentNullException>(() => new DateComparer(null)); }
public CarouselContent ToModel(ContentfulCarouselContent carousel) { var title = carousel.Title ?? string.Empty; var slug = carousel.Slug ?? string.Empty; var teaser = carousel.Teaser ?? string.Empty; var image = ContentfulHelpers.EntryIsNotALink(carousel.Image.SystemProperties) ? carousel.Image.File.Url : string.Empty; var url = carousel.Url ?? string.Empty; DateTime sunriseDate = DateComparer.DateFieldToDate(carousel.SunriseDate); DateTime sunsetDate = DateComparer.DateFieldToDate(carousel.SunsetDate); return(new CarouselContent(title, slug, teaser, image, sunriseDate, sunsetDate, url)); }
public void Compare4() { DateComparer comparer = DateComparer.DefaultInvariant as DateComparer; object x = "10/31/2006"; object y = "11/1/2006"; Assert.IsTrue(comparer.Compare(x, y) < 0); Assert.IsTrue(comparer.Compare(y, x) > 0); Assert.IsTrue(comparer.Compare(x, x) == 0); x = String.Empty; y = String.Empty; Assert.IsTrue(comparer.Compare(x, "10/31/2006") == -1); Assert.IsTrue(comparer.Compare("10/31/2006", y) == 1); Assert.IsTrue(comparer.Compare(x, y) == 0); }
public void Compare9() { var comparer = new DateComparer(); object x = "10/31/2006"; object y = "11/1/2006"; Assert.IsTrue(comparer.Compare(x, y) < 0); Assert.IsTrue(comparer.Compare(y, x) > 0); Assert.IsTrue(comparer.Compare(x, x) == 0); x = String.Empty; y = String.Empty; Assert.IsTrue(comparer.Compare(x, "10/31/2006") == -1); Assert.IsTrue(comparer.Compare("10/31/2006", y) == 1); Assert.IsTrue(comparer.Compare(x, y) == 0); }
public EventRepository(ContentfulConfig config, IContentfulClientManager contentfulClientManager, ITimeProvider timeProvider, IContentfulFactory <ContentfulEvent, Event> contentfulFactory, IContentfulFactory <ContentfulEventHomepage, EventHomepage> contentfulEventHomepageFactory, ICache cache, ILogger <EventRepository> logger, IConfiguration configuration) { _contentfulFactory = contentfulFactory; _contentfulEventHomepageFactory = contentfulEventHomepageFactory; _dateComparer = new DateComparer(timeProvider); _client = contentfulClientManager.GetClient(config); _cache = cache; _logger = logger; _configuration = configuration; int.TryParse(_configuration["redisExpiryTimes:Events"], out _eventsTimeout); _timeProvider = timeProvider; }
public ArticleContentfulFactory(IContentfulFactory <ContentfulSection, Section> sectionFactory, IContentfulFactory <ContentfulReference, Crumb> crumbFactory, IContentfulFactory <ContentfulProfile, Profile> profileFactory, IContentfulFactory <ContentfulArticle, Topic> parentTopicFactory, IContentfulFactory <Asset, Document> documentFactory, IVideoRepository videoRepository, ITimeProvider timeProvider, IContentfulFactory <ContentfulAlert, Alert> alertFactory) { _sectionFactory = sectionFactory; _crumbFactory = crumbFactory; _profileFactory = profileFactory; _documentFactory = documentFactory; _videoRepository = videoRepository; _parentTopicFactory = parentTopicFactory; _dateComparer = new DateComparer(timeProvider); _alertFactory = alertFactory; }
public ArticleRepository(ContentfulConfig config, IContentfulClientManager contentfulClientManager, ITimeProvider timeProvider, IContentfulFactory <ContentfulArticle, Article> contentfulFactory, IContentfulFactory <ContentfulArticleForSiteMap, ArticleSiteMap> contentfulFactoryArticle, IVideoRepository videoRepository, ICache cache, IConfiguration configuration) { _contentfulFactory = contentfulFactory; _dateComparer = new DateComparer(timeProvider); _client = contentfulClientManager.GetClient(config); _videoRepository = videoRepository; _contentfulFactoryArticle = contentfulFactoryArticle; _cache = cache; _configuration = configuration; int.TryParse(_configuration["redisExpiryTimes:Articles"], out _articleTimeout); }
public GroupRepository(ContentfulConfig config, IContentfulClientManager clientManager, ITimeProvider timeProvider, IContentfulFactory <ContentfulGroup, Group> groupFactory, IContentfulFactory <ContentfulGroupCategory, GroupCategory> groupCategoryFactory, IContentfulFactory <ContentfulGroupHomepage, GroupHomepage> groupHomepageContentfulFactory, EventRepository eventRepository, ICache cache, IConfiguration configuration ) { _dateComparer = new DateComparer(timeProvider); _client = clientManager.GetClient(config); _groupFactory = groupFactory; _groupCategoryFactory = groupCategoryFactory; _eventRepository = eventRepository; _cache = cache; _configuration = configuration; int.TryParse(_configuration["redisExpiryTimes:Groups"], out _groupsTimeout); _groupHomepageContentfulFactory = groupHomepageContentfulFactory; }
public GroupContentfulFactory(IContentfulFactory <ContentfulOrganisation, Organisation> contentfulOrganisationFactory, IContentfulFactory <ContentfulGroupCategory, GroupCategory> contentfulGroupCategoryFactory, IContentfulFactory <ContentfulGroupSubCategory, GroupSubCategory> contentfulGroupSubCategoryFactory, ITimeProvider timeProvider, IContentfulFactory <Asset, Document> documentFactory, IContentfulFactory <ContentfulGroupBranding, GroupBranding> groupBrandingFactory, IContentfulFactory <ContentfulAlert, Alert> alertFactory) { _contentfulOrganisationFactory = contentfulOrganisationFactory; _contentfulGroupCategoryFactory = contentfulGroupCategoryFactory; _contentfulGroupSubCategoryFactory = contentfulGroupSubCategoryFactory; _dateComparer = new DateComparer(timeProvider); _documentFactory = documentFactory; _contentfulGroupBrandingFactory = groupBrandingFactory; _alertFactory = alertFactory; }
/// <summary> /// Sets up the selected comparer. /// </summary> /// <param name="commandArgument">The command argument indicating what comparer to set up.</param> private void SetupSelectedComparer(string commandArgument) { SortingColumn = commandArgument; switch (commandArgument) { case "name": SelectedComparer = new NameComparer(Direction); break; case "size": SelectedComparer = new SizeComparer(Direction); break; case "checkedOut": SelectedComparer = new CheckedOutByComparer(Direction); break; case "lastChanged": SelectedComparer = new DateComparer(Direction); break; } }
public ShowcaseContentfulFactory(IContentfulFactory <ContentfulReference, SubItem> subitemFactory, IContentfulFactory <ContentfulReference, Crumb> crumbFactory, ITimeProvider timeProvider, IContentfulFactory <ContentfulSocialMediaLink, SocialMediaLink> socialMediaFactory, IContentfulFactory <ContentfulAlert, Alert> alertFactory, IContentfulFactory <ContentfulProfile, Profile> profileFactory, IContentfulFactory <ContentfulTrivia, Trivia> triviaFactory, IContentfulFactory <ContentfulCallToActionBanner, CallToActionBanner> callToActionBannerContentfulFactory, IContentfulFactory <ContentfulVideo, Video> videoFactory, IContentfulFactory <ContentfulSpotlightBanner, SpotlightBanner> spotlightBannerFactory) { _subitemFactory = subitemFactory; _crumbFactory = crumbFactory; _socialMediaFactory = socialMediaFactory; _dateComparer = new DateComparer(timeProvider); _alertFactory = alertFactory; _profileFactory = profileFactory; _callToActionBannerContentfulFactory = callToActionBannerContentfulFactory; _triviaFactory = triviaFactory; _videoFactory = videoFactory; _spotlightBannerFactory = spotlightBannerFactory; }
public SubItemContentfulFactory(ITimeProvider timeProvider) { _dateComparer = new DateComparer(timeProvider); }
public PaymentContentfulFactory(IContentfulFactory <ContentfulAlert, Alert> alertFactory, ITimeProvider timeProvider, IContentfulFactory <ContentfulReference, Crumb> crumbFactory) { _alertFactory = alertFactory; _dateComparer = new DateComparer(timeProvider); _crumbFactory = crumbFactory; }
public void Test_DateStringsMatch_Functional(string date1, string date2, bool expectedResult) { bool result = DateComparer.DateStringsMatch(date1, date2); Assert.Equal(expectedResult, result); }
public DateComparerTest() { _dateNow = new Mock <ITimeProvider>(); _comparer = new DateComparer(_dateNow.Object); }
public NewsRoomContentfulFactory(IContentfulFactory <ContentfulAlert, Alert> alertFactory, ITimeProvider timeProvider) { _alertFactory = alertFactory; _dateComparer = new DateComparer(timeProvider); }
void addFolder(string recTVFolder) { DirectoryInfo di = new DirectoryInfo(recTVFolder); ArrayList files = new ArrayList(); files.AddRange(di.GetFiles("*.wtv")); files.AddRange(di.GetFiles("*.dvr-ms")); IComparer dateComparer = new DateComparer(); files.Sort(dateComparer); foreach (FileInfo fi in files) { try { // If file is not in use, add it, otherwise postpone it AddTVProgrammeResults ATVresult = AddTVProgrammeIfPossible(fi); if (ATVresult != AddTVProgrammeResults.Success) { DebugNormal("Cannot add " + fi.Name + " yet, file in use - postponing."); if (!PostponedFiles.Contains(fi.FullName)) PostponedFiles.Add(fi.FullName); } else DebugNormal("Added " + fi.Name); } catch (Exception ex) { DebugError(ex); } } if (Settings.Default.RecurseRecTVSubfolders) { foreach (DirectoryInfo diDir in di.GetDirectories()) { FileAttributes att = diDir.Attributes; if ((att & FileAttributes.Hidden) == FileAttributes.Hidden) continue; if ((att & FileAttributes.System) == FileAttributes.System) continue; addFolder(diDir.FullName); } } }
public ParentTopicContentfulFactory(IContentfulFactory <ContentfulReference, SubItem> subItemFactory, ITimeProvider timeProvider) { _subItemFactory = subItemFactory; _dateComparer = new DateComparer(timeProvider); }
public void ShouldReturnMinimumDateTimePossibleFromAInvalidDateString() { var date = DateComparer.DateFieldToDate("not-valid"); date.Should().Be(DateTime.MinValue); }
public void Compare9() { DateComparer comparer = new DateComparer(); object x = "10/31/2006"; object y = "11/1/2006"; Assert.IsTrue(comparer.Compare(x, y) < 0); Assert.IsTrue(comparer.Compare(y, x) > 0); Assert.IsTrue(comparer.Compare(x, x) == 0); x = String.Empty; y = String.Empty; Assert.IsTrue(comparer.Compare(x, "10/31/2006") == -1); Assert.IsTrue(comparer.Compare("10/31/2006", y) == 1); Assert.IsTrue(comparer.Compare(x, y) == 0); }
public EventHomepageContentfulFactory(ITimeProvider timeProvider) { _dateComparer = new DateComparer(timeProvider); }
public StartPageRepository(ContentfulConfig config, IContentfulClientManager contentfulClientManager, IContentfulFactory <ContentfulStartPage, StartPage> contentfulFactory, ITimeProvider timeProvider) { _contentfulFactory = contentfulFactory; _client = contentfulClientManager.GetClient(config); _dateComparer = new DateComparer(timeProvider); }
public new void Sort(SortDirection dir) { DateComparer dtComp = new DateComparer(dir); base.Sort(SortDirection.Ascending, dtComp); }
private static string GetCommentAction(string createdAt, string updatedAt) { return(DateComparer.DateStringsMatch(createdAt, updatedAt) ? "commented" : "updated the comment"); }
public ExpandingLinkBoxContentfulfactory(IContentfulFactory <ContentfulReference, SubItem> subitemFactory, ITimeProvider timeProvider) { _subitemFactory = subitemFactory; _dateComparer = new DateComparer(timeProvider); }