コード例 #1
0
        public void ValidateProducerName_WithIncorrectProducerName_ReturnsError()
        {
            // Arrange
            var builder = new EeeValidatorBuilder();

            builder.Year = 2016;

            var producerSubmission = A.Fake <ProducerSubmission>();

            A.CallTo(() => producerSubmission.OrganisationName)
            .Returns("ProducerName123");

            var registeredProducer = A.Fake <RegisteredProducer>();

            A.CallTo(() => registeredProducer.CurrentSubmission)
            .Returns(producerSubmission);

            // Act
            var error = builder.Build().ValidateProducerName(registeredProducer, "PRN1234", "IncorrectProducerName");

            // Assert
            Assert.NotNull(error);
            Assert.Equal(ErrorLevel.Error, error.ErrorLevel);
            Assert.Contains("does not match the registered producer name of", error.Description);
            Assert.Contains("ProducerName123", error.Description);
            Assert.Contains("IncorrectProducerName", error.Description);
            Assert.Contains("PRN1234", error.Description);
            Assert.Contains("2016", error.Description);
        }
コード例 #2
0
        public void ValidateProducerObligationType_WithIncorrectObligationType_ReturnsError(ObligationType registeredObligationType, ObligationType eeeObligationType)
        {
            // Arrange
            var builder = new EeeValidatorBuilder();

            var producerSubmission = A.Fake <ProducerSubmission>();

            A.CallTo(() => producerSubmission.ObligationType)
            .Returns(registeredObligationType);

            var registeredProducer = A.Fake <RegisteredProducer>();

            A.CallTo(() => registeredProducer.CurrentSubmission)
            .Returns(producerSubmission);

            // Act
            var error = builder.Build().ValidateProducerObligationType(registeredProducer, "PRN1234", "TestProducerName", eeeObligationType);

            // Assert
            Assert.NotNull(error);
            Assert.Equal(ErrorLevel.Error, error.ErrorLevel);
            Assert.Contains("for one or more categories but is only registered for", error.Description);
            Assert.Contains("PRN1234", error.Description);
            Assert.Contains("TestProducerName", error.Description);
            Assert.Contains(eeeObligationType.ToString(), error.Description);
            Assert.Contains(registeredObligationType.ToString(), error.Description);
        }
コード例 #3
0
        public void ValidateProducerObligationType_WithCorrectObligationType_DoesNotReturnError(ObligationType registeredObligationType, ObligationType eeeObligationType)
        {
            // Arrange
            var builder = new EeeValidatorBuilder();

            var producerSubmission = A.Fake <ProducerSubmission>();

            A.CallTo(() => producerSubmission.ObligationType)
            .Returns(registeredObligationType);

            var registeredProducer = A.Fake <RegisteredProducer>();

            A.CallTo(() => registeredProducer.CurrentSubmission)
            .Returns(producerSubmission);

            // Act
            var error = builder.Build().ValidateProducerObligationType(registeredProducer, A.Dummy <string>(), A.Dummy <string>(), eeeObligationType);

            // Assert
            Assert.Null(error);
        }
コード例 #4
0
        public void ValidateProducerName_WithProducerNamesDifferentCase_DoesNotReturnError()
        {
            // Arrange
            var builder = new EeeValidatorBuilder();

            builder.Year = 2016;

            var producerSubmission = A.Fake <ProducerSubmission>();

            A.CallTo(() => producerSubmission.OrganisationName)
            .Returns("producer name aaa");

            var registeredProducer = A.Fake <RegisteredProducer>();

            A.CallTo(() => registeredProducer.CurrentSubmission)
            .Returns(producerSubmission);

            // Act
            var error = builder.Build().ValidateProducerName(registeredProducer, A.Dummy <string>(), "Producer NamE AAA");

            // Assert
            Assert.Null(error);
        }
コード例 #5
0
        public void ValidateProducerObligationType_WithCorrectObligationType_DoesNotReturnError(ObligationType registeredObligationType, ObligationType eeeObligationType)
        {
            // Arrange
            var builder = new EeeValidatorBuilder();

            var producerSubmission = A.Fake<ProducerSubmission>();
            A.CallTo(() => producerSubmission.ObligationType)
                .Returns(registeredObligationType);

            var registeredProducer = A.Fake<RegisteredProducer>();
            A.CallTo(() => registeredProducer.CurrentSubmission)
                .Returns(producerSubmission);

            // Act
            var error = builder.Build().ValidateProducerObligationType(registeredProducer, A.Dummy<string>(), A.Dummy<string>(), eeeObligationType);

            // Assert
            Assert.Null(error);
        }
コード例 #6
0
        public void ValidateProducerObligationType_WithIncorrectObligationType_ReturnsError(ObligationType registeredObligationType, ObligationType eeeObligationType)
        {
            // Arrange
            var builder = new EeeValidatorBuilder();

            var producerSubmission = A.Fake<ProducerSubmission>();
            A.CallTo(() => producerSubmission.ObligationType)
                .Returns(registeredObligationType);

            var registeredProducer = A.Fake<RegisteredProducer>();
            A.CallTo(() => registeredProducer.CurrentSubmission)
                .Returns(producerSubmission);

            // Act
            var error = builder.Build().ValidateProducerObligationType(registeredProducer, "PRN1234", "TestProducerName", eeeObligationType);

            // Assert
            Assert.NotNull(error);
            Assert.Equal(ErrorLevel.Error, error.ErrorLevel);
            Assert.Contains("for one or more categories but is only registered for", error.Description);
            Assert.Contains("PRN1234", error.Description);
            Assert.Contains("TestProducerName", error.Description);
            Assert.Contains(eeeObligationType.ToString(), error.Description);
            Assert.Contains(registeredObligationType.ToString(), error.Description);
        }
コード例 #7
0
        public void ValidateProducerName_WithProducerNamesDifferentCase_DoesNotReturnError()
        {
            // Arrange
            var builder = new EeeValidatorBuilder();
            builder.Year = 2016;

            var producerSubmission = A.Fake<ProducerSubmission>();
            A.CallTo(() => producerSubmission.OrganisationName)
                .Returns("producer name aaa");

            var registeredProducer = A.Fake<RegisteredProducer>();
            A.CallTo(() => registeredProducer.CurrentSubmission)
                .Returns(producerSubmission);

            // Act
            var error = builder.Build().ValidateProducerName(registeredProducer, A.Dummy<string>(), "Producer NamE AAA");

            // Assert
            Assert.Null(error);
        }
コード例 #8
0
        public void ValidateProducerName_WithIncorrectProducerName_ReturnsError()
        {
            // Arrange
            var builder = new EeeValidatorBuilder();
            builder.Year = 2016;

            var producerSubmission = A.Fake<ProducerSubmission>();
            A.CallTo(() => producerSubmission.OrganisationName)
                .Returns("ProducerName123");

            var registeredProducer = A.Fake<RegisteredProducer>();
            A.CallTo(() => registeredProducer.CurrentSubmission)
                .Returns(producerSubmission);

            // Act
            var error = builder.Build().ValidateProducerName(registeredProducer, "PRN1234", "IncorrectProducerName");

            // Assert
            Assert.NotNull(error);
            Assert.Equal(ErrorLevel.Error, error.ErrorLevel);
            Assert.Contains("does not match the registered producer name of", error.Description);
            Assert.Contains("ProducerName123", error.Description);
            Assert.Contains("IncorrectProducerName", error.Description);
            Assert.Contains("PRN1234", error.Description);
            Assert.Contains("2016", error.Description);
        }