public async Task GetLatestEarlierPublishedProviderVersionFromVersion()
        {
            string  fundingStreamId = NewRandomString();
            string  fundingPeriodId = NewRandomString();
            decimal version         = NewRandomInteger();
            string  providerId      = NewRandomString();

            PublishedProviderVersion expectedLatestEarlierDocument = NewPublishedProviderVersion();

            GivenTheLatestEarlierDocument(@$ "SELECT
                              TOP 1 *
                        FROM publishedProviderVersion p
                        WHERE p.documentType = 'PublishedProviderVersion'
                        AND StringToNumber(CONCAT(Tostring(p.content.majorVersion), '.', Tostring(p.content.minorVersion))) < @version
                        AND p.content.fundingStreamId = @fundingStreamId
                        AND p.content.fundingPeriodId = @fundingPeriodId
                        AND p.content.providerId = @providerId
                        {string.Empty}
                        AND p.deleted = false
                        ORDER BY p.content.majorVersion DESC, p.content.minorVersion DESC",
                                          expectedLatestEarlierDocument,
                                          ("@fundingPeriodId", fundingPeriodId),
                                          ("@fundingStreamId", fundingStreamId),
                                          ("@version", version),
                                          ("@providerId", providerId));

            PublishedProviderVersion actualLatestEarlierDocument = await _repository.GetLatestEarlierPublishedProviderVersionFromVersion(fundingStreamId,
                                                                                                                                         fundingPeriodId,
                                                                                                                                         version,
                                                                                                                                         providerId);

            actualLatestEarlierDocument
            .Should()
            .BeSameAs(expectedLatestEarlierDocument);
        }
        public async Task GetLatestEarlierPublishedProviderVersion()
        {
            string fundingStreamId = NewRandomString();
            string fundingPeriodId = NewRandomString();
            long   timeStamp       = NewRandomTimeStamp();
            string providerId      = NewRandomString();

            PublishedProviderVersion expectedLatestEarlierDocument = NewPublishedProviderVersion();

            GivenTheLatestEarlierDocument(@$ "SELECT
                              TOP 1 *
                        FROM publishedProviderVersion p
                        WHERE p.documentType = 'PublishedProviderVersion'
                        AND p._ts < @sinceTimeStamp
                        AND p.content.fundingStreamId = @fundingStreamId
                        AND p.content.fundingPeriodId = @fundingPeriodId
                        AND p.content.providerId = @providerId
                        {string.Empty}
                        AND p.deleted = false
                        ORDER BY p._ts DESC",
                                          expectedLatestEarlierDocument,
                                          ("@fundingPeriodId", fundingPeriodId),
                                          ("@fundingStreamId", fundingStreamId),
                                          ("@sinceTimeStamp", timeStamp),
                                          ("@providerId", providerId));

            PublishedProviderVersion actualLatestEarlierDocument = await _repository.GetLatestEarlierPublishedProviderVersion(fundingStreamId,
                                                                                                                              fundingPeriodId,
                                                                                                                              timeStamp,
                                                                                                                              providerId);

            actualLatestEarlierDocument
            .Should()
            .BeSameAs(expectedLatestEarlierDocument);
        }