public void TestResolveByBaseClass()
 {
     var container = this.GetContainer();
     var original = new ChildMock();
     container.Register(original);
     var resolved = container.Get<ParentMock>();
     resolved.Should().NotBeNull("unable to resolve the Parent class");
     resolved.Should().BeSameAs(original, "returned Child is a different instance");
 }
 public void TestResolveByClass()
 {
     var container = this.GetContainer();
     var registered = new ChildMock();
     container.Register(registered);
     var resolved = container.Get<ChildMock>();
     resolved.Should().NotBeNull("unable to resolve the item by class");
     resolved.Should().BeSameAs(registered, "returned item is a different instance than the registered");
 }
Exemplo n.º 3
0
        public void TestResolveByBaseClass()
        {
            var container = this.GetContainer();
            var original  = new ChildMock();

            container.Register(original);
            var resolved = container.Get <ParentMock>();

            resolved.Should().NotBeNull("unable to resolve the Parent class");
            resolved.Should().BeSameAs(original, "returned Child is a different instance");
        }
Exemplo n.º 4
0
        public void TestResolveByClass()
        {
            var container  = this.GetContainer();
            var registered = new ChildMock();

            container.Register(registered);
            var resolved = container.Get <ChildMock>();

            resolved.Should().NotBeNull("unable to resolve the item by class");
            resolved.Should().BeSameAs(registered, "returned item is a different instance than the registered");
        }
Exemplo n.º 5
0
        public void TestDoubleRegistration()
        {
            var container = this.GetContainer();
            var resolved  = new ChildMock();
            var resolved2 = new ChildMock();

            container.Register(resolved);
            container.Register(resolved2);
            container.Get <ChildMock>().Should().BeSameAs(resolved2, "object not replaced with second");
            container.Register(resolved);
            container.Get <ChildMock>().Should().BeSameAs(resolved, "object not replaced with original");
        }
Exemplo n.º 6
0
        public void TestDoubleRegistration()
        {
            var container = this.GetContainer();
            var resolved  = new ChildMock();
            var resolved2 = new ChildMock();

            container.Register(resolved);
            container.Register(resolved2);
            container.Get <ChildMock>().Should().BeSameAs(resolved2, "object not replaced with second");
            container.Register(resolved);
            container.Get <ChildMock>().Should().BeSameAs(resolved, "object not replaced with original");
            container.GetAll().OfType <ChildMock>().Count().Should().Be(3, "first object has been removed from history");
        }
Exemplo n.º 7
0
        public void TestResolveAllTwoElements()
        {
            var container = this.GetContainer();
            var first     = new ParentMock();

            container.Register(first);
            var second = new ChildMock();

            container.Register(second, second.GetType());
            var resolved = container.GetAll().OfType <ParentMock>().ToList();

            resolved.Should().NotBeNull("resolved collection should not be null");
            resolved.Count.Should().Be(2, "resolved collection should have 2 elements");
            resolved.First().Should().BeSameAs(first, "resolved element 1 should be the original item");
            resolved.Last().Should().BeSameAs(second, "resolved element 2 should be the new item");
        }
 public void TestResolveAllTwoElements()
 {
     var container = this.GetContainer();
     var first = new ParentMock();
     container.Register(first);
     var second = new ChildMock();
     container.Register(second, second.GetType());
     var resolved = container.GetAll().OfType<ParentMock>().ToList();
     resolved.Should().NotBeNull("resolved collection should not be null");
     resolved.Count.Should().Be(2, "resolved collection should have 2 elements");
     resolved.First().Should().BeSameAs(first, "resolved element 1 should be the original item");
     resolved.Last().Should().BeSameAs(second, "resolved element 2 should be the new item");
 }
 public void TestDoubleRegistration()
 {
     var container = this.GetContainer();
     var resolved = new ChildMock();
     var resolved2 = new ChildMock();
     container.Register(resolved);
     container.Register(resolved2);
     container.Get<ChildMock>().Should().BeSameAs(resolved2, "object not replaced with second");
     container.Register(resolved);
     container.Get<ChildMock>().Should().BeSameAs(resolved, "object not replaced with original");
     container.GetAll().OfType<ChildMock>().Count().Should().Be(3, "first object has been removed from history");
 }