Example #1
0
        public void WhenCallingResetItShouldBePossibleToRegisterInstancesAgain()
        {
            // Arrange
            var container = new ShifterContainer();

            // Act
            container.Reset();
            container.AddInstance("string");
            var resolvedValue = container.Resolve <string>();

            // Assert
            resolvedValue.Should().Be("string", "because we added it.");
        }
Example #2
0
        public void WhenResettingItShouldUnregisterAllInstancesOfThatType()
        {
            // 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.Reset();
            var resolvedInts      = container.ResolveAll <int>();
            var resolvedString    = container.ResolveAll <string>();
            var resolvedContainer = container.ResolveAll <IShifterContainer>();

            // Assert
            resolvedInts.Should().BeEmpty("because these ints are unregistered.");
            resolvedString.Should().BeEmpty("because these strings are unregistered.");
            resolvedContainer.Should().BeEmpty("because these containers are unregistered.");
        }