Beispiel #1
0
            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);
            }
Beispiel #2
0
            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)));
            }
Beispiel #3
0
            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
                    });
                }));
            }