public void CompaniesURIs_NotExistingUri() { // Arrange var inputValues = new Dictionary <string, Uri>() { { "FirstCompany", new Uri("https://www.dropbox.com/s/4rwsu8goeq7zx1h/bbc_world.xml?dl=1") }, { "SecondCompany", new Uri("http://example.com/rss.xml") }, }; // Act Func <Task> act = () => RawToDTOFormatter.Format(inputValues); // Assert Assert.ThrowsAsync <WebException>(act); }
public void CompaniesURIs_EmptyURIThrowsException() { // Arrange var inputValues = new Dictionary <string, Uri>() { { "FirstCompany", new Uri("https://www.example1.com") }, { "SecondCompany", null } }; // Act Func <Task> act = () => RawToDTOFormatter.Format(inputValues); // Assert Assert.ThrowsAsync <ArgumentException>(act); }
public void CompaniesXMLs_EmptyXMLThrowsException() { // Arrange var inputValues = new Dictionary <string, string>() { { "FirstCompany", "xml" }, { "SecondCompany", "" } }; // Act Func <Task> act = () => RawToDTOFormatter.Format(inputValues); // Assert Assert.ThrowsAsync <ArgumentException>(act); }
public void CompaniesURIs_InvalidXml() { // Arrange var inputValues = new Dictionary <string, Uri>() { { "FirstCompany", new Uri("https://www.dropbox.com/s/4rwsu8goeq7zx1h/bbc_world.xml?dl=1") }, { "SecondCompany", new Uri("https://www.dropbox.com/s/acypcml3d89v38i/bbc_world_addition.xml?dl=1") }, { "ErrorCompany", new Uri("https://www.dropbox.com/s/enthqc1pvfz8t8e/bbc_world_error.xml?dl=1") } }; // Act Func <Task> act = () => RawToDTOFormatter.Format(inputValues); // Assert Assert.ThrowsAsync <XmlException>(act); }
public async Task CompaniesURIs_TwoCompaniesWith4And11Items() { // Arrange var inputValues = new Dictionary <string, Uri>() { { "FirstCompany", new Uri("https://www.dropbox.com/s/4rwsu8goeq7zx1h/bbc_world.xml?dl=1") }, { "SecondCompany", new Uri("https://www.dropbox.com/s/acypcml3d89v38i/bbc_world_addition.xml?dl=1") }, }; // Act var result = await RawToDTOFormatter.Format(inputValues); // Assert var firstCompanyFeedCount = result.First(x => x.Company == "FirstCompany").Feed.Count(); var secondCompanyFeedCount = result.First(x => x.Company == "SecondCompany").Feed.Count(); Assert.True(firstCompanyFeedCount == 4 && secondCompanyFeedCount == 11); }
public async Task CompaniesXMLs_TwoCompaniesWith3And2Items() { // Arrange var exampleXmlNotOlder2Days = File.ReadAllText("RssExample_NotOlder2Days.xml"); var exampleXmlOlder2Days = File.ReadAllText("RssExample_Older2Days.xml"); var inputValues = new Dictionary <string, string>() { { "FirstCompany", exampleXmlNotOlder2Days }, { "SecondCompany", exampleXmlOlder2Days } }; // Act var result = await RawToDTOFormatter.Format(inputValues); // Assert var itemsCountNotOlder = result.First(x => x.Company == "FirstCompany").Feed.Count(); var itemsCountOlder = result.First(x => x.Company == "SecondCompany").Feed.Count(); Assert.True(itemsCountNotOlder == 3 && itemsCountOlder == 2); }
public void CompaniesXMLs_InvalidXml() { // Arrange var exampleXmlNotOlder2Days = File.ReadAllText("RssExample_NotOlder2Days.xml"); var exampleXmlOlder2Days = File.ReadAllText("RssExample_Older2Days.xml"); var exampleXmlInvalid = File.ReadAllText("RssExample_Invalid.xml"); var inputValues = new Dictionary <string, string>() { { "FirstCompany", exampleXmlNotOlder2Days }, { "SecondCompany", exampleXmlOlder2Days }, { "ErrorCompany", exampleXmlInvalid } }; // Act Func <Task> act = () => RawToDTOFormatter.Format(inputValues); // Assert Assert.ThrowsAsync <XmlException>(act); }
/// <summary> /// Gets list of companies which were inactive for <paramref name="inactiveDaysCount"/> /// based on <paramref name="companiesRssUris"/> /// </summary> /// <param name="companiesRssUris"> dictionary of CompanyName and RSS XML </param> /// <param name="inactiveDaysCount"> days count during on which we need to check companies for activity </param> /// <returns> list of inactive companies </returns> public async Task <IEnumerable <string> > GetInactiveCompanies(Dictionary <string, string> companiesRssXmls, int inactiveDaysCount) { var companiesFeeds = await RawToDTOFormatter.Format(companiesRssXmls); return(_companyInactiveCalcAlgorithm.GetInactiveCompanies(companiesFeeds, inactiveDaysCount)); }