Ejemplo n.º 1
0
        private void Add(ProfileColumn column)
        {
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }

            if (NameMatches(column.PropertyName))
            {
                throw ArtifactListExceptionHelper.DuplicateColumnException(column.PropertyName);
            }

            if (_columns.Count >= _maxCapacity)
            {
                throw ArtifactListExceptionHelper.ColumnCapacityExceededException(column.PropertyName, _maxCapacity);
            }

            _columns.Add(column);
        }
Ejemplo n.º 2
0
        public void Construction_OverCapacity_ThrowException()
        {
            // Arrange
            const int maxCapacity = 2;
            var       column      = new ProfileColumn("Test3", PropertyTypePredefined.CustomGroup, PropertyPrimitiveType.Text);

            _columns.Add(column);

            // Act
            try
            {
                new ProfileColumns(_columns, maxCapacity);
            }
            catch (BadRequestException ex)
            {
                // Assert
                var expectedException = ArtifactListExceptionHelper.ColumnCapacityExceededException(column.PropertyName, maxCapacity);
                Assert.AreEqual(expectedException.ErrorCode, ex.ErrorCode);
                Assert.AreEqual(expectedException.Message, ex.Message);
                return;
            }

            Assert.Fail("BadRequestException was expected.");
        }