Пример #1
0
        public void RemoveAt_GuardClauses()
        {
            // Arrange
            var config          = new HttpConfiguration();
            var defaultServices = new DefaultServices(config);

            // Act & assert
            Assert.ThrowsArgumentNull(() => defaultServices.RemoveAt(serviceType: null, index: 0), "serviceType");
            Assert.ThrowsArgument(
                () => defaultServices.RemoveAt(typeof(object), 0),
                "serviceType",
                "The service type Object is not supported.");
            Assert.ThrowsArgumentOutOfRange(
                () => defaultServices.RemoveAt(typeof(IFilterProvider), -1),
                "index",
                "Index was out of range. Must be non-negative and less than the size of the collection.");
        }
Пример #2
0
        public void RemoteAt_RemovesService()
        {
            // 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.RemoveAt(typeof(IFilterProvider), 1);

            // Assert
            Assert.Equal(new[] { filterProvider1 }, defaultServices.GetServices(typeof(IFilterProvider)));
        }
        public void RemoteAt_RemovesService()
        {
            // 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.RemoveAt(typeof(IFilterProvider), 1);

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

            // Act & assert
            Assert.ThrowsArgumentNull(() => defaultServices.RemoveAt(serviceType: null, index: 0), "serviceType");
            Assert.ThrowsArgument(
                () => defaultServices.RemoveAt(typeof(object), 0),
                "serviceType",
                "The service type Object is not supported.");
            Assert.ThrowsArgumentOutOfRange(
                () => defaultServices.RemoveAt(typeof(IFilterProvider), -1),
                "index",
                "Index was out of range. Must be non-negative and less than the size of the collection.");
        }