Пример #1
0
        public void WithInnerException_WhenInnerExceptionIsNotNull_ReturnsIntranetExceptionBuilder()
        {
            IIntranetExceptionBuilder sut = CreateSut();

            IIntranetExceptionBuilder result = sut.WithInnerException(_fixture.Create <Exception>());

            Assert.That(result, Is.EqualTo(sut));
        }
Пример #2
0
        public void WithMethodBase_WhenMethodBaseIsNull_ThrowsArgumentNullException()
        {
            IIntranetExceptionBuilder sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.WithMethodBase(null));

            Assert.That(result.ParamName, Is.EqualTo("methodBase"));
        }
Пример #3
0
        public void WithInnerException_WhenInnerExceptionIsNull_ThrowsArgumentNullException()
        {
            IIntranetExceptionBuilder sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.WithInnerException(null));

            Assert.That(result.ParamName, Is.EqualTo("innerException"));
        }
        public void WithValidatingType_WhenValidatingTypeIsNotNull_ReturnsIntranetExceptionBuilder()
        {
            IIntranetExceptionBuilder sut = CreateSut();

            IIntranetExceptionBuilder result = sut.WithValidatingType(typeof(WithValidatingTypeTests));

            Assert.That(result, Is.EqualTo(sut));
        }
        public void WithValidatingType_WhenValidatingTypeIsNull_ThrowsArgumentNullException()
        {
            IIntranetExceptionBuilder sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.WithValidatingType(null));

            Assert.That(result.ParamName, Is.EqualTo("validatingType"));
        }
Пример #6
0
        public void WithMethodBase_WhenMethodBaseIsNotNull_ReturnsIntranetExceptionBuilder()
        {
            IIntranetExceptionBuilder sut = CreateSut();

            IIntranetExceptionBuilder result = sut.WithMethodBase(MethodBase.GetCurrentMethod());

            Assert.That(result, Is.EqualTo(sut));
        }
Пример #7
0
        public void Build_WhenCalledForIntranetQueryBusExceptionWithoutInnerException_AssertInnerExceptionIsNull()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.NoQueryHandlerSupportingQuery, _fixture.Create <string>(), _fixture.Create <string>());

            IntranetExceptionBase result = sut.Build();

            Assert.That(result.InnerException, Is.Null);
        }
Пример #8
0
        public void Build_WhenCalledForIntranetRepositoryExceptionWithoutMethodBase_AssertMethodBaseIsNull()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.RepositoryError, _fixture.Create <string>(), _fixture.Create <string>());

            IntranetRepositoryException result = (IntranetRepositoryException)sut.Build();

            Assert.That(result.MethodBase, Is.Null);
        }
Пример #9
0
        public void Build_WhenCalledForIntranetSystemException_ReturnsIntranetSystemException()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.ObjectIsNull, _fixture.Create <string>());

            IntranetExceptionBase result = sut.Build();

            Assert.That(result, Is.TypeOf <IntranetSystemException>());
        }
Пример #10
0
        public void Build_WhenCalledForIntranetRepositoryException_ReturnsIntranetRepositoryException()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.RepositoryError, _fixture.Create <string>(), _fixture.Create <string>());

            IntranetExceptionBase result = sut.Build();

            Assert.That(result, Is.TypeOf <IntranetRepositoryException>());
        }
        public void WithValidatingType_WhenValidatingFieldIsNotNullEmptyOrWhiteSpace_ReturnsIntranetExceptionBuilder()
        {
            IIntranetExceptionBuilder sut = CreateSut();

            IIntranetExceptionBuilder result = sut.WithValidatingField(_fixture.Create <string>());

            Assert.That(result, Is.EqualTo(sut));
        }
Пример #12
0
        public void Build_WhenCalledForIntranetQueryBusException_ReturnsIntranetQueryBusException()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.NoQueryHandlerSupportingQuery, _fixture.Create <string>(), _fixture.Create <string>());

            IntranetExceptionBase result = sut.Build();

            Assert.That(result, Is.TypeOf <IntranetQueryBusException>());
        }
