public void Remove_NullAreaDoesntThrowException() { //Arrange MockConfigManager config = new MockConfigManager(); DiagnosticsAreaCollection areas = new DiagnosticsAreaCollection(config); //Act areas.Remove(null); // Assert - no action required, it should be a no-op }
public void Save_AreasConfiguration() { //Arrange MockConfigManager config = new MockConfigManager(); DiagnosticsAreaCollection areas = new DiagnosticsAreaCollection(config); //Act areas.SaveConfiguration(); //Assert Assert.IsTrue(config.SaveCount == 1); }
public void CTOR_WithNoConfigurationSet() { //Arrange var config = new MockConfigManager(); config.Clear(); //Act var target = new DiagnosticsAreaCollection(config); //Assert Assert.IsTrue(target.Count == 0); }
public void Add_AreaWithConfigMgrConstructorWithConfigData() { //Arrange var configMgr = new MockConfigManager(); var target = new DiagnosticsAreaCollection(configMgr); var expected = new DiagnosticsArea(TestsConstants.TestGuidName); //Act target.Add(expected); //Assert Assert.AreEqual <DiagnosticsArea>(target[TestsConstants.TestGuidName], expected); }
public void CTOR_WithConfiguration() { //Arrange var expected = new MockConfigManager(); //Act var target = new DiagnosticsAreaCollection(expected); //Assert Assert.IsTrue(target.Count == expected.Areas.Count); for (int i = 0; i < target.Count; i++) { Assert.AreEqual <DiagnosticsArea>(target[i], expected.Areas[i]); } }
public void Update_ByStringIndexer() { //Arrange var config = new MockConfigManager(); var target = new DiagnosticsAreaCollection(config); var expected = new DiagnosticsArea(MockConfigManager.Area1Name); var category = new DiagnosticsCategory(Guid.NewGuid().ToString()); expected.DiagnosticsCategories.Add(category); //Act target[MockConfigManager.Area1Name] = expected; //Assert Assert.AreEqual <DiagnosticsArea>(target[MockConfigManager.Area1Name], expected); Assert.IsTrue(target[MockConfigManager.Area1Name].DiagnosticsCategories.Count == 1); Assert.AreEqual(target[MockConfigManager.Area1Name].DiagnosticsCategories[0], category); }
public void Remove_AreaRemoveDefault() { //Arrange MockConfigManager config = new MockConfigManager(); DiagnosticsAreaCollection areas = new DiagnosticsAreaCollection(config); DiagnosticsArea area = new DiagnosticsArea(MockConfigManager.Area2Name); DiagnosticsCategory category = new DiagnosticsCategory(MockConfigManager.Area2Category1Name); area.DiagnosticsCategories.Add(category); int areasCount = areas.Count; DiagnosticsArea originalArea = areas[MockConfigManager.Area2Name]; //Act bool isRemoved = areas.Remove(originalArea); //Assert Assert.IsTrue(isRemoved); Assert.IsNull(areas[MockConfigManager.Area2Name]); }
public void Update_ByStringIndexerWithNullValue_ThrowsArgumentNotNullException() { //Arrange var config = new MockConfigManager(); var target = new DiagnosticsAreaCollection(config); bool expectedExceptionThrown = false; //Act try { target[MockConfigManager.Area1Name] = null; } catch (ArgumentNullException) { expectedExceptionThrown = true; } //Assert Assert.IsTrue(expectedExceptionThrown); }
public void Update_ByStringIndexerWithDuplicateArea_ThrowsInvalidOperationException() { //Arrange var config = new MockConfigManager(); var target = new DiagnosticsAreaCollection(config); var area = new DiagnosticsArea(MockConfigManager.Area2Name); bool expectedExceptionThrown = false; //Act try { target[MockConfigManager.Area1Name] = area; } catch (InvalidOperationException) { expectedExceptionThrown = true; } //Assert Assert.IsTrue(expectedExceptionThrown, "exception not thrown with duplicate area added"); }
public void Update_ByStringIndexerWithNullAreaName_ThrowsArgumentNullException() { //Arrange var config = new MockConfigManager(); var target = new DiagnosticsAreaCollection(config); var area = new DiagnosticsArea(); bool expectedExceptionThrown = false; //Act try { target[MockConfigManager.Area1Name] = area; } catch (ArgumentNullException) { expectedExceptionThrown = true; } //Assert Assert.IsTrue(expectedExceptionThrown, "did not throw exception with null area name"); }
public void Update_ByStringIndexerWithNullKey_ThrowsArgumentNullException() { //Arrange var config = new MockConfigManager(); var target = new DiagnosticsAreaCollection(config); var area = new DiagnosticsArea(TestsConstants.TestGuidName); bool expectedExceptionThrown = false; //Act try { target[null] = area; } catch (ArgumentNullException) { expectedExceptionThrown = true; } //Assert Assert.IsTrue(expectedExceptionThrown); }
public void Update_ByIndexerWithNullAreaName_ThrowsArgumentNullException() { //Arrange var config = new MockConfigManager(); var target = new DiagnosticsAreaCollection(config); var originalArea = target[MockConfigManager.Area1Name]; int index = target.IndexOf(originalArea); var area = new DiagnosticsArea(); bool expectedExceptionThrown = false; //Act try { target[index] = area; } catch (ArgumentNullException) { expectedExceptionThrown = true; } //Assert Assert.IsTrue(expectedExceptionThrown); }