Esempio n. 1
0
        public void Handle_All_With_Data()
        {
            #region Prepare
            var inputObject = new InputObject()
            {
                Entities = new List <Entity>()
                {
                    new Entity()
                    {
                        ID   = 1,
                        Name = "Something 1"
                    },
                    new Entity()
                    {
                        ID   = 2,
                        Name = "Something 2"
                    },
                    new Entity()
                    {
                        ID   = 3,
                        Name = "Something 3"
                    },
                },
                Links = new List <Link>()
                {
                    new Link()
                    {
                        FromEntityId = 1,
                        ToEntityId   = 2
                    },

                    new Link()
                    {
                        FromEntityId = 1,
                        ToEntityId   = 3
                    },

                    new Link()
                    {
                        FromEntityId = 2,
                        ToEntityId   = 3
                    }
                }
            };

            var originalEntity     = _cloneProcessor.GetInitialEntity(inputObject, 2);
            var originalEntityCopy = _cloneProcessor.CreateCloneAndAssignId(inputObject, originalEntity);
            #endregion

            #region Act
            _cloneProcessor.HandleAllTo(inputObject, originalEntity, originalEntityCopy);
            #endregion

            #region Assert
            Assert.Equal(4, inputObject.Links.Count);
            #endregion
        }
        public void Entity_Exist_Flow()
        {
            #region Prepare
            var inputObject = new InputObject()
            {
                Entities = new List <Entity>()
                {
                    new Entity()
                    {
                        ID   = 1,
                        Name = "Something 1"
                    },
                    new Entity()
                    {
                        ID   = 2,
                        Name = "Something 2"
                    },
                    new Entity()
                    {
                        ID   = 3,
                        Name = "Something 3"
                    },
                }
            };

            var originalEntity = inputObject.Entities.ElementAt(1);
            #endregion

            #region Act
            var entity = _cloneProcessor.CreateCloneAndAssignId(inputObject, originalEntity);
            #endregion

            #region Assert
            Assert.NotNull(entity);
            Assert.Equal(4, entity.ID);
            Assert.Equal(4, inputObject.Entities.Count);
            #endregion
        }