public void ImportRenUk_Successful() { // Arrange var dataService = new DataService(_repository, _dataSourceRepository, _dataTypeRepository,_importServiceResolver, _dataSourceResolver); var inputDoc = _htmlDoc; using (ShimsContext.Create()) { // Fake the call to the internet HtmlAgilityPack.Fakes.ShimHtmlWeb.AllInstances.LoadString = (htmlWeb, s) => { return inputDoc; }; // Fake the statue code returned from HTTP response HtmlAgilityPack.Fakes.ShimHtmlWeb.AllInstances.StatusCodeGet = (web => { return System.Net.HttpStatusCode.OK; }); // Act var result = dataService.ImportDataSource(2, baseUrl); // Assert Assert.IsTrue(result, "Expected a successful import to return True."); } }
public void ImportDataSource_UnSuccessful_ReturnsFALSE() { // Arrange var mockImportService = new Mock<IRenUkImportService>(); mockImportService.Setup(i => i.ImportData(It.IsAny<int>(), It.IsAny<string>())).Returns(false); _mockImportServiceResolver.Setup(r => r.Resolve(It.IsAny<int>())).Returns(mockImportService.Object); var dataService = new DataService(_mockAggregateRepository.Object, _mockDatasourceRepository.Object, _mockDataTypeRepository.Object, _mockImportServiceResolver.Object, _mockDataSourceResolver.Object); // Act var result = dataService.ImportDataSource(2, string.Empty); // Assert Assert.IsFalse(result, "Expected Import to be unsuccessfull and return FALSE."); }