public async Task QueryPublishedFundingCountBuildsQueryAndTreatsResultsAsScalarCountJObject() { IEnumerable <string> fundingStreamIds = EnumerableFor(NewRandomString(), NewRandomString()); IEnumerable <string> fundingPeriodIds = EnumerableFor(NewRandomString(), NewRandomString(), NewRandomString()); IEnumerable <string> groupingReasons = EnumerableFor(NewRandomString()); IEnumerable <string> variationReasons = EnumerableFor(NewRandomString()); CosmosDbQuery query = new CosmosDbQuery(); GivenTheCosmosDbCountQuery(fundingStreamIds, fundingPeriodIds, groupingReasons, variationReasons, query); int expectedCount = new RandomNumberBetween(1, 10000); IEnumerable <dynamic> results = new dynamic[] { expectedCount }; AndTheDynamicResultsForTheQuery(query, results); int actualCount = await _repository.QueryPublishedFundingCount(fundingStreamIds, fundingPeriodIds, groupingReasons, variationReasons); actualCount .Should() .Be(expectedCount); }
public async Task ProfilesBatchesFromSuppliedContext() { BatchProfilingRequestModel requestOne = NewBatchProfilingRequestModel(); BatchProfilingRequestModel requestTwo = NewBatchProfilingRequestModel(); BatchProfilingRequestModel requestThree = NewBatchProfilingRequestModel(); BatchProfilingResponseModel responseOne = NewBatchProfilingResponseModel(); BatchProfilingResponseModel responseTwo = NewBatchProfilingResponseModel(); BatchProfilingResponseModel responseThree = NewBatchProfilingResponseModel(); BatchProfilingResponseModel responseFour = NewBatchProfilingResponseModel(); BatchProfilingResponseModel responseFive = NewBatchProfilingResponseModel(); BatchProfilingResponseModel responseSix = NewBatchProfilingResponseModel(); int batchSize = new RandomNumberBetween(1, int.MaxValue); GivenThePagesOfRequests(requestOne, requestTwo, requestThree); AndTheBatchSize(batchSize); AndTheProfilingResponses(requestOne, responseOne, responseTwo); AndTheProfilingResponses(requestTwo, responseThree); AndTheProfilingResponses(requestThree, responseFour, responseFive, responseSix); await WhenTheBatchesAreProfiled(); ThenTheContextItemsWereInitialisedWithABatchSize(batchSize); AndTheResponseWereReconciled(responseOne, responseTwo, responseThree, responseFour, responseFive, responseSix); }
public async Task ExecutesVariationStrategiesSpecifiedInSuppliedFundingVariationsAndReturnsVariationResult( FundingVariation[] fundingVariations) { IEnumerable <ProfileVariationPointer> variationPointers = ArraySegment <ProfileVariationPointer> .Empty; PublishedProvider existingPublishedProvider = NewPublishedProvider(); Provider updatedProvider = NewApiProvider(); decimal updatedTotalFunding = new RandomNumberBetween(0, 1000); IDictionary <string, PublishedProviderSnapShots> allPublishedProviderSnapShots = new Dictionary <string, PublishedProviderSnapShots>(); IDictionary <string, PublishedProvider> allPublishedProviderRefreshStates = new Dictionary <string, PublishedProvider>(); string providerVersionId = NewRandomString(); ProviderVariationContext providerVariationContext = await _factory.CreateRequiredVariationChanges(existingPublishedProvider, updatedTotalFunding, updatedProvider, fundingVariations, allPublishedProviderSnapShots, allPublishedProviderRefreshStates, variationPointers, providerVersionId); providerVariationContext .UpdatedTotalFunding .Should() .Be(updatedTotalFunding); providerVariationContext .ReleasedState .Should() .BeSameAs(existingPublishedProvider.Released); providerVariationContext .UpdatedProvider .Should() .BeSameAs(updatedProvider); providerVariationContext .ProviderVersionId .Should() .BeSameAs(providerVersionId); Received.InOrder(() => { foreach (FundingVariation fundingVariation in fundingVariations.OrderBy(_ => _.Order)) { _variationStrategyServiceLocator.GetService(fundingVariation.Name); _variationStrategy.DetermineVariations(Arg.Is <ProviderVariationContext>( ctx => ctx.UpdatedTotalFunding == updatedTotalFunding && ReferenceEquals(ctx.ReleasedState, existingPublishedProvider.Released) && ctx.ProviderId == existingPublishedProvider.Current.ProviderId && ReferenceEquals(ctx.UpdatedProvider, updatedProvider) && ReferenceEquals(ctx.AllPublishedProviderSnapShots, allPublishedProviderSnapShots) && ReferenceEquals(ctx.AllPublishedProvidersRefreshStates, allPublishedProviderRefreshStates) && ctx.ProviderVersionId == providerVersionId), fundingVariation.FundingLineCodes); } }); }
private IEnumerable <string> NewRandomStrings() { int count = new RandomNumberBetween(1, 3); for (int id = 0; id < count; id++) { yield return(NewRandomString()); } }
public void EachFundingLineFunctionRoundsTheSumToTheSuppliedDecimalPlaces() { int decimalPlaces = new RandomNumberBetween(2, 99); string psg = "PSG"; string expectedFundingLineLambda = @$ "Dim userCalculationCodeImplementation As Func(Of Decimal?) = Function() As Decimal? Dim sum As Decimal? = Nothing AddToNullable(sum, Template.CalcOne()) Return If(sum.HasValue(), Math.Round(sum.Value, {decimalPlaces}, MidpointRounding.AwayFromZero), sum)
public void ReturnsSingleMatchingTransformForJobType() { int supportedTransform = new RandomNumberBetween(0, 2); GeneratePublishingCsvJobsCreationAction action = new RandomEnum <GeneratePublishingCsvJobsCreationAction>(); GivenTheTransformSupportsTheJobType(action, supportedTransform); _serviceLocator.GetService(action) .Should() .BeSameAs(_transforms[supportedTransform].Object); }
public void ReturnsSingleMatchingTransformForJobType() { int supportedTransform = new RandomNumberBetween(0, 2); FundingLineCsvGeneratorJobType jobType = new RandomEnum <FundingLineCsvGeneratorJobType>(); GivenTheTransformSupportsTheJobType(jobType, supportedTransform); _serviceLocator.GetService(jobType) .Should() .BeSameAs(_batchProcessors[supportedTransform].Object); }
private ProviderVariationContext NewVariationContext(Action <ProviderVariationContextBuilder> setUp = null) { decimal totalFunding = new RandomNumberBetween(100, 100000); ProviderVariationContextBuilder variationContextBuilder = new ProviderVariationContextBuilder() .WithPublishedProvider(NewPublishedProvider(_ => _.WithReleased(NewPublishedProviderVersion(ppv => ppv.WithTotalFunding(totalFunding))))) .WithCurrentState(NewProvider(_ => _.WithStatus(Variation.Closed))) .WithUpdatedTotalFunding(totalFunding); setUp?.Invoke(variationContextBuilder); return(variationContextBuilder.Build()); }