Пример #1
0
            public void Should_guard_against_null()
            {
                // Arrange
                IErrorFromExceptionFactory     nullErrorFromExceptionFactory     = null;
                IErrorFromDictionaryFactory    nullErrorFromDictionaryFactory    = null;
                IErrorFromKeyValuePairFactory  nullErrorFromKeyValuePairFactory  = null;
                IErrorFromRawValuesFactory     nullErrorFromRawValuesFactory     = null;
                IErrorFromIdentityErrorFactory nullErrorFromIdentityErrorFactory = null;

                // Act & Assert
                Assert.Throws <ArgumentNullException>(
                    () => new DefaultErrorFactory(
                        nullErrorFromExceptionFactory,
                        _errorFromDictionaryFactoryMock.Object,
                        _errorFromKeyValuePairFactoryMock.Object,
                        _errorFromRawValuesFactoryMock.Object,
                        _errorFromIdentityErrorFactoryMock.Object
                        )
                    );
                Assert.Throws <ArgumentNullException>(
                    () => new DefaultErrorFactory(
                        _errorFromExceptionFactoryMock.Object,
                        nullErrorFromDictionaryFactory,
                        _errorFromKeyValuePairFactoryMock.Object,
                        _errorFromRawValuesFactoryMock.Object,
                        _errorFromIdentityErrorFactoryMock.Object
                        )
                    );
                Assert.Throws <ArgumentNullException>(
                    () => new DefaultErrorFactory(
                        _errorFromExceptionFactoryMock.Object,
                        _errorFromDictionaryFactoryMock.Object,
                        nullErrorFromKeyValuePairFactory,
                        _errorFromRawValuesFactoryMock.Object,
                        _errorFromIdentityErrorFactoryMock.Object
                        )
                    );
                Assert.Throws <ArgumentNullException>(
                    () => new DefaultErrorFactory(
                        _errorFromExceptionFactoryMock.Object,
                        _errorFromDictionaryFactoryMock.Object,
                        _errorFromKeyValuePairFactoryMock.Object,
                        nullErrorFromRawValuesFactory,
                        _errorFromIdentityErrorFactoryMock.Object
                        )
                    );
                Assert.Throws <ArgumentNullException>(
                    () => new DefaultErrorFactory(
                        _errorFromExceptionFactoryMock.Object,
                        _errorFromDictionaryFactoryMock.Object,
                        _errorFromKeyValuePairFactoryMock.Object,
                        _errorFromRawValuesFactoryMock.Object,
                        nullErrorFromIdentityErrorFactory
                        )
                    );
            }
Пример #2
0
 public DefaultErrorFactory(
     IErrorFromExceptionFactory errorFromExceptionFactory,
     IErrorFromDictionaryFactory errorFromDictionaryFactory,
     IErrorFromKeyValuePairFactory errorFromKeyValuePairFactory,
     IErrorFromRawValuesFactory errorFromRawValuesFactory,
     IErrorFromIdentityErrorFactory errorFromIdentityErrorFactory
     )
 {
     _errorFromExceptionFactory     = errorFromExceptionFactory ?? throw new ArgumentNullException(nameof(errorFromExceptionFactory));
     _errorFromDictionaryFactory    = errorFromDictionaryFactory ?? throw new ArgumentNullException(nameof(errorFromDictionaryFactory));
     _errorFromKeyValuePairFactory  = errorFromKeyValuePairFactory ?? throw new ArgumentNullException(nameof(errorFromKeyValuePairFactory));
     _errorFromRawValuesFactory     = errorFromRawValuesFactory ?? throw new ArgumentNullException(nameof(errorFromRawValuesFactory));
     _errorFromIdentityErrorFactory = errorFromIdentityErrorFactory ?? throw new ArgumentNullException(nameof(errorFromIdentityErrorFactory));
 }