Exemplo n.º 1
0
        public void RemoveAll_GuardClauses()
        {
            // Arrange
            var config          = new HttpConfiguration();
            var defaultServices = new DefaultServices(config);

            // Act & assert
            Assert.ThrowsArgumentNull(() => defaultServices.RemoveAll(serviceType: null, match: _ => true), "serviceType");
            Assert.ThrowsArgumentNull(() => defaultServices.RemoveAll(typeof(object), match: null), "match");
            Assert.ThrowsArgument(
                () => defaultServices.RemoveAll(typeof(object), _ => true),
                "serviceType",
                "The service type Object is not supported.");
        }
Exemplo n.º 2
0
        public void RemoveAll_PartialMatch()
        {
            // Arrange
            var config          = new HttpConfiguration();
            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)));
        }
Exemplo n.º 3
0
        public void RemoveAll_SuccessfulMatch()
        {
            // Arrange
            var config          = new HttpConfiguration();
            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.Empty(defaultServices.GetServices(typeof(IFilterProvider)));
        }
        public void RemoveAll_PartialMatch()
        {
            // Arrange
            var config = new HttpConfiguration();
            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 HttpConfiguration();
            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.Empty(defaultServices.GetServices(typeof(IFilterProvider)));
        }
        public void RemoveAll_GuardClauses()
        {
            // Arrange
            var config = new HttpConfiguration();
            var defaultServices = new DefaultServices(config);

            // Act & assert
            Assert.ThrowsArgumentNull(() => defaultServices.RemoveAll(serviceType: null, match: _ => true), "serviceType");
            Assert.ThrowsArgumentNull(() => defaultServices.RemoveAll(typeof(object), match: null), "match");
            Assert.ThrowsArgument(
                () => defaultServices.RemoveAll(typeof(object), _ => true),
                "serviceType",
                "The service type Object is not supported.");
        }