Пример #13
0
        public void Build_WhenCalledForIntranetValidationExceptionWithoutValidatingField_AssertValidatingFieldIsNull()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.ValueNotGreaterThanZero, _fixture.Create <string>());

            IntranetValidationException result = (IntranetValidationException)sut.Build();

            Assert.That(result.ValidatingField, Is.Null);
        }
Пример #14
0
        public void Build_WhenCalledForIntranetRepositoryExceptionWithoutInnerException_AssertInnerExceptionIsNull()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.RepositoryError, _fixture.Create <string>(), _fixture.Create <string>());

            IntranetExceptionBase result = sut.Build();

            Assert.That(result.InnerException, Is.Null);
        }
Пример #15
0
        public void Build_WhenCalledForIntranetValidationException_ReturnsIntranetValidationException()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.ValueNotGreaterThanZero, _fixture.Create <string>());

            IntranetExceptionBase result = sut.Build();

            Assert.That(result, Is.TypeOf <IntranetValidationException>());
        }
        public void WithValidatingField_WhenValidatingFieldIsWhiteSpace_ThrowsArgumentNullException()
        {
            IIntranetExceptionBuilder sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.WithValidatingField(" "));

            Assert.That(result.ParamName, Is.EqualTo("validatingField"));
        }
Пример #17
0
        public void Build_WhenCalledForIntranetQueryBusExceptionWithInnerException_AssertInnerExceptionIsCorrect()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.NoQueryHandlerSupportingQuery, _fixture.Create <string>(), _fixture.Create <string>());

            Exception             innerException = _fixture.Create <Exception>();
            IntranetExceptionBase result         = sut.WithInnerException(innerException).Build();

            Assert.That(result.InnerException, Is.EqualTo(innerException));
        }
Пример #18
0
        public void Build_WhenCalledForIntranetRepositoryExceptionWithMethodBase_AssertMethodBaseIsCorrect()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.RepositoryError, _fixture.Create <string>(), _fixture.Create <string>());

            MethodBase methodBase = MethodBase.GetCurrentMethod();
            IntranetRepositoryException result = (IntranetRepositoryException)sut.WithMethodBase(methodBase).Build();

            Assert.That(result.MethodBase, Is.EqualTo(methodBase));
        }
Пример #19
0
        public void Build_WhenCalledForIntranetValidationExceptionWithValidatingField_AssertValidatingFieldIsCorrect()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.ValueNotGreaterThanZero, _fixture.Create <string>());

            string validatingField             = _fixture.Create <string>();
            IntranetValidationException result = (IntranetValidationException)sut.WithValidatingField(validatingField).Build();

            Assert.That(result.ValidatingField, Is.EqualTo(validatingField));
        }
Пример #20
0
        public void Build_WhenCalledForIntranetRepositoryExceptionWithInnerException_AssertInnerExceptionIsCorrect()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.RepositoryError, _fixture.Create <string>(), _fixture.Create <string>());

            Exception             innerException = _fixture.Create <Exception>();
            IntranetExceptionBase result         = sut.WithInnerException(innerException).Build();

            Assert.That(result.InnerException, Is.EqualTo(innerException));
        }
Пример #21
0
        public void Build_WhenCalledForIntranetValidationExceptionWithInnerException_AssertInnerExceptionIsCorrect()
        {
            IIntranetExceptionBuilder sut = CreateSut(ErrorCode.ValueNotGreaterThanZero, _fixture.Create <string>());

            Exception             innerException = _fixture.Create <Exception>();
            IntranetExceptionBase result         = sut.WithInnerException(innerException).Build();

            Assert.That(result.InnerException, Is.EqualTo(innerException));
        }
