Ejemplo n.º 1
0
        public void WhenUnregisteringATypeGenericallyItShouldUnregisterAllInstancesOfThatType()
        {
            // Arrange
            var container = new ShifterContainer();

            container
            .AddInstance(typeof(int), 1234)
            .AddInstance(typeof(string), "Hello")
            .AddInstance(typeof(int), 2)
            .AddInstance(typeof(IShifterContainer), ShifterContainer.Default);

            // Act
            container.Unregister <int>();
            var resolvedInts      = container.ResolveAll <int>();
            var resolvedString    = container.ResolveAll <string>();
            var resolvedContainer = container.ResolveAll <IShifterContainer>();

            // Assert
            resolvedInts.Should().BeEmpty("because these are unregistered.");
            resolvedString.Count().Should().Be(1, "because one string was left.");
            resolvedContainer.Count().Should().Be(1, "because one IShifterContainer was left.");
        }