public void TestTimeConversionFromUnixTimeStamp(int timeStamp, string expected) { var storyMapper = new StoryMapper(); var outDateTime = storyMapper.GetDotNetTimeFromUnixTime(timeStamp); Assert.Equal(outDateTime.ToLongTimeString(), expected); }
public void TestURLExtraction(string url, string expected) { var storyMapper = new StoryMapper(); var outUrl = storyMapper.GetDomainFromURI(url); Assert.Equal(outUrl, expected); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddHttpClient(); services.AddControllersWithViews(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); // wiring up application specific dependencies var restApiConfig = new RestApiConfig(); services.AddSingleton(typeof(IApiConfig), restApiConfig); var serializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; services.AddSingleton(typeof(JsonSerializerSettings), serializerSettings); var storyMapper = new StoryMapper(serializerSettings); services.AddSingleton(typeof(IItemMapper <Story>), storyMapper); var commentMapper = new CommentMapper(serializerSettings); services.AddSingleton(typeof(IItemMapper <Comment>), commentMapper); IServiceProvider provider = services.BuildServiceProvider(false); services.AddSingleton <IHackerNewsClient <Story> >(c => { return(new HackerNewsRestClient <Story>(restApiConfig, provider.GetService <IHttpClientFactory>(), provider.GetService <ILogger <HackerNewsRestClient <Story> > >(), storyMapper)); } ); services.AddSingleton <IHackerNewsClient <Comment> >(c => { return(new HackerNewsRestClient <Comment>(restApiConfig, provider.GetService <IHttpClientFactory>(), provider.GetService <ILogger <HackerNewsRestClient <Comment> > >(), commentMapper)); } ); }