示例#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)));
        }