public static void LoadSourceJson(string configFolder) { string configContent = ""; string configFilePath = System.IO.Path.Combine(configFolder, "ARTICLES_SOURCE.JSON"); try { StreamReader readerFile = new StreamReader(configFilePath, Encoding.GetEncoding("windows-1250")); configContent = readerFile.ReadToEnd(); readerFile.Close(); } catch (Exception ex) { System.Diagnostics.Debug.Print(ex.Message); } var contractSourceConverter = new ArticleJsonConverter <ContractTermArticle>(); var positionSourceConverter = new ArticleJsonConverter <PositionTermArticle>(); JsonSerializerSettings settings = new JsonSerializerSettings(); settings.Converters.Add(contractSourceConverter); settings.Converters.Add(positionSourceConverter); // var ImportArticleCollection = JsonConvert.DeserializeObject<List<IArticleSource>>(configContent, settings); }
private static Page <Article> InvokeReadJsonMethodOnConverter(ArticleJsonConverter converter) { var actual = converter.ReadJson(new JsonTextReader(new StringReader(json)), typeof(Page <Article>), "", new Mock <JsonSerializer>().Object) as Page <Article>; return(actual); }
public void The_Page_Model_Is_Populated_With_The_Bread_Crumb_Details(ArticleJsonConverter converter) { var actual = InvokeReadJsonMethodOnConverter(converter); actual.Breadcrumbs.Should().NotBeNull(); actual.Breadcrumbs.LandingPageSlug.Should().NotBeNullOrWhiteSpace(); actual.Breadcrumbs.HubPage.Should().NotBeNullOrWhiteSpace(); actual.Breadcrumbs.LandingPage.Should().NotBeNullOrWhiteSpace(); }
public void The_Page_Model_Is_Populated_With_Page_Information(ArticleJsonConverter converter) { var actual = InvokeReadJsonMethodOnConverter(converter); actual.Slug.Should().NotBeNullOrWhiteSpace(); actual.Title.Should().NotBeNullOrWhiteSpace(); actual.MetaContent.MetaDescription.Should().NotBeNullOrWhiteSpace(); actual.MetaContent.PageTitle.Should().NotBeNullOrWhiteSpace(); }
public static void LoadSourceJson(string configFolder) { DateTime?TestDateFrom = new DateTime(2010, 1, 1); DateTime?TestDateStop = null; var contractSource = new ContractTermArticle( new ContractTermSource(TestDateFrom, TestDateStop, WorkEmployTerms.WORKTERM_EMPLOYMENT_1)); var positionSource = new PositionTermArticle( new PositionTermSource(TestDateFrom, TestDateStop, WorkPositionType.POSITION_EXCLUSIVE)); var ImportArticleCollection = new IArticleSource[] { contractSource, positionSource, }; //var articleSourceConverter = new ArticleJsonConverter<IArticleSource>(); var contractSourceConverter = new ArticleJsonConverter <ContractTermArticle>(); var positionSourceConverter = new ArticleJsonConverter <PositionTermArticle>(); string configContent = JsonConvert.SerializeObject(ImportArticleCollection, Formatting.Indented, contractSourceConverter, positionSourceConverter); string configFilePath = System.IO.Path.Combine(configFolder, "ARTICLES_SOURCE.JSON"); try { StreamWriter writerFile = new StreamWriter(configFilePath, false, Encoding.GetEncoding("windows-1250")); writerFile.Write(configContent); writerFile.Flush(); writerFile.Close(); } catch (Exception ex) { System.Diagnostics.Debug.Print(ex.Message); } }
public void The_Page_Model_Is_Populated_With_The_Page_Controls(ArticleJsonConverter converter) { var actual = InvokeReadJsonMethodOnConverter(converter); actual.Content.PageControls.Should().NotBeNullOrEmpty(); }
public void The_Page_Model_Is_Populated_With_Related_Page_Information(ArticleJsonConverter converter) { var actual = InvokeReadJsonMethodOnConverter(converter); actual.RelatedPages.Should().NotBeNullOrEmpty(); }
public void The_Page_Model_Is_Returned(ArticleJsonConverter converter) { var actual = InvokeReadJsonMethodOnConverter(converter); actual.Should().NotBeNull(); }