public void Should_have_opportunistically_cached_the_unique_id_from_the_usi_value_mapper() { // Value was cached opportunistically by initial call, so no call necessary A.CallTo( () => _usiValueMapper.GetUniqueId( A <string> .That.IsEqualTo(Staff), A <int> .That.IsEqualTo(_suppliedUsiValueMap.Usi))).MustNotHaveHappened(); }
protected override void Arrange() { _edFiOdsInstanceIdentificationProvider = new FakeEdFiOdsInstanceIdentificationProvider(); _personIdentifiersProvider = Stub <IPersonIdentifiersProvider>(); A.CallTo(() => _personIdentifiersProvider.GetAllPersonIdentifiers(A <string> ._)) .Returns(Task.Run(() => (IEnumerable <PersonIdentifiersValueMap>) new PersonIdentifiersValueMap[0])); // USI value mapper gets call twice during Act step, with first value on ODS instance 1, and second on ODS instance 2 _usiValueMapper = Stub <IUniqueIdToUsiValueMapper>(); A.CallTo(() => _usiValueMapper.GetUniqueId(A <string> .That.IsEqualTo(Staff), A <int> .That.IsEqualTo(11))) .Returns( new PersonIdentifiersValueMap { UniqueId = "ABC123", Usi = 11 }).Once(); A.CallTo(() => _usiValueMapper.GetUniqueId(A <string> .That.IsEqualTo(Staff), A <int> .That.IsEqualTo(11))) .Returns( new PersonIdentifiersValueMap { UniqueId = "CDE234", Usi = 11 }).Once(); SetupCaching(); void SetupCaching() { var memorycacheoption = A.Fake <IOptions <MemoryCacheOptions> >(); MemoryCache memoryCache = new MemoryCache(memorycacheoption); _memoryCacheProvider = new MemoryCacheProvider(memoryCache); _usiCache = new PersonUniqueIdToUsiCache( _memoryCacheProvider, _edFiOdsInstanceIdentificationProvider, _usiValueMapper, _personIdentifiersProvider, TimeSpan.Zero, TimeSpan.Zero, synchronousInitialization: true); } }
protected override void Arrange() { _edfiOdsInstanceIdentificationProvider = Stub <IEdFiOdsInstanceIdentificationProvider>(); _usiValueMapper = Stub <IUniqueIdToUsiValueMapper>(); _suppliedUsiValueMap = new PersonIdentifiersValueMap { UniqueId = Guid.NewGuid() .ToString(), Usi = 10, Id = Guid.NewGuid() // Id is also provided by the USI value mapper }; A.CallTo(() => _usiValueMapper.GetUniqueId(A <string> ._, A <int> ._)) .Returns(_suppliedUsiValueMap); _personIdentifiersProvider = Stub <IPersonIdentifiersProvider>(); A.CallTo(() => _personIdentifiersProvider.GetAllPersonIdentifiers(A <string> ._)) .Returns(Task.Run(() => (IEnumerable <PersonIdentifiersValueMap>) new PersonIdentifiersValueMap[0])); SetupCaching(); void SetupCaching() { var memorycacheoption = A.Fake <IOptions <MemoryCacheOptions> >(); MemoryCache memoryCache = new MemoryCache(memorycacheoption); _memoryCacheProvider = new MemoryCacheProvider(memoryCache); _usiCache = new PersonUniqueIdToUsiCache( _memoryCacheProvider, _edfiOdsInstanceIdentificationProvider, _usiValueMapper, _personIdentifiersProvider, TimeSpan.Zero, TimeSpan.Zero, synchronousInitialization: true); PersonUniqueIdToUsiCache.GetCache = () => _usiCache; } }
public void Should_call_value_mapper_for_the_unique_id() { A.CallTo( () => _usiValueMapper.GetUniqueId( A <string> .That.IsEqualTo(Staff), A <int> .That.IsEqualTo(_suppliedUsiValueMap.Usi))).MustHaveHappened(); }