Пример #1
0
        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");
        }
Пример #2
0
        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)));
        }
Пример #3
0
        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());
        }
Пример #4
0
        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)));
        }
Пример #5
0
        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());
        }
Пример #6
0
        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");
        }