public void TestCacheFrom() { var dependency = new DependencyContainer(); var newDependency = new DependencyContainer(); List <int> a = new List <int>(); List <float> b = new List <float>(); dependency.Cache(a); dependency.Cache(b); Assert.AreSame(a, dependency.Get <List <int> >()); Assert.AreSame(b, dependency.Get <List <float> >()); newDependency.CacheFrom(dependency); Assert.AreSame(dependency.Get <List <int> >(), newDependency.Get <List <int> >()); Assert.AreSame(dependency.Get <List <float> >(), newDependency.Get <List <float> >()); var newA = new List <int>(); var newB = new List <float>(); Assert.AreNotSame(newA, dependency.Get <List <int> >()); Assert.AreNotSame(newA, newDependency.Get <List <int> >()); Assert.AreNotSame(newB, dependency.Get <List <float> >()); Assert.AreNotSame(newB, newDependency.Get <List <float> >()); var lastDependency = new DependencyContainer(); lastDependency.Cache(newA); lastDependency.Cache(newB); newDependency.CacheFrom(lastDependency); Assert.AreNotSame(newA, newDependency.Get <List <int> >()); Assert.AreNotSame(newB, newDependency.Get <List <float> >()); newDependency.CacheFrom(lastDependency, true); Assert.AreSame(newA, newDependency.Get <List <int> >()); Assert.AreSame(newB, newDependency.Get <List <float> >()); }