public void RemoveAll_GuardClauses() { // Arrange var config = new ProcessorConfiguration(); var defaultServices = new DefaultServices(config); // Act & assert ExceptionAssert.ThrowsArgumentNull(() => defaultServices.RemoveAll(serviceType: null, match: _ => true), "serviceType"); ExceptionAssert.ThrowsArgumentNull(() => defaultServices.RemoveAll(typeof(object), match: null), "match"); ExceptionAssert.ThrowsArgument(() => defaultServices.RemoveAll(typeof(object), _ => true), "serviceType"); }
public void RemoveAll_PartialMatch() { // Arrange var config = new ProcessorConfiguration(); var defaultServices = new DefaultServices(config); var filterProvider1 = new Mock <IFilterProvider>().Object; var filterProvider2 = new Mock <IFilterProvider>().Object; defaultServices.ReplaceRange(typeof(IFilterProvider), new[] { filterProvider1, filterProvider2 }); // Act defaultServices.RemoveAll(typeof(IFilterProvider), obj => obj == filterProvider2); // Assert Assert.Equal(new[] { filterProvider1 }, defaultServices.GetServices(typeof(IFilterProvider))); }
public void RemoveAll_SuccessfulMatch() { // Arrange var config = new ProcessorConfiguration(); var defaultServices = new DefaultServices(config); var filterProvider1 = new Mock <IFilterProvider>().Object; var filterProvider2 = new Mock <IFilterProvider>().Object; defaultServices.ReplaceRange(typeof(IFilterProvider), new[] { filterProvider1, filterProvider2 }); // Act defaultServices.RemoveAll(typeof(IFilterProvider), _ => true); // Assert Assert.Equal(0, defaultServices.GetServices(typeof(IFilterProvider)).Count()); }
public void RemoveAll_PartialMatch() { // Arrange var config = new ProcessorConfiguration(); var defaultServices = new DefaultServices(config); var filterProvider1 = new Mock<IFilterProvider>().Object; var filterProvider2 = new Mock<IFilterProvider>().Object; defaultServices.ReplaceRange(typeof(IFilterProvider), new[] { filterProvider1, filterProvider2 }); // Act defaultServices.RemoveAll(typeof(IFilterProvider), obj => obj == filterProvider2); // Assert Assert.Equal(new[] { filterProvider1 }, defaultServices.GetServices(typeof(IFilterProvider))); }
public void RemoveAll_SuccessfulMatch() { // Arrange var config = new ProcessorConfiguration(); var defaultServices = new DefaultServices(config); var filterProvider1 = new Mock<IFilterProvider>().Object; var filterProvider2 = new Mock<IFilterProvider>().Object; defaultServices.ReplaceRange(typeof(IFilterProvider), new[] { filterProvider1, filterProvider2 }); // Act defaultServices.RemoveAll(typeof(IFilterProvider), _ => true); // Assert Assert.Equal(0, defaultServices.GetServices(typeof(IFilterProvider)).Count()); }