public void GetCloneFor_DoesntCallClonerTwiceForKnownObject()
        {
            CloneContext context = new CloneContext(_clonerMock);
            Order        source  = DomainObjectIDs.Order1.GetObject <Order> ();
            Order        clone   = Order.NewObject();

            Expect.Call(_clonerMock.CreateCloneHull <DomainObject> (source)).Return(clone);
            _mockRepository.ReplayAll();
            Assert.That(context.GetCloneFor(source), Is.SameAs(clone));
            Assert.That(context.GetCloneFor(source), Is.SameAs(clone));
            _mockRepository.VerifyAll();
        }
        public void GetCloneFor_DoesntAddToShallowClonesForKnownObject()
        {
            CloneContext context = new CloneContext(_clonerMock);
            Order        source  = DomainObjectIDs.Order1.GetObject <Order> ();
            Order        clone   = Order.NewObject();

            SetupResult.For(_clonerMock.CreateCloneHull <DomainObject> (source)).Return(clone);
            _mockRepository.ReplayAll();

            context.GetCloneFor(source);
            context.GetCloneFor(source);
            Assert.That(context.CloneHulls.Count, Is.EqualTo(1));
        }
        public void GetCloneFor_AddsToShallowClones()
        {
            CloneContext context = new CloneContext(_clonerMock);
            Order        source  = DomainObjectIDs.Order1.GetObject <Order> ();
            Order        clone   = Order.NewObject();

            SetupResult.For(_clonerMock.CreateCloneHull <DomainObject> (source)).Return(clone);
            _mockRepository.ReplayAll();

            context.GetCloneFor(source);
            Assert.That(context.CloneHulls.Contains(new Tuple <DomainObject, DomainObject> (source, clone)));
        }