public void Map_GivenWithRemovedDtosWithExceptionThrownByRemoveMethod_Succeeds()
        {
            var dtoCollection = new SoftDeleteObservableCollection <AggregateCollectionMapperTestDto> ();
            var dto           = new AggregateCollectionMapperTestDto();

            dtoCollection.RemovedItems.Add(dto);

            var requestHandler = new AggregateCollectionMapperTestRequestHandler();

            var aggregateRoot           = new AggregateCollectionMapperTestAggregateRootEntity();
            var aggregateNodeCollection = new List <AggregateCollectionMapperTestAggregateNodeEntity>
            {
                new AggregateCollectionMapperTestAggregateNodeEntity()
            };

            var aggregateNodeCollectionMapper = new AggregateNodeCollectionMapper
                                                <AggregateCollectionMapperTestDto, AggregateCollectionMapperTestAggregateRootEntity,
                                                 AggregateCollectionMapperTestAggregateNodeEntity> (
                dtoCollection, aggregateRoot, aggregateNodeCollection);

            bool returnValue = aggregateNodeCollectionMapper
                               .MapRemovedItem(requestHandler.AggregateNodeRemoveWithThrowException)
                               .MapChangedItem(requestHandler.AggregateNodeChangeWithThrowException)
                               .MapAddedItem(requestHandler.AggregateNodeAddWithThrowException)
                               .Map();

            Assert.IsTrue(dtoCollection.RemovedItems[0].DataErrorInfoCollection.Count() > 0);
            Assert.IsTrue(requestHandler.NoOfTimesAggregateNodeAddWithThrowExceptionMethodCalled == 0);
            Assert.IsTrue(requestHandler.NoOfTimesAggregateNodeChangeWithThrowExceptionMethodCalled == 0);
            Assert.IsTrue(requestHandler.NoOfTimesAggregateNodeRemoveWithThrowExceptionMethodCalled > 0);
            Assert.IsFalse(returnValue);
        }
        public void Map_GivenWithCurrentDtosAndEditStatusAsUpdate_Succeeds()
        {
            var dtoCollection = new SoftDeleteObservableCollection <AggregateCollectionMapperTestDto> ();
            var dto           = new AggregateCollectionMapperTestDto {
                EditStatus = EditStatus.Update
            };

            dtoCollection.CurrentItems.Add(dto);

            var requestHandler = new AggregateCollectionMapperTestRequestHandler();

            var aggregateRoot           = new AggregateCollectionMapperTestAggregateRootEntity();
            var aggregateNodeCollection = new List <AggregateCollectionMapperTestAggregateNodeEntity>
            {
                new AggregateCollectionMapperTestAggregateNodeEntity()
            };

            var aggregateNodeCollectionMapper = new AggregateNodeCollectionMapper
                                                <AggregateCollectionMapperTestDto, AggregateCollectionMapperTestAggregateRootEntity,
                                                 AggregateCollectionMapperTestAggregateNodeEntity> (
                dtoCollection, aggregateRoot, aggregateNodeCollection);

            bool returnValue = aggregateNodeCollectionMapper
                               .MapRemovedItem(requestHandler.AggregateNodeRemove)
                               .MapChangedItem(requestHandler.AggregateNodeChange)
                               .MapAddedItem(requestHandler.AggregateNodeAdd)
                               .Map();

            Assert.IsTrue(returnValue);
            Assert.IsTrue(dtoCollection.CurrentItems[0].DataErrorInfoCollection.Count() == 0);
            Assert.IsTrue(requestHandler.NoOfTimesAggregateNodeRemoveMethodCalled == 0);
            Assert.IsTrue(requestHandler.NoOfTimesAggregateNodeChangeMethodCalled > 0);
            Assert.IsTrue(requestHandler.NoOfTimesAggregateNodeAddMethodCalled == 0);
        }
        public void Map_GivenWithCurrentDtosAndEditStatusAsDelete_ThrowsArgumentException()
        {
            var dtoCollection = new SoftDeleteObservableCollection <AggregateCollectionMapperTestDto> ();
            var dto           = new AggregateCollectionMapperTestDto {
                EditStatus = EditStatus.Delete
            };

            dtoCollection.CurrentItems.Add(dto);

            var requestHandler = new AggregateCollectionMapperTestRequestHandler();

            var aggregateRoot           = new AggregateCollectionMapperTestAggregateRootEntity();
            var aggregateNodeCollection = new List <AggregateCollectionMapperTestAggregateNodeEntity>
            {
                new AggregateCollectionMapperTestAggregateNodeEntity()
            };

            var aggregateNodeCollectionMapper = new AggregateNodeCollectionMapper
                                                <AggregateCollectionMapperTestDto, AggregateCollectionMapperTestAggregateRootEntity,
                                                 AggregateCollectionMapperTestAggregateNodeEntity> (
                dtoCollection, aggregateRoot, aggregateNodeCollection);

            bool returnValue = aggregateNodeCollectionMapper
                               .MapRemovedItem(requestHandler.AggregateNodeRemove)
                               .MapChangedItem(requestHandler.AggregateNodeChange)
                               .MapAddedItem(requestHandler.AggregateNodeAdd)
                               .Map();
        }
        public void Map_GivenWithCurrentDtosAndEditStatusAsCreateWithExceptionThrownByAddMethod_Succeeds()
        {
            var dtoCollection = new SoftDeleteObservableCollection <AggregateCollectionMapperTestDto> ();
            var dto           = new AggregateCollectionMapperTestDto {
                EditStatus = EditStatus.Create
            };

            dtoCollection.CurrentItems.Add(dto);

            var requestHandler = new AggregateCollectionMapperTestRequestHandler();

            var aggregateRootCollectionMapper = new AggregateRootCollectionMapper
                                                <AggregateCollectionMapperTestDto, AggregateCollectionMapperTestAggregateRootEntity> (dtoCollection);

            bool returnValue = aggregateRootCollectionMapper
                               .FindCollectionEntity(requestHandler.AggregateRootFind)
                               .MapRemovedItem(requestHandler.AggregateRootRemoveWithThrowException)
                               .MapChangedItem(requestHandler.AggregateRootChangeWithThrowException)
                               .MapAddedItem(requestHandler.AggregateRootAddWithThrowException)
                               .Map();

            Assert.IsTrue(dtoCollection.CurrentItems[0].DataErrorInfoCollection.Count() > 0);
            Assert.IsTrue(requestHandler.NoOfTimesAggregateRootFindMethodCalled == 0);
            Assert.IsTrue(requestHandler.NoOfTimesAggregateRootAddWithThrowExceptionMethodCalled > 0);
            Assert.IsTrue(requestHandler.NoOfTimesAggregateRootChangeWithThrowExceptionMethodCalled == 0);
            Assert.IsTrue(requestHandler.NoOfTimesAggregateRootRemoveWithThrowExceptionMethodCalled == 0);
            Assert.IsFalse(returnValue);
        }
 public void AggregateNodeChangeWithThrowException(AggregateCollectionMapperTestDto aggregateNodeCollectionMapperTestDto, AggregateCollectionMapperTestAggregateRootEntity aggregateNodeCollectionMapperTestAggregateRootEntity, AggregateCollectionMapperTestAggregateNodeEntity aggregateNodeCollectionMapperTestAggregateNodeEntity)
 {
     NoOfTimesAggregateNodeChangeWithThrowExceptionMethodCalled++;
     throw new Exception();
 }
 public void AggregateRootAddWithThrowException(AggregateCollectionMapperTestDto aggregateNodeCollectionMapperTestDto)
 {
     NoOfTimesAggregateRootAddWithThrowExceptionMethodCalled++;
     throw new Exception();
 }
 public void AggregateNodeChange(AggregateCollectionMapperTestDto aggregateNodeCollectionMapperTestDto, AggregateCollectionMapperTestAggregateRootEntity aggregateNodeCollectionMapperTestAggregateRootEntity, AggregateCollectionMapperTestAggregateNodeEntity aggregateNodeCollectionMapperTestAggregateNodeEntity)
 {
     NoOfTimesAggregateNodeChangeMethodCalled++;
 }
        public void Map_GivenWithRemovedDtosWithExceptionThrownByRemoveMethod_Succeeds()
        {
            var dtoCollection = new SoftDeleteObservableCollection<AggregateCollectionMapperTestDto> ();
            var dto = new AggregateCollectionMapperTestDto ();
            dtoCollection.RemovedItems.Add ( dto );

            var requestHandler = new AggregateCollectionMapperTestRequestHandler ();

            var aggregateRoot = new AggregateCollectionMapperTestAggregateRootEntity ();
            var aggregateNodeCollection = new List<AggregateCollectionMapperTestAggregateNodeEntity>
                                              { new AggregateCollectionMapperTestAggregateNodeEntity () };

            var aggregateNodeCollectionMapper = new AggregateNodeCollectionMapper
                <AggregateCollectionMapperTestDto, AggregateCollectionMapperTestAggregateRootEntity,
                    AggregateCollectionMapperTestAggregateNodeEntity> (
                dtoCollection, aggregateRoot, aggregateNodeCollection );

            bool returnValue = aggregateNodeCollectionMapper
                .MapRemovedItem ( requestHandler.AggregateNodeRemoveWithThrowException )
                .MapChangedItem ( requestHandler.AggregateNodeChangeWithThrowException )
                .MapAddedItem ( requestHandler.AggregateNodeAddWithThrowException )
                .Map ();

            Assert.IsTrue ( dtoCollection.RemovedItems[ 0 ].DataErrorInfoCollection.Count () > 0 );
            Assert.IsTrue ( requestHandler.NoOfTimesAggregateNodeAddWithThrowExceptionMethodCalled == 0 );
            Assert.IsTrue ( requestHandler.NoOfTimesAggregateNodeChangeWithThrowExceptionMethodCalled == 0 );
            Assert.IsTrue ( requestHandler.NoOfTimesAggregateNodeRemoveWithThrowExceptionMethodCalled > 0 );
            Assert.IsFalse ( returnValue );
        }
 public void AggregateRootAdd(AggregateCollectionMapperTestDto aggregateNodeCollectionMapperTestDto)
 {
     NoOfTimesAggregateRootAddMethodCalled++;
 }
        public void Map_GivenWithCurrentDtosAndEditStatusAsDelete_ThrowsArgumentException()
        {
            var dtoCollection = new SoftDeleteObservableCollection<AggregateCollectionMapperTestDto> ();
            var dto = new AggregateCollectionMapperTestDto { EditStatus = EditStatus.Delete };
            dtoCollection.CurrentItems.Add ( dto );

            var requestHandler = new AggregateCollectionMapperTestRequestHandler ();

            var aggregateRoot = new AggregateCollectionMapperTestAggregateRootEntity ();
            var aggregateNodeCollection = new List<AggregateCollectionMapperTestAggregateNodeEntity>
                                              { new AggregateCollectionMapperTestAggregateNodeEntity () };

            var aggregateNodeCollectionMapper = new AggregateNodeCollectionMapper
                <AggregateCollectionMapperTestDto, AggregateCollectionMapperTestAggregateRootEntity,
                    AggregateCollectionMapperTestAggregateNodeEntity> (
                dtoCollection, aggregateRoot, aggregateNodeCollection );

            bool returnValue = aggregateNodeCollectionMapper
                .MapRemovedItem ( requestHandler.AggregateNodeRemove )
                .MapChangedItem ( requestHandler.AggregateNodeChange )
                .MapAddedItem ( requestHandler.AggregateNodeAdd )
                .Map ();
        }
        public void Map_GivenWithCurrentDtosAndEditStatusAsUpdate_Succeeds()
        {
            var dtoCollection = new SoftDeleteObservableCollection<AggregateCollectionMapperTestDto> ();
            var dto = new AggregateCollectionMapperTestDto { EditStatus = EditStatus.Update };
            dtoCollection.CurrentItems.Add ( dto );

            var requestHandler = new AggregateCollectionMapperTestRequestHandler ();

            var aggregateRoot = new AggregateCollectionMapperTestAggregateRootEntity ();
            var aggregateNodeCollection = new List<AggregateCollectionMapperTestAggregateNodeEntity>
                                              { new AggregateCollectionMapperTestAggregateNodeEntity () };

            var aggregateNodeCollectionMapper = new AggregateNodeCollectionMapper
                <AggregateCollectionMapperTestDto, AggregateCollectionMapperTestAggregateRootEntity,
                    AggregateCollectionMapperTestAggregateNodeEntity> (
                dtoCollection, aggregateRoot, aggregateNodeCollection );

            bool returnValue = aggregateNodeCollectionMapper
                .MapRemovedItem ( requestHandler.AggregateNodeRemove )
                .MapChangedItem ( requestHandler.AggregateNodeChange )
                .MapAddedItem ( requestHandler.AggregateNodeAdd )
                .Map ();

            Assert.IsTrue ( returnValue );
            Assert.IsTrue ( dtoCollection.CurrentItems[ 0 ].DataErrorInfoCollection.Count () == 0 );
            Assert.IsTrue ( requestHandler.NoOfTimesAggregateNodeRemoveMethodCalled == 0 );
            Assert.IsTrue ( requestHandler.NoOfTimesAggregateNodeChangeMethodCalled > 0 );
            Assert.IsTrue ( requestHandler.NoOfTimesAggregateNodeAddMethodCalled == 0 );
        }
        public void Map_GivenWithCurrentDtosAndEditStatusAsUpdateWithExceptionThrownByChangeMethod_Succeeds()
        {
            var dtoCollection = new SoftDeleteObservableCollection<AggregateCollectionMapperTestDto> ();
            var dto = new AggregateCollectionMapperTestDto { EditStatus = EditStatus.Update };
            dtoCollection.CurrentItems.Add ( dto );

            var requestHandler = new AggregateCollectionMapperTestRequestHandler ();

            var aggregateRootCollectionMapper = new AggregateRootCollectionMapper
                <AggregateCollectionMapperTestDto, AggregateCollectionMapperTestAggregateRootEntity> ( dtoCollection );

            bool returnValue = aggregateRootCollectionMapper
                .FindCollectionEntity ( requestHandler.AggregateRootFind )
                .MapRemovedItem ( requestHandler.AggregateRootRemoveWithThrowException )
                .MapChangedItem ( requestHandler.AggregateRootChangeWithThrowException )
                .MapAddedItem ( requestHandler.AggregateRootAddWithThrowException )
                .Map ();

            Assert.IsTrue ( dtoCollection.CurrentItems[ 0 ].DataErrorInfoCollection.Count () > 0 );
            Assert.IsTrue ( requestHandler.NoOfTimesAggregateRootFindMethodCalled > 0 );
            Assert.IsTrue ( requestHandler.NoOfTimesAggregateRootAddWithThrowExceptionMethodCalled == 0 );
            Assert.IsTrue ( requestHandler.NoOfTimesAggregateRootChangeWithThrowExceptionMethodCalled > 0 );
            Assert.IsTrue ( requestHandler.NoOfTimesAggregateRootRemoveWithThrowExceptionMethodCalled == 0 );
            Assert.IsFalse ( returnValue );
        }
 public void AggregateRootChange(AggregateCollectionMapperTestDto aggregateNodeCollectionMapperTestDto, AggregateCollectionMapperTestAggregateRootEntity aggregateNodeCollectionMapperTestAggregateRootEntity)
 {
     NoOfTimesAggregateRootChangeMethodCalled++;
 }
 public void AggregateRootAdd(AggregateCollectionMapperTestDto aggregateNodeCollectionMapperTestDto)
 {
     NoOfTimesAggregateRootAddMethodCalled++;
 }
 public void AggregateNodeRemoveWithThrowException(AggregateCollectionMapperTestDto aggregateNodeCollectionMapperTestDto, AggregateCollectionMapperTestAggregateRootEntity aggregateNodeCollectionMapperTestAggregateRootEntity, AggregateCollectionMapperTestAggregateNodeEntity aggregateNodeCollectionMapperTestAggregateNodeEntity)
 {
     NoOfTimesAggregateNodeRemoveWithThrowExceptionMethodCalled++;
     throw new Exception();
 }
 public void AggregateRootAddWithThrowException(AggregateCollectionMapperTestDto aggregateNodeCollectionMapperTestDto)
 {
     NoOfTimesAggregateRootAddWithThrowExceptionMethodCalled++;
     throw new Exception();
 }