Esempio n. 1
0
        public void GetCategoryByNameSucceeds()
        {
            //Arrange
            const string Category1Name = TestsConstants.TestGuidName;
            const string Category2Name = "{351C28A4-2E3C-4C98-82CD-2B6FEEE3A12C}";
            const string Category3Name = "{238C3E82-E8FD-429B-85F7-8052CC1232B1}";
            var          target        = new DiagnosticsCategoryCollection();
            var          expected1     = new DiagnosticsCategory(Category1Name);
            var          expected2     = new DiagnosticsCategory(Category2Name);
            var          expected3     = new DiagnosticsCategory(Category3Name);

            target.Add(expected1);
            target.Add(expected2);
            target.Add(expected3);

            //Act
            DiagnosticsCategory foundCategory1 = target[TestsConstants.TestGuidName];
            DiagnosticsCategory foundCategory2 = target[Category2Name];
            DiagnosticsCategory foundCategory3 = target[Category3Name];

            //Assert
            Assert.AreEqual <DiagnosticsCategory>(expected1, foundCategory1);
            Assert.AreEqual <DiagnosticsCategory>(expected2, foundCategory2);
            Assert.AreEqual <DiagnosticsCategory>(expected3, foundCategory3);
        }
Esempio n. 2
0
        public void ConstructCategoryWithNullListThrowsArgumentNullException()
        {
            //Arrange

            //Act
            var target = new DiagnosticsCategoryCollection(null);

            //Assert caught by exception
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DiagnosticsArea"/> class.
        /// </summary>
        /// <param name="name">The name of the diagnostic area.</param>
        /// <param name="diagnosticsCategories">A collection of <see cref="DiagnosticsCategory"/> that will be part of the area.</param>
        public DiagnosticsArea(string name, DiagnosticsCategoryCollection diagnosticsCategories)
        {
            this.Name = name;

            if (diagnosticsCategories == null)
                this.diagnosticsCategories = new DiagnosticsCategoryCollection();
            else
                this.diagnosticsCategories = new DiagnosticsCategoryCollection(diagnosticsCategories);
        }
Esempio n. 4
0
        public void CreateNameAndValuesConstructorWithNullNameThrowsArgumentNullException()
        {
            //Arrange
            var diagnosticsCategories = new DiagnosticsCategoryCollection();

            //Act
            var area = new DiagnosticsArea(null, diagnosticsCategories);

            // Assert caught by exception
        }
Esempio n. 5
0
        public void ConstructCategoryCollectionSucceeds()
        {
            //Arrange

            //Act
            var target = new DiagnosticsCategoryCollection();

            //Assert
            Assert.IsTrue(target.Count == 0);
        }
Esempio n. 6
0
        public void AddCategoryWithNullCategoryThrowsArgumentNullException()
        {
            //Arrange
            var target = new DiagnosticsCategoryCollection();

            //Act
            target.Add(null);

            //Assert caught by exception.
        }
Esempio n. 7
0
        public void GetMissingCategoryReturnsNullSucceeds()
        {
            //Arrange
            var target = new DiagnosticsCategoryCollection();

            //Act
            DiagnosticsCategory foundCategory = target["test"];

            //Assert
            Assert.IsNull(foundCategory);
        }
Esempio n. 8
0
        public void GetCategoryWithNullKeyThrowsArgumentNullException()
        {
            //Arrange
            var target   = new DiagnosticsCategoryCollection();
            var category = new DiagnosticsCategory(TestsConstants.TestGuidName);

            target.Add(category);

            //Act
            DiagnosticsCategory foundCategory = target[null];

            //Assert caught by exception.
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DiagnosticsArea"/> class.
        /// </summary>
        /// <param name="name">The name of the diagnostic area.</param>
        /// <param name="diagnosticsCategories">A collection of <see cref="DiagnosticsCategory"/> that will be part of the area.</param>
        public DiagnosticsArea(string name, DiagnosticsCategoryCollection diagnosticsCategories)
        {
            this.Name = name;

            if (diagnosticsCategories == null)
            {
                this.diagnosticsCategories = new DiagnosticsCategoryCollection();
            }
            else
            {
                this.diagnosticsCategories = new DiagnosticsCategoryCollection(diagnosticsCategories);
            }
        }
Esempio n. 10
0
        public void AddCategorySucceeds()
        {
            //Arrange
            const string CategoryName = TestsConstants.TestGuidName;
            var          target       = new DiagnosticsCategoryCollection();
            var          expected     = new DiagnosticsCategory(CategoryName);

            //Act
            target.Add(expected);

            //Assert
            Assert.AreEqual <DiagnosticsCategory>(expected, target[0]);
        }
Esempio n. 11
0
        public void SetCategoryWithNullWithStringIndexThrowsInvalidOperationException()
        {
            //Arrange
            const string CategoryName = TestsConstants.TestGuidName;
            var          target       = new DiagnosticsCategoryCollection();
            var          category     = new DiagnosticsCategory(CategoryName);

            target.Add(category);

            //Act
            target[TestsConstants.TestGuidName] = null;

            //Assert caught by exeption.
        }
Esempio n. 12
0
        public void AddDuplicateCategoryThrowsInvalidOperationException()
        {
            //Arrange
            var target      = new DiagnosticsCategoryCollection();
            var category    = new DiagnosticsCategory(TestsConstants.TestGuidName);
            var dupCategory = new DiagnosticsCategory(TestsConstants.TestGuidName);

            target.Add(category);

            //Act
            target.Add(dupCategory);

            //Assert caught by exception.
        }
Esempio n. 13
0
        public void SetWithStringIndexWithNullKeyThrowsArgumentNullException()
        {
            //Arrange
            const string CategoryName = TestsConstants.TestGuidName;
            var          target       = new DiagnosticsCategoryCollection();
            var          category     = new DiagnosticsCategory(CategoryName, EventSeverity.ErrorCritical, TraceSeverity.High);

            target.Add(category);
            DiagnosticsCategory newCategory = new DiagnosticsCategory(TestsConstants.TestGuidName, EventSeverity.Information, TraceSeverity.Medium);

            //Act
            target[null] = newCategory;

            //Assert caught by exception.
        }
Esempio n. 14
0
        public void SetSameCategoryAtSameIndexSucceeds()
        {
            //Arrange
            const string CategoryName = TestsConstants.TestGuidName;
            var          target       = new DiagnosticsCategoryCollection();
            var          category     = new DiagnosticsCategory(CategoryName, EventSeverity.ErrorCritical, TraceSeverity.High);

            target.Add(category);
            DiagnosticsCategory expected = new DiagnosticsCategory(TestsConstants.TestGuidName, EventSeverity.Information, TraceSeverity.Medium);

            //Act
            target[0] = expected;

            //Assert
            Assert.AreEqual <DiagnosticsCategory>(target[0], expected);
        }
Esempio n. 15
0
        public void SetDuplicateCategoryThrowsInvalidOperationException()
        {
            //Arrange
            const string CategoryName = TestsConstants.TestGuidName;
            var          target       = new DiagnosticsCategoryCollection();
            var          category     = new DiagnosticsCategory(CategoryName, EventSeverity.ErrorCritical, TraceSeverity.High);

            target.Add(category);
            DiagnosticsCategory newCategory = new DiagnosticsCategory(TestsConstants.TestGuidName, EventSeverity.Information, TraceSeverity.Medium);

            target.Add(newCategory);

            //Act
            target[0] = newCategory;

            //Assert caught by exception
        }
Esempio n. 16
0
        public void SetCategoryWithStringIndexSucceeds()
        {
            //Arrange
            const string CategoryName    = TestsConstants.TestGuidName;
            const string newCategoryName = "{351C28A4-2E3C-4C98-82CD-2B6FEEE3A12C}";
            var          target          = new DiagnosticsCategoryCollection();
            var          category        = new DiagnosticsCategory(CategoryName);

            target.Add(category);
            var expected = new DiagnosticsCategory(newCategoryName);

            //Act
            target[TestsConstants.TestGuidName] = expected;

            //Assert
            Assert.AreEqual <DiagnosticsCategory>(expected, target[newCategoryName]);
        }
Esempio n. 17
0
        public void SetDuplicateCategoryWithStringIndexThrowsInvalidOperationException()
        {
            //Arrange
            const string CategoryName = TestsConstants.TestGuidName;
            var          target       = new DiagnosticsCategoryCollection();
            var          category     = new DiagnosticsCategory(CategoryName, EventSeverity.ErrorCritical, TraceSeverity.High);

            target.Add(category);
            DiagnosticsCategory expected = new DiagnosticsCategory(TestsConstants.TestGuidName, EventSeverity.Information, TraceSeverity.Medium);

            target.Add(expected);

            //Act
            target[TestsConstants.TestGuidName] = expected;

            //Assert
            Assert.AreEqual <DiagnosticsCategory>(target[TestsConstants.TestGuidName], expected);
        }
Esempio n. 18
0
        public void ConstructCategoryCollectionWithListSucceeds()
        {
            //Arrange
            var    addCategories = new List <DiagnosticsCategory>();
            string category2Name = "{2FC195E5-8102-449A-B42E-2FEC841E30ED}";
            var    expected1     = new DiagnosticsCategory(TestsConstants.TestGuidName);
            var    expected2     = new DiagnosticsCategory(category2Name);

            addCategories.Add(expected1);
            addCategories.Add(expected2);

            //Act
            var target = new DiagnosticsCategoryCollection(addCategories);

            //Assert
            Assert.IsTrue(target.Count == 2);
            Assert.AreEqual <DiagnosticsCategory>(expected1, target[0]);
            Assert.AreEqual <DiagnosticsCategory>(expected2, target[1]);
        }
Esempio n. 19
0
        public void CreateNameAndValuesConstructorSucceeds()
        {
            string testCategory = TestsConstants.TestGuidName;

            //Arrange
            var diagnosticsCategories = new DiagnosticsCategoryCollection();

            diagnosticsCategories.Add(new DiagnosticsCategory(testCategory,
                                                              Microsoft.SharePoint.Administration.EventSeverity.Error,
                                                              Microsoft.SharePoint.Administration.TraceSeverity.Medium));

            //Act
            var area = new DiagnosticsArea("name", diagnosticsCategories);

            // Assert
            Assert.AreEqual <string>("name", area.Name);
            Assert.AreEqual <int>(1, area.DiagnosticsCategories.Count);
            Assert.AreEqual <int>(1, diagnosticsCategories.Count);
            Assert.IsTrue(area.DiagnosticsCategories[0].Name == testCategory);
            Assert.IsTrue(area.DiagnosticsCategories[0].EventSeverity == Microsoft.SharePoint.Administration.EventSeverity.Error);
            Assert.IsTrue(area.DiagnosticsCategories[0].TraceSeverity == Microsoft.SharePoint.Administration.TraceSeverity.Medium);
        }
Esempio n. 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DiagnosticsArea"/> class.
 /// </summary>
 public DiagnosticsArea()
 {
     this.diagnosticsCategories = new DiagnosticsCategoryCollection();
 }
Esempio n. 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DiagnosticsArea"/> class.
 /// </summary>
 public DiagnosticsArea()
 {
     this.diagnosticsCategories = new DiagnosticsCategoryCollection();
 }