示例#1
0
        public async Task ImportGenericComponents_ShouldReturnGenericComponents()
        {
            var mapComponentsClientMocked = new Mock <IMapComponentsClient>();

            var optionsMocked = new Mock <IOptions <AppSettings> >();

            optionsMocked.Setup(i => i.Value).Returns(new AppSettings {
                BcnConnectaApi = new BcnConnectaApi {
                    SensorType = "noise"
                }
            });

            var genericComponentService = new GenericComponentsImportService(_genericComponentRepositoryMocked, optionsMocked.Object, _loggerMocked, mapComponentsClientMocked.Object);

            mapComponentsClientMocked.Setup(x => x.GetMapComponentsFromBcnConnectaApi())
            .ReturnsAsync(await GeneratorMapComponentsDto.GenerateMapComponentsDtoAsync());

            var result = await genericComponentService.ImportGenericComponents();

            var expected = GenericComponentConverter.MapToEntity(GeneratorMapComponentsDto.GenerateMapComponentsDtoAsync().Result.Components.Where(i => i.Icon.Equals("noise")));

            Assert.Equal(expected.SingleOrDefault().IdComponent, result.SingleOrDefault().IdComponent);
        }
示例#2
0
 public IEnumerable <GenericComponent> GetGenericNoiseComponents(MapComponentsDto mapComponentsDto)
 {
     return(GenericComponentConverter.MapToEntity(mapComponentsDto.Components.Where(i => i.Icon.Equals(_appSettings.BcnConnectaApi.SensorType)).ToList()));
 }