Esempio n. 1
0
        public async Task GetLatestEarlierPublishedProviderVersion()
        {
            PublishedProviderVersion document = await _repository.GetLatestEarlierPublishedProviderVersion("DSG",
                                                                                                           "FY-2021",
                                                                                                           1584355885, //timestamp is v3 so should yield v2
                                                                                                           "10007322");

            document?
            .Version
            .Should()
            .Be(2);
        }
        public async Task GetLatestEarlierPublishedProviderVersionByStatus()
        {
            string fundingStreamId         = NewRandomString();
            string fundingPeriodId         = NewRandomString();
            long   timeStamp               = NewRandomTimeStamp();
            string providerId              = NewRandomString();
            PublishedProviderStatus status = new RandomEnum <PublishedProviderStatus>();

            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
                        AND p.content.status = @status
                        AND p.deleted = false
                        ORDER BY p._ts DESC",
                                          expectedLatestEarlierDocument,
                                          ("@fundingPeriodId", fundingPeriodId),
                                          ("@fundingStreamId", fundingStreamId),
                                          ("@sinceTimeStamp", timeStamp),
                                          ("@providerId", providerId),
                                          ("@status", status));

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

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