Esempio n. 1
0
        public void Remove_GuardClauses()
        {
            // Arrange
            var config          = new HttpConfiguration();
            var defaultServices = new DefaultServices(config);

            // Act & assert
            Assert.ThrowsArgumentNull(() => defaultServices.Remove(serviceType: null, service: new object()), "serviceType");
            Assert.ThrowsArgumentNull(() => defaultServices.Remove(typeof(object), service: null), "service");
            Assert.ThrowsArgument(
                () => defaultServices.Remove(typeof(object), new object()),
                "serviceType",
                "The service type Object is not supported.");
        }
Esempio n. 2
0
        public void Remove_ObjectFound()
        {
            // 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.Remove(typeof(IFilterProvider), filterProvider1);

            // Assert
            Assert.Equal(new[] { filterProvider2 }, defaultServices.GetServices(typeof(IFilterProvider)));
        }
        public void Remove_ObjectNotFound()
        {
            // Arrange
            var config = new HttpConfiguration();
            var defaultServices = new DefaultServices(config);
            var filterProvider1 = new Mock<IFilterProvider>().Object;
            var filterProvider2 = new Mock<IFilterProvider>().Object;
            var notPresentFilterProvider = new Mock<IFilterProvider>().Object;
            defaultServices.ReplaceRange(typeof(IFilterProvider), new[] { filterProvider1, filterProvider2 });

            // Act
            defaultServices.Remove(typeof(IFilterProvider), notPresentFilterProvider);

            // Assert
            Assert.Equal(new[] { filterProvider1, filterProvider2 }, defaultServices.GetServices(typeof(IFilterProvider)));
        }
        public void Remove_GuardClauses()
        {
            // Arrange
            var config = new HttpConfiguration();
            var defaultServices = new DefaultServices(config);

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