public void Enumerator_ReturnsElementsInDefault_ExceptThoseInDirectCollection() { // Arrange var extension1 = new ExtensionOne(); var extension2 = new ExtensionTwo(); var extension2InDefault = new ExtensionTwo(); var extension3InDefault = new ExtensionThree(); var defaults = new WorkContextExtensionCollection(); defaults[typeof(ExtensionTwo)] = extension2InDefault; defaults[typeof(ExtensionThree)] = extension3InDefault; var collection = new WorkContextExtensionCollection(defaults); collection[typeof(ExtensionOne)] = extension1; collection[typeof(ExtensionTwo)] = extension2; // Act var extensions = collection.ToList(); // Assert Assert.Equal(3, extensions.Count); Assert.Contains(extensions, p => p.Key == typeof(ExtensionOne) && p.Value == extension1); Assert.Contains(extensions, p => p.Key == typeof(ExtensionTwo) && p.Value == extension2); Assert.Contains(extensions, p => p.Key == typeof(ExtensionThree) && p.Value == extension3InDefault); Assert.DoesNotContain(extensions, p => p.Key == typeof(ExtensionTwo) && p.Value == extension2InDefault); }
public void Enumerator_ReturnsElementsInCollection() { // Arrange var extension1 = new ExtensionOne(); var extension2 = new ExtensionTwo(); var collection = new WorkContextExtensionCollection(); collection[typeof(ExtensionOne)] = extension1; collection[typeof(ExtensionTwo)] = extension2; // Act var extensions = collection.ToList(); // Assert Assert.Equal(2, extensions.Count); Assert.Contains(extensions, p => p.Key == typeof(ExtensionOne) && p.Value == extension1); Assert.Contains(extensions, p => p.Key == typeof(ExtensionTwo) && p.Value == extension2); }