コード例 #1
0
        public async Task Evaluate_ProducerObligationTypeChange_WithConflictDueToExistingEeeData_ReturnsExistingUniqueEeeDataObligationInErrorMessage
            (ObligationType existingProducerEeeDataObligationType, ObligationType existingProducerObligationType, ObligationType newProducerObligationType)
        {
            // Arrange
            var builder = new ProducerObligationTypeChangeBuilder();

            var existingProducerDetails = A.Fake<ProducerSubmission>();
            A.CallTo(() => existingProducerDetails.ObligationType)
                .Returns(existingProducerObligationType);

            A.CallTo(() => builder.ProducerQuerySet.GetLatestProducerForComplianceYearAndScheme(A<string>._, A<string>._, A<Guid>._))
                .Returns(existingProducerDetails);

            var eeeOutputAmount = A.Fake<EeeOutputAmount>();
            A.CallTo(() => eeeOutputAmount.ObligationType)
                .Returns(existingProducerEeeDataObligationType);

            A.CallTo(() => builder.SchemeEeeDataQuerySet.GetLatestProducerEeeData(A<string>._))
                .Returns(new List<EeeOutputAmount> { eeeOutputAmount });

            var newProducerDetails = new producerType
            {
                status = statusType.A,
                obligationType = newProducerObligationType.ToDeserializedXmlObligationType()
            };

            // Act
            var result = await builder.Build().Evaluate(newProducerDetails);

            // Assert
            A.CallTo(() => builder.ProducerQuerySet.GetLatestProducerForComplianceYearAndScheme(A<string>._, A<string>._, A<Guid>._))
                .MustHaveHappened();

            A.CallTo(() => builder.SchemeEeeDataQuerySet.GetLatestProducerEeeData(A<string>._))
                .MustHaveHappened();

            Assert.False(result.IsValid);
            Assert.Equal(ErrorLevel.Error, result.ErrorLevel);
            Assert.Contains(string.Format("because {0} EEE data has already been submitted", existingProducerEeeDataObligationType), result.Message);
        }
コード例 #2
0
        public async Task Evaluate_ProducerObligationTypeChange_NoConflictWithExistingEeeData_ReturnsWarning
            (ObligationType existingProducerEeeDataObligationType, ObligationType existingProducerObligationType, ObligationType newProducerObligationType)
        {
            // Arrange
            var builder = new ProducerObligationTypeChangeBuilder();

            var existingProducerDetails = A.Fake<ProducerSubmission>();
            A.CallTo(() => existingProducerDetails.ObligationType)
                .Returns(existingProducerObligationType);

            A.CallTo(() => builder.ProducerQuerySet.GetLatestProducerForComplianceYearAndScheme(A<string>._, A<string>._, A<Guid>._))
                .Returns(existingProducerDetails);

            var eeeOutputAmount = A.Fake<EeeOutputAmount>();
            A.CallTo(() => eeeOutputAmount.ObligationType)
                .Returns(existingProducerEeeDataObligationType);

            A.CallTo(() => builder.SchemeEeeDataQuerySet.GetLatestProducerEeeData(A<string>._))
                .Returns(new List<EeeOutputAmount> { eeeOutputAmount });

            var newProducerDetails = new producerType
            {
                status = statusType.A,
                obligationType = newProducerObligationType.ToDeserializedXmlObligationType()
            };

            // Act
            var result = await builder.Build().Evaluate(newProducerDetails);

            // Assert
            A.CallTo(() => builder.ProducerQuerySet.GetLatestProducerForComplianceYearAndScheme(A<string>._, A<string>._, A<Guid>._))
                .MustHaveHappened();

            A.CallTo(() => builder.SchemeEeeDataQuerySet.GetLatestProducerEeeData(A<string>._))
                .MustHaveHappened();

            Assert.False(result.IsValid);
            Assert.Equal(ErrorLevel.Warning, result.ErrorLevel);
        }