Exemple #1
0
        public async Task GetLatestEarlierPublishedFundingVersionFromVersion()
        {
            PublishedFundingVersion document = await _repository.GetLatestEarlierPublishedFundingVersionFromVersion("DSG",
                                                                                                                    "FY-2021",
                                                                                                                    4M,
                                                                                                                    "LACode",
                                                                                                                    "213",
                                                                                                                    ModelGroupingReason.Information);

            document?
            .MajorVersion
            .Should()
            .Be(3);
        }
        public async Task GetLatestEarlierPublishedFundingVersionFromVersion()
        {
            string  fundingStreamId             = NewRandomString();
            string  fundingPeriodId             = NewRandomString();
            decimal version                     = NewRandomInteger();
            string  groupTypeIdentifier         = NewRandomString();
            string  groupTypeIdentifierValue    = NewRandomString();
            ModelsGroupingReason groupingReason = NewRandomGroupingReason();

            PublishedFundingVersion expectedLatestEarlierDocument = NewPublishedFundingVersion();

            GivenTheLatestEarlierDocument(@"SELECT
                              TOP 1 *
                        FROM publishedFundingVersion p
                        WHERE p.documentType = 'PublishedFundingVersion'
                        AND StringToNumber(CONCAT(Tostring(p.content.majorVersion), '.', Tostring(p.content.minorVersion))) < @version
                        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.content.majorVersion DESC, p.content.minorVersion DESC",
                                          expectedLatestEarlierDocument,
                                          ("@fundingPeriodId", fundingPeriodId),
                                          ("@fundingStreamId", fundingStreamId),
                                          ("@version", version),
                                          ("@groupTypeIdentifier", groupTypeIdentifier),
                                          ("@groupTypeIdentifierValue", groupTypeIdentifierValue),
                                          ("@groupingReason", groupingReason.ToString()));

            PublishedFundingVersion actualLatestEarlierDocument = await _repository.GetLatestEarlierPublishedFundingVersionFromVersion(fundingStreamId,
                                                                                                                                       fundingPeriodId,
                                                                                                                                       version,
                                                                                                                                       groupTypeIdentifier,
                                                                                                                                       groupTypeIdentifierValue,
                                                                                                                                       groupingReason);

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