Пример #22
0
        public void Build_WhenCalledForIntranetValidationException_AssertErrorCodeIsCorrect()
        {
            const ErrorCode errorCode = ErrorCode.ValueNotGreaterThanZero;

            IIntranetExceptionBuilder sut = CreateSut(errorCode, _fixture.Create <string>());

            IntranetExceptionBase result = sut.Build();

            Assert.That(result.ErrorCode, Is.EqualTo(errorCode));
        }
Пример #23
0
        public void Build_WhenCalledForIntranetRepositoryException_AssertErrorCodeIsCorrect()
        {
            const ErrorCode errorCode = ErrorCode.RepositoryError;

            IIntranetExceptionBuilder sut = CreateSut(errorCode, _fixture.Create <string>(), _fixture.Create <string>());

            IntranetExceptionBase result = sut.Build();

            Assert.That(result.ErrorCode, Is.EqualTo(errorCode));
        }
Пример #24
0
        public void Build_WhenCalledForIntranetQueryBusException_AssertErrorCodeIsCorrect()
        {
            const ErrorCode errorCode = ErrorCode.NoQueryHandlerSupportingQuery;

            IIntranetExceptionBuilder sut = CreateSut(errorCode, _fixture.Create <string>(), _fixture.Create <string>());

            IntranetExceptionBase result = sut.Build();

            Assert.That(result.ErrorCode, Is.EqualTo(errorCode));
        }
Пример #25
0
        public void Build_WhenCalledForIntranetSystemException_AssertMessageIsCorrect()
        {
            const ErrorCode errorCode       = ErrorCode.ObjectIsNull;
            string          commandTypeName = _fixture.Create <string>();

            ErrorCodeAttribute errorCodeAttribute = _errorCodeAttributeTestHelper.GetErrorCodeAttribute(errorCode);

            IIntranetExceptionBuilder sut = CreateSut(errorCode, commandTypeName);

            IntranetExceptionBase result = sut.Build();

            Assert.That(result.Message, Is.EqualTo(string.Format(errorCodeAttribute.Message, commandTypeName)));
        }
Пример #26
0
        public void Build_WhenCalledForIntranetCommandBusException_AssertMessageIsCorrect()
        {
            const ErrorCode errorCode       = ErrorCode.NoCommandHandlerSupportingCommandWithoutResultType;
            string          commandTypeName = _fixture.Create <string>();

            ErrorCodeAttribute errorCodeAttribute = _errorCodeAttributeTestHelper.GetErrorCodeAttribute(errorCode);

            IIntranetExceptionBuilder sut = CreateSut(errorCode, commandTypeName);

            IntranetExceptionBase result = sut.Build();

            Assert.That(result.Message, Is.EqualTo(string.Format(errorCodeAttribute.Message, commandTypeName)));
        }
Пример #27
0
        public void Build_WhenCalledForIntranetValidationException_AssertMessageIsCorrect()
        {
            const ErrorCode errorCode       = ErrorCode.ValueNotGreaterThanZero;
            string          validatingField = _fixture.Create <string>();

            ErrorCodeAttribute errorCodeAttribute = _errorCodeAttributeTestHelper.GetErrorCodeAttribute(errorCode);

            IIntranetExceptionBuilder sut = CreateSut(errorCode, validatingField);

            IntranetExceptionBase result = sut.Build();

            Assert.That(result.Message, Is.EqualTo(string.Format(errorCodeAttribute.Message, validatingField)));
        }
Пример #28
0
        public void Build_WhenCalledForIntranetRepositoryException_AssertMessageIsCorrect()
        {
            const ErrorCode errorCode  = ErrorCode.RepositoryError;
            string          methodName = _fixture.Create <string>();
            string          error      = _fixture.Create <string>();

            ErrorCodeAttribute errorCodeAttribute = _errorCodeAttributeTestHelper.GetErrorCodeAttribute(errorCode);

            IIntranetExceptionBuilder sut = CreateSut(errorCode, methodName, error);

            IntranetExceptionBase result = sut.Build();

            Assert.That(result.Message, Is.EqualTo(string.Format(errorCodeAttribute.Message, methodName, error)));
        }