public void Get_UnSuccessful_HttpStatusCode_NotFound() { var document = _testDoc; // Arrange var mockHelper = new Mock<IRenUkHtmlHelper>(); mockHelper.Setup(l => l.LoadHtmlPage(out document, It.IsAny<string>())) .Returns(HttpStatusCode.NotFound); // Instantiate the datasource class var dataSource = new RenUkDataSource(mockHelper.Object); // Act var result = dataSource.Get(rubbishBaseUrl); // Assert Assert.IsNull(result, "Expected 'null' to be returned "); //Assert.IsNull(result.Identifier, "Expected 'empty' object to be returned "); }
public void Get_Successful() { var document = _testDoc; // Arrange var mockHelper = new Mock<IRenUkHtmlHelper>(); mockHelper.Setup(l => l.LoadHtmlPage(out document, It.IsAny<string>())) .Returns(HttpStatusCode.OK); mockHelper.Setup(n => n.GetAggregateNodes(It.IsAny<HtmlDocument>())).Returns(_aggregateNodes); mockHelper.Setup(m => m.GetAggregateName(_aggregateNodesArray[0])).Returns(_aggregateNamesArray[0]); mockHelper.Setup(v => v.GetAggregateColumnValues(It.IsAny<HtmlNode>())) .Returns("A JSON data object"); mockHelper.Setup(u => u.GetUrlFromJsonObject(It.IsAny<string>())).Returns("An External URL"); // Instantiate the datasource class var dataSource = new RenUkDataSource(mockHelper.Object); // Act var result = dataSource.Get(rubbishBaseUrl); var dataout = result.Data.First().Data; // Assert Assert.AreEqual(_aggregateData[1].Identifier, result.Identifier, "Expected Achairn to be returned "); Assert.AreEqual("A JSON data object", dataout, "Expected the 'JSON object to be returned in the data"); }