public void Initialization_WithEventRaiser()
        {
            var innerRaiserStub = MockRepository.GenerateStub <IDomainObjectCollectionEventRaiser> ();
            var indirectRaiser  = new IndirectDomainObjectCollectionEventRaiser(innerRaiserStub);

            Assert.That(indirectRaiser.EventRaiser, Is.SameAs(innerRaiserStub));
        }
        private void CheckDelegation(Action <IDomainObjectCollectionEventRaiser> action)
        {
            var indirectRaiser   = new IndirectDomainObjectCollectionEventRaiser();
            var actualRaiserMock = MockRepository.GenerateMock <IDomainObjectCollectionEventRaiser>();

            indirectRaiser.EventRaiser = actualRaiserMock;

            action(indirectRaiser);

            actualRaiserMock.AssertWasCalled(action);
        }
        private void CheckThrowOnNoEventRaiser(Action <IDomainObjectCollectionEventRaiser> action)
        {
            var indirectRaiser = new IndirectDomainObjectCollectionEventRaiser();

            try
            {
                action(indirectRaiser);
                Assert.Fail("Expected InvalidOperationException");
            }
            catch (InvalidOperationException)
            {
                // ok
            }
        }
        /// <summary>
        /// Creates a stand-alone collection of the given <paramref name="collectionType"/> via reflection. The collection is initialized to have
        /// the given <paramref name="requiredItemType"/> and initial <paramref name="content"/>.
        /// The collection must provide a constructor that takes a single parameter of type <see cref="IDomainObjectCollectionData"/>.
        /// </summary>
        /// <param name="collectionType">The type of the collection to create.</param>
        /// <param name="content">The initial content of the collection. This must match <paramref name="requiredItemType"/> and it cannot contain
        /// duplicates or <see langword="null" /> values.</param>
        /// <param name="requiredItemType">The required item type of the collection.</param>
        /// <returns>A stand-alone instance of <paramref name="collectionType"/>.</returns>
        public DomainObjectCollection CreateCollection(Type collectionType, IEnumerable <DomainObject> content, Type requiredItemType)
        {
            ArgumentUtility.CheckNotNull("collectionType", collectionType);
            ArgumentUtility.CheckNotNull("content", content);

            var eventRaiser = new IndirectDomainObjectCollectionEventRaiser();

            var dataStore = new DomainObjectCollectionData();

            dataStore.AddRangeAndCheckItems(content, requiredItemType);

            var dataStrategy = DomainObjectCollection.CreateDataStrategyForStandAloneCollection(dataStore, requiredItemType, eventRaiser);
            var collection   = CreateCollection(collectionType, dataStrategy);

            eventRaiser.EventRaiser = collection;

            return(collection);
        }
        public void Serializable()
        {
            var indirectRaiser = new IndirectDomainObjectCollectionEventRaiser();

            Serializer.SerializeAndDeserialize(indirectRaiser);
        }
        public void Initialization_WithoutEventRaiser()
        {
            var indirectRaiser = new IndirectDomainObjectCollectionEventRaiser();

            Assert.That(indirectRaiser.EventRaiser, Is.Null);
        }