public void GetAggregates_Successful_ReturnsCollection_InternalDataStoreValues() { //////IUnitOfWork uow = new AggregateContext(); //////IAggregateRepository aggregateRepository = new AggregateRepository(uow); // Arrange // Configure the AggregateRepository _mockAggregateRepository.Setup(r => r.GetAll()).Returns(_snhAggregates); // Configure the DataSourceRepository _mockDatasourceRepository.Setup(d => d.Get(1)).Returns(_dataSource1); _mockDatasourceRepository.Setup(d => d.Get(2)).Returns(_dataSource2); var dataService = new DataService(_mockAggregateRepository.Object, _mockDatasourceRepository.Object, _mockDataTypeRepository.Object, _mockImportServiceResolver.Object, _mockDataSourceResolver.Object); //////var dataService = new DataService(aggregateRepository, ////// _mockDatasourceRepository.Object, _mockDataTypeRepository.Object, ////// _mockImportServiceResolver.Object, _mockDataSourceResolver.Object); // Act var results = dataService.GetAggregates(string.Empty).ToArray(); // Assert Assert.AreEqual(2, results.Count(), "Expected 2 aggregates to be returned."); Assert.AreEqual("Achany Estate", results[0].Name, "Expected 'Achany Estate' to be returned as first object."); Assert.AreEqual("{achany estate}", results[0].Data.FirstOrDefault(t => t.DataType == DataTypeEnum.FootPrint).Data, "Expected original data '{achany estate}' to be returned"); Assert.AreEqual("Whitelee Windfarm", results[1].Name, "Expected 'Whitelee Windfarm' to be returned as second object."); Assert.AreEqual("{whitelee windfarm}", results[1].Data.FirstOrDefault(t => t.DataType == DataTypeEnum.FootPrint).Data, "Expected original data '{whitelee windfarm}' to be returned"); }
public void GetAggregates_Successful() { // Arrange: var dataService = new DataService(_repository, _dataSourceRepository, _dataTypeRepository, _importServiceResolver, _dataSourceResolver); // Act var result = dataService.GetAggregates(string.Empty).ToArray(); // Get all aggregates // Assert var minCount = result.Count() >= 10; Assert.IsTrue(minCount, "Expected at least 10 aggregates to be returned"); }
public void GetAggregates_Successful_ReturnsUnaltered_InvalidDataSource() { // Arrange // Configure the AggregateRepository _mockAggregateRepository.Setup(r => r.GetAll()).Returns(_snhAggregates); // Configure the DataSourceRepository _mockDatasourceRepository.Setup(d => d.Get(It.IsAny<int>())).Returns(() => null); var dataService = new DataService(_mockAggregateRepository.Object, _mockDatasourceRepository.Object, _mockDataTypeRepository.Object, _mockImportServiceResolver.Object, _mockDataSourceResolver.Object); // Act var results = dataService.GetAggregates(string.Empty).ToArray(); // Assert Assert.AreEqual(2, results.Count(), "Expected 2 aggregates to be returned."); Assert.AreEqual("Achany Estate", results[0].Name, "Expected 'Achany Estate' to be returned as first object."); Assert.AreEqual("{achany estate}", results[0].Data.FirstOrDefault(t => t.DataType == DataTypeEnum.FootPrint).Data, "Expected original data '{achany estate}' to be returned"); Assert.AreEqual("Whitelee Windfarm", results[1].Name, "Expected 'Whitelee Windfarm' to be returned as second object."); Assert.AreEqual("{whitelee windfarm}", results[1].Data.FirstOrDefault(t => t.DataType == DataTypeEnum.FootPrint).Data, "Expected original data '{whitelee windfarm}' to be returned"); }
public void GetAggregates_UnSuccessful_ReturnsEmpty_NoSourceValues() { // Arrange _mockAggregateRepository.Setup(r => r.GetAll()).Returns(new List<Aggregate>().AsQueryable); var dataService = new DataService(_mockAggregateRepository.Object, _mockDatasourceRepository.Object, _mockDataTypeRepository.Object, _mockImportServiceResolver.Object, _mockDataSourceResolver.Object); // Act var results = dataService.GetAggregates(string.Empty).ToArray(); // Assert Assert.AreEqual(0, results.Count(), "Expected zero aggregates to be returned."); }
public void GetAggregates_Successful_ReturnsUnaltered_InvalidResolver() { // Arrange // Configure the DataSourceResolver _mockDataSourceResolver.Setup(r => r.Resolve(It.IsAny<int>())).Returns(() => null); // Configure the AggregateRepository _mockAggregateRepository.Setup(r => r.GetAll()).Returns(_renUkAggregates); // Configure the DataSourceRepository _mockDatasourceRepository.Setup(d => d.Get(1)).Returns(_dataSource1); _mockDatasourceRepository.Setup(d => d.Get(2)).Returns(_dataSource2); var dataService = new DataService(_mockAggregateRepository.Object, _mockDatasourceRepository.Object, _mockDataTypeRepository.Object, _mockImportServiceResolver.Object, _mockDataSourceResolver.Object); // Act var results = dataService.GetAggregates(string.Empty).ToArray(); // Assert Assert.AreEqual(2, results.Count(), "Expected 2 aggregates to be returned."); Assert.AreEqual("Whitelee Windfarm", results[0].Name, "Expected 'Whitelee Windfarm' to be returned as first object."); Assert.AreEqual("{URL to Whiltelee Windfarm}", results[0].Data.FirstOrDefault(t => t.DataType == DataTypeEnum.Statistics).Data, "Expected the original data '{URL to Whiltelee Windfarm}' to be returned"); Assert.AreEqual("Blacklaw Windfarm", results[1].Name, "Expected 'Blacklaw Windfarm' to be returned as first object."); Assert.AreEqual("{URL to Blacklaw Windfarm}", results[1].Data.FirstOrDefault(t => t.DataType == DataTypeEnum.Statistics).Data, "Expected the original data '{URL to Blacklaw Windfarm}' to be returned"); }