protected override void Arrange() { edfiOdsInstanceIdentificationProvider = Stub <IEdFiOdsInstanceIdentificationProvider>(); edOrgValueMapper = Stub <IEducationOrganizationIdentifiersValueMapper>(); educationOrganizationIdentifiersProvider = Stub <IEducationOrganizationCacheDataProvider>(); educationOrganizationIdentifiersProvider.Stub(x => x.GetAllEducationOrganizationIdentifiers()) .IgnoreArguments() .Return( Task.Run( () => (IEnumerable <EducationOrganizationIdentifiers>) new EducationOrganizationIdentifiers[0])); // edorg value mapper suppliedEdOrgValueMap = new EducationOrganizationIdentifiers( educationOrganizationId: 123456, educationOrganizationType: "District", stateEducationAgencyId: 1, educationServiceCenterId: 330950, localEducationAgencyId: 123456); edOrgValueMapper.Stub(x => x.GetEducationOrganizationIdentifiers(default(int))) .IgnoreArguments() .Return(suppliedEdOrgValueMap); }
/// <summary> /// /// </summary> /// <param name="cacheProvider">The cache where the database-specific maps (dictionaries) are stored, expiring after 4 hours of inactivity.</param> /// <param name="edFiOdsInstanceIdentificationProvider">Identifies the ODS instance for the current call.</param> /// <param name="educationOrganizationIdentifiersValueMapper">A component that maps between USI and UniqueId values.</param> /// <param name="educationOrganizationIdentifiersProvider">A component that retrieves all education organization identifiers.</param> /// <param name="synchronousInitialization">Indicates whether the cache should wait until all the Person identifiers are loaded before responding, or if using the value mappers initially to avoid an initial delay is preferable.</param> public EducationOrganizationCache( ICacheProvider cacheProvider, IEdFiOdsInstanceIdentificationProvider edFiOdsInstanceIdentificationProvider, IEducationOrganizationIdentifiersValueMapper educationOrganizationIdentifiersValueMapper, IEducationOrganizationCacheDataProvider educationOrganizationIdentifiersProvider, bool synchronousInitialization) { _cacheProvider = cacheProvider; _edFiOdsInstanceIdentificationProvider = edFiOdsInstanceIdentificationProvider; _educationOrganizationIdentifiersValueMapper = educationOrganizationIdentifiersValueMapper; _educationOrganizationIdentifiersProvider = educationOrganizationIdentifiersProvider; _synchronousInitialization = synchronousInitialization; }
protected override void Arrange() { edfiOdsInstanceIdentificationProvider = Stub <IEdFiOdsInstanceIdentificationProvider>(); edOrgValueMapper = Stub <IEducationOrganizationIdentifiersValueMapper>(); educationOrganizationIdentifiersProvider = Stub <IEducationOrganizationCacheDataProvider>(); A.CallTo(() => educationOrganizationIdentifiersProvider.GetAllEducationOrganizationIdentifiers()) .WithAnyArguments() .Returns( Task.Run( () => (IEnumerable <EducationOrganizationIdentifiers>) new EducationOrganizationIdentifiers[0])); edOrgValueMapper = Stub <IEducationOrganizationIdentifiersValueMapper>(); A.CallTo(() => edOrgValueMapper.GetEducationOrganizationIdentifiers(default(int))) .WithAnyArguments() .Returns(EducationOrganizationIdentifiers.CreateLookupInstance(default(int))); }
protected override void Arrange() { edfiOdsInstanceIdentificationProvider = Stub <IEdFiOdsInstanceIdentificationProvider>(); edOrgValueMapper = Stub <IEducationOrganizationIdentifiersValueMapper>(); educationOrganizationIdentifiersProvider = Stub <IEducationOrganizationCacheDataProvider>(); // edorg value mapper suppliedEdOrgValueMap = new EducationOrganizationIdentifiers( educationOrganizationId: 123456, educationOrganizationType: "District", stateEducationAgencyId: 1, educationServiceCenterId: 330950, localEducationAgencyId: 123456); A.CallTo(() => edOrgValueMapper.GetEducationOrganizationIdentifiers(default(int))) .WithAnyArguments() .Returns(suppliedEdOrgValueMap); // edorg identifiers provider suppliedEducationOrganizationIdentifiers = new EducationOrganizationIdentifiers( educationOrganizationId: 123456, educationOrganizationType: "District", stateEducationAgencyId: 1, educationServiceCenterId: 330950, localEducationAgencyId: 8675309); A.CallTo(() => educationOrganizationIdentifiersProvider.GetAllEducationOrganizationIdentifiers()) .WithAnyArguments() .Returns( Task.Run( () => { System.Threading.Thread.Sleep(10); return((IEnumerable <EducationOrganizationIdentifiers>) new[] { suppliedEducationOrganizationIdentifiers }); })); }
protected override void Arrange() { edfiOdsInstanceIdentificationProvider = Stub <IEdFiOdsInstanceIdentificationProvider>(); edOrgValueMapper = Stub <IEducationOrganizationIdentifiersValueMapper>(); educationOrganizationIdentifiersProvider = Stub <IEducationOrganizationCacheDataProvider>(); educationOrganizationIdentifiersProvider.Stub(x => x.GetAllEducationOrganizationIdentifiers()) .IgnoreArguments() .Return( Task.Run( () => (IEnumerable <EducationOrganizationIdentifiers>) new EducationOrganizationIdentifiers[0])); edOrgValueMapper = mocks.StrictMock <IEducationOrganizationIdentifiersValueMapper>(); SetupResult.For(edOrgValueMapper.GetEducationOrganizationIdentifiers(default(int))) .IgnoreArguments() .Return(EducationOrganizationIdentifiers.CreateLookupInstance(default(int))); }
protected override void Arrange() { edfiOdsInstanceIdentificationProvider = Stub <IEdFiOdsInstanceIdentificationProvider>(); edOrgValueMapper = Stub <IEducationOrganizationIdentifiersValueMapper>(); educationOrganizationIdentifiersProvider = Stub <IEducationOrganizationCacheDataProvider>(); // edorg value mapper suppliedEdOrgValueMap = new EducationOrganizationIdentifiers( educationOrganizationId: 123456, educationOrganizationType: "District", stateEducationAgencyId: 1, educationServiceCenterId: 330950, localEducationAgencyId: 123456); edOrgValueMapper.Stub(x => x.GetEducationOrganizationIdentifiers(default(int))) .IgnoreArguments() .Return(suppliedEdOrgValueMap); // edorg identifiers provider suppliedEducationOrganizationIdentifiers = new EducationOrganizationIdentifiers( educationOrganizationId: 123456, educationOrganizationType: "District", stateEducationAgencyId: 1, educationServiceCenterId: 330950, localEducationAgencyId: 8675309); var memoryCacheProvider = new MemoryCacheProvider { MemoryCache = new MemoryCache("IsolatedForUnitTest") }; var educationOrganizationCache = new EducationOrganizationCache( memoryCacheProvider, edfiOdsInstanceIdentificationProvider, edOrgValueMapper, educationOrganizationIdentifiersProvider, synchronousInitialization: false); var listLock = new object(); for (var i = 0; i < TaskCount; i++) { _tasks.Add( new Task( () => { var educationOrganizationIdentifiers = educationOrganizationCache.GetEducationOrganizationIdentifiers( suppliedEducationOrganizationIdentifiers.EducationOrganizationId); lock (listLock) { actualEducationOrganizationIdentifiers.Add(educationOrganizationIdentifiers); } })); } educationOrganizationIdentifiersProvider.Stub(x => x.GetAllEducationOrganizationIdentifiers()) .IgnoreArguments() .Return( Task.Run( () => { Task.WaitAll(_tasks.ToArray()); return((IEnumerable <EducationOrganizationIdentifiers>) new[] { suppliedEducationOrganizationIdentifiers }); })); }