public async Task TableStorageService_GetAllProviders_Returns_Expected_Results() { var providerEntities = new ProviderEntityListBuilder() .Add() .Build(); var locationEntities = new LocationEntityListBuilder() .Add() .Build(); var providerRepository = Substitute.For <ICloudTableRepository <ProviderEntity> >(); providerRepository .GetAll() .Returns(providerEntities); var locationRepository = Substitute.For <ICloudTableRepository <LocationEntity> >(); locationRepository .GetAll() .Returns(locationEntities); var service = BuildTableStorageService(locationRepository, providerRepository); var providers = new ProviderListBuilder() .Add() .Build(); var result = await service.GetAllProviders(); result.Should().BeEquivalentTo(providers); }
public async Task TableStorageService_GetAllProviders_Returns_Expected_Results() { var providerEntities = new ProviderEntityListBuilder() .Add() .Build(); var locationEntities = new LocationEntityListBuilder() .Add() .Build(); var providerRepository = Substitute.For <ICloudTableRepository <ProviderEntity> >(); providerRepository .GetAll() .Returns(providerEntities); var locationRepository = Substitute.For <ICloudTableRepository <LocationEntity> >(); locationRepository .GetByPartitionKey(Arg.Any <string>()) .Returns(callInfo => { var partitionKey = callInfo.ArgAt <string>(0); var results = locationEntities.Where(p => p.PartitionKey == partitionKey); return(results.ToList()); }); var service = BuildTableStorageService(locationRepository, providerRepository); var providers = new ProviderListBuilder() .Add() .Build(); var result = await service.GetAllProviders(); result.Should().BeEquivalentTo(providers); }