public async Task GetLatestEarlierPublishedFundingVersion() { PublishedFundingVersion document = await _repository.GetLatestEarlierPublishedFundingVersion("DSG", "FY-2021", 1584980585, //timestamp is for version 3 so test should find me version 2 "LACode", "213", ModelGroupingReason.Information); document? .MajorVersion .Should() .Be(2); }
public async Task GetLatestEarlierPublishedFundingVersion() { string fundingStreamId = NewRandomString(); string fundingPeriodId = NewRandomString(); long timeStamp = NewRandomTimeStamp(); string groupTypeIdentifier = NewRandomString(); string groupTypeIdentifierValue = NewRandomString(); ModelsGroupingReason groupingReason = NewRandomGroupingReason(); PublishedFundingVersion expectedLatestEarlierDocument = NewPublishedFundingVersion(); GivenTheLatestEarlierDocument(@"SELECT TOP 1 * FROM publishedFundingVersion p WHERE p.documentType = 'PublishedFundingVersion' AND p._ts < @sinceTimeStamp AND p.content.fundingStreamId = @fundingStreamId AND p.content.fundingPeriod.id = @fundingPeriodId AND p.content.organisationGroupTypeIdentifier = @groupTypeIdentifier AND p.content.organisationGroupIdentifierValue = @groupTypeIdentifierValue AND p.content.groupingReason = @groupingReason AND p.deleted = false ORDER BY p._ts DESC", expectedLatestEarlierDocument, ("@fundingPeriodId", fundingPeriodId), ("@fundingStreamId", fundingStreamId), ("@sinceTimeStamp", timeStamp), ("@groupTypeIdentifier", groupTypeIdentifier), ("@groupTypeIdentifierValue", groupTypeIdentifierValue), ("@groupingReason", groupingReason.ToString())); PublishedFundingVersion actualLatestEarlierDocument = await _repository.GetLatestEarlierPublishedFundingVersion(fundingStreamId, fundingPeriodId, timeStamp, groupTypeIdentifier, groupTypeIdentifierValue, groupingReason); actualLatestEarlierDocument .Should() .BeSameAs(expectedLatestEarlierDocument); }