示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (entity == StateStaticComponent.m_currentEntity)
        {
            if (entity.GetComponent <BlockInfoComponent>().m_blockType == BlockType.Player)
            {
                if (skill == null)
                {
                    ShowSkill(StateStaticComponent.m_currentEntity);
                }

                if (Input.GetButtonDown("Bag"))
                {
                    if (bag != null)
                    {
                        CloseBag();
                    }
                    else
                    {
                        ShowBag(StateStaticComponent.m_currentEntity);
                    }
                }
                if (Input.GetButtonDown("ShowPropety"))
                {
                    if (propety.activeSelf)
                    {
                        propety.SetActive(false);
                    }
                    else
                    {
                        propety.SetActive(true);
                    }
                }
            }
        }
        else
        {
            entity = StateStaticComponent.m_currentEntity;
            CloseSkill();
            CloseBag();
        }

        if (Input.GetButtonDown("ShowTips"))
        {
            if (tips.activeSelf)
            {
                tips.SetActive(false);
            }
            else
            {
                tips.SetActive(true);
            }
        }
    }
示例#2
0
 // Update is called once per frame
 void Update()
 {
     if (StateStaticComponent.m_currentEntity != null)
     {
         if (StateStaticComponent.m_currentEntity.GetComponent <BlockInfoComponent>().m_blockType == BlockType.Player)
         {
             currentRole = StateStaticComponent.m_currentEntity;
         }
     }
     LoadInfo();
 }
        public void UpdateDistanceFieldTransformations(List <BasicEntity> entities, List <SignedDistanceField> sdfDefinitions, DeferredEnvironmentMapRenderModule environmentMapRenderModule, GraphicsDevice graphics, SpriteBatch spriteBatch, LightAccumulationModule lightAccumulationModule)
        {
            if (!GameSettings.sdf_draw)
            {
                return;
            }

            //First of all let's build the atlas
            UpdateAtlas(sdfDefinitions, graphics, spriteBatch, environmentMapRenderModule, lightAccumulationModule);

            int i = 0;

            for (var index = 0; index < entities.Count; index++)
            {
                BasicEntity entity = entities[index];

                if (entity.SignedDistanceField.IsUsed)
                {
                    _instanceInverseMatrixArray[i] = entity.WorldTransform.InverseWorld;
                    _instanceScaleArray[i]         = entity.WorldTransform.Scale;
                    _instanceSDFIndexArray[i]      = entity.SignedDistanceField.ArrayIndex;

                    i++;

                    if (i >= InstanceMaxCount)
                    {
                        break;
                    }
                }
            }

            _instancesCount = i;

            //TODO: Check for change

            //Submit
            //Instances

            _instanceInverseMatrixArrayParam.SetValue(_instanceInverseMatrixArray);
            _instanceScaleArrayParam.SetValue(_instanceScaleArray);
            _instanceSDFIndexArrayParam.SetValue(_instanceSDFIndexArray);
            _instancesCountParam.SetValue((float)_instancesCount);

            lightAccumulationModule.PointLightRenderModule.deferredPointLightParameter_InstanceInverseMatrix.SetValue(_instanceInverseMatrixArray);
            lightAccumulationModule.PointLightRenderModule.deferredPointLightParameter_InstanceScale.SetValue(_instanceScaleArray);
            lightAccumulationModule.PointLightRenderModule.deferredPointLightParameter_InstanceSDFIndex.SetValue(_instanceSDFIndexArray);
            lightAccumulationModule.PointLightRenderModule.deferredPointLightParameter_InstancesCount.SetValue((float)_instancesCount);

            environmentMapRenderModule.ParamInstanceInverseMatrix.SetValue(_instanceInverseMatrixArray);
            environmentMapRenderModule.ParamInstanceScale.SetValue(_instanceScaleArray);
            environmentMapRenderModule.ParamInstanceSDFIndex.SetValue(_instanceSDFIndexArray);
            environmentMapRenderModule.ParamInstancesCount.SetValue((float)_instancesCount);
        }
        public PageComponent(BasicEntity parent, Coord position) : base(true, false, true, true)
        {
            Parent    = parent;
            Position  = position;
            Component = (T)parent.GetConsoleComponent <T>();
            Name      = "Display for " + Component.Name;

            InitWindow();
            InitButton();
            InitBackground();
            InitTextSurface();
        }
示例#5
0
 public static List <string> ContainerTypeValidation(BasicEntity <string> selectedContainer)
 {
     if (selectedContainer == null || selectedContainer.Id < 0)
     {
         return new List <string> {
                    "Container type field is mandatory."
         }
     }
     ;
     return(null);
     //return new List<string> { "Container type is invalid." };
 }
示例#6
0
 public Match()
 {
     gameOperator         = new GameOperator();
     spriteBatch          = new SpriteBatch(Global.Instance.Graphics);
     returnToMenu         = new Button();
     continueGame         = new Button();
     setting              = new Button();
     save                 = new Button();
     pauseScreen          = new BasicEntity();
     playerOneInstruction = new TextEntity();
     playerTwoInstruction = new TextEntity();
 }
        public static List <string> BloodTypeValidation(BasicEntity <string> bloodType)
        {
            if (bloodType is null || bloodType.Id < 0)
            {
                return new List <string> {
                           "Blood type field is mandatory."
                }
            }
            ;

            return(null);
        }
示例#8
0
        /// <summary>
        /// Validates the county of the address.
        /// </summary>
        /// <param name="county">The county of the address.</param>
        /// <returns></returns>
        public static List <string> CountyValidation(BasicEntity <string> county)
        {
            if (county is null || county.Id < 0)
            {
                return new List <string> {
                           "County field is mandatory."
                }
            }
            ;

            return(null);
        }
        public static List <string> ContainerTypeValidation(BasicEntity <string> containerType)
        {
            if (containerType is null || containerType.Id < 0)
            {
                return new List <string> {
                           "Container type is mandatory."
                }
            }
            ;

            return(null);
        }
示例#10
0
        public static List <string> RHValidation(BasicEntity <string> rh)
        {
            if (rh is null || rh.Id < 0)
            {
                return new List <string> {
                           "RH field is mandatory."
                }
            }
            ;

            return(null);
        }
示例#11
0
    public void AddHackerAbility(BasicEntity entity)
    {
        AbilityComponent ability = entity.GetComponent <AbilityComponent> ();


//		ability.m_temporaryAbility.Add (ComponentType.Drone);
        ability.m_temporaryAbility.Add(ComponentType.Move);
        ability.m_temporaryAbility.Add(ComponentType.Attack);
        ability.m_temporaryAbility.Add(ComponentType.Knock);
        ability.m_temporaryAbility.Add(ComponentType.Input);
        ability.m_temporaryAbility.Add(ComponentType.Item);
    }
示例#12
0
    public void AddVeteranAbility(BasicEntity entity)
    {
        AbilityComponent ability = entity.GetComponent <AbilityComponent> ();


        ability.m_temporaryAbility.Add(ComponentType.Move);
        ability.m_temporaryAbility.Add(ComponentType.Attack);
        ability.m_temporaryAbility.Add(ComponentType.Knock);
        ability.m_temporaryAbility.Add(ComponentType.CheerUp);
        ability.m_temporaryAbility.Add(ComponentType.Input);
        ability.m_temporaryAbility.Add(ComponentType.Item);
    }
示例#13
0
        /// <summary>
        /// Determines whether the specified object is equal to the current <see cref="BasicEntity{Type}"/>.
        /// </summary>
        /// <param name="obj">The object o compare with the current <see cref="BasicEntity{Type}"/>.</param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            // If the object is null or has a different type
            if (obj is null || obj.GetType() != GetType())
            {
                return(false);
            }

            BasicEntity <Type> be = obj as BasicEntity <Type>;

            return(Value.Equals(be.Value));
        }
示例#14
0
        /// <summary>
        /// Validates the selected person name.
        /// </summary>
        /// <param name="personName">The selected person name.</param>
        /// <returns></returns>
        public static List <string> PersonNameValidation(BasicEntity <string> personName)
        {
            if (personName is null || personName.Id < 0)
            {
                return new List <string> {
                           "Person name field is mandatory."
                }
            }
            ;

            return(null);
        }
示例#15
0
        public static List <string> NotNullStringFieldValidation(BasicEntity <string> field, string message)
        {
            if (field is null || field.Id < 0)
            {
                return new List <string> {
                           message + " field is mandatory."
                }
            }
            ;

            return(null);
        }
示例#16
0
        public int TendencyToExplain;     // e

        public SpeechComponent(BasicEntity parent) : base(isUpdate: true, isKeyboard: false, isDraw: true, isMouse: false)
        {
            Parent               = parent;
            Name                 = "Speech";
            TendencyToMinimize   = Calculate.PercentValue();  // m
            TendencyToInvalidate = Calculate.PercentValue();  // i
            TendencyToDeny       = Calculate.PercentValue();  // d
            TendencyToJustify    = Calculate.PercentValue();  // j
            TendencyToArgue      = Calculate.PercentValue();  // a
            TendencyToDefend     = Calculate.PercentValue();  // d
            TendencyToExplain    = Calculate.PercentValue();  // e
        }
示例#17
0
        public Room()
        {
            var res = ResManager.Instance;

            playerInfo = new Character[]
            {
                new Character(),
                new Character(),
                new Character(),
                new Character()
            };

            player2Info = new Character[]
            {
                new Character(),
                new Character(),
                new Character(),
                new Character()
            };

            background = new BasicEntity();

            multiplayerTitle    = new TextEntity();
            multiplayerEnabled  = new TextEntity();
            multiplayerDisabled = new TextEntity();

            title           = new TextEntity();
            playerTypeTitle = new TextEntity();
            player          = new Character();
            previousPlayer  = new BasicEntity();
            nextPlayer      = new BasicEntity();

            player2TypeTitle = new TextEntity();
            player2          = new Character();
            previousPlayer2  = new BasicEntity();
            nextPlayer2      = new BasicEntity();


            fight        = new Button();
            returnToMenu = new Button();

            numOfBotsTitle    = new TextEntity();
            numOfBotsEntity   = new TextEntity();
            decreaseNumOfBots = new BasicEntity();
            increaseNumOfBots = new BasicEntity();

            map = new BasicEntity();



            previousMap = new BasicEntity();
            nextMap     = new BasicEntity();
        }
示例#18
0
        /// <summary>
        /// Validates the favourite donation center of the donor.
        /// </summary>
        /// <param name="donationCenter">The favourite donation center of the donor.</param>
        /// <returns></returns>
        public static List <string> FavouriteDonationCenterValidation(BasicEntity <string> donationCenter)
        {
            if (donationCenter.Id < 0)
            {
                return new List <string> {
                           "Favourite donation center is mandatory."
                }
            }
            ;

            return(null);
        }
    }
示例#19
0
        public void Setup()
        {
            _ui              = MockGame.Menu;
            _main            = _ui.MainOptions;
            _help            = _ui.HelpOptions;
            _settings        = _ui.SettingsOptions;
            _activePanels    = _ui.ActivePanels;
            _selector        = _ui.Player;
            _newGame         = _ui.NewGameOptions;
            _newGameAdvanced = _ui.NewGameAdvancedOptions;

            //Panels = new MenuPanel[] { main, help, settings, newGame, newGameAdvanced };
        }
示例#20
0
        /// <summary>
        /// Validates the selected donation center.
        /// </summary>
        /// <param name="donationCenter">The selected donation center.</param>
        /// <returns></returns>
        public static List <string> DonationCenterValidation(BasicEntity <string> donationCenter)
        {
            if (donationCenter is null || donationCenter.Id < 0)
            {
                return new List <string> {
                           "Donation center field is mandatory."
                }
            }
            ;

            return(null);
        }
    }
示例#21
0
    static public bool FriendInSight(BasicEntity entity)
    {
        MonitorComponent monitor = entity.GetComponent <MonitorComponent> ();

        foreach (BasicEntity e in StateStaticComponent.enemyActionList)
        {
            if (monitor.m_view.Contains(e.GetComponent <BlockInfoComponent> ().m_logicPosition))
            {
                return(true);
            }
        }
        return(false);
    }
示例#22
0
    void HealthPotion(BasicEntity entity)
    {
        entity.GetComponent <DeadComponent>().hp += 10;
        ItemComponent itemComp = entity.GetComponent <ItemComponent>();

        //移除瓶子
        itemComp.item.Remove(ItemType.HealthPotion);
        entity.GetComponent <ItemComponent>().current = ItemType.Null;
        entity.GetComponent <StateComponent>().AnimationStart();

        StateStaticComponent.m_currentSystemState = StateStaticComponent.SystemState.Action;
        entity.GetComponent <StateComponent>().Invoke("AnimationEnd", 1);
    }
示例#23
0
        public void Generate(BasicEntity entity)
        {
            //Extract all triangles
            //foreach (ModelMesh modelmesh in entity.Model.Meshes)
            //{
            //    foreach (ModelMeshPart part in modelmesh.MeshParts)
            //    {
            //        VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[part.VertexBuffer.VertexCount];
            //        part.VertexBuffer.GetData<VertexPositionNormalTexture>(vertices);

            //        ushort[] drawOrder = new ushort[part.IndexBuffer.IndexCount];
            //        part.IndexBuffer.GetData<ushort>(drawOrder);

            //        foreach (var vertex in vertices)
            //        {
            //            points.Add(vertex.Position);
            //        }
            //    }
            //}

            generateTris = Task.Factory.StartNew(() =>
            {
                int[] indices;
                ModelDataExtractor.GetVerticesAndIndicesFromModel(entity.Model, out vertices, out indices);

                triangles = new Triangle[indices.Length / 3];

                for (var index = 0; index < vertices.Length; index++)
                {
                    vertices[index] = Vector3.Transform(vertices[index], entity.WorldTransform.World);
                }

                int baseIndex = 0;
                for (var i = 0; i < triangles.Length; i++, baseIndex += 3)
                {
                    triangles[i].a = vertices[indices[baseIndex]];
                    triangles[i].b = vertices[indices[baseIndex + 1]];
                    triangles[i].c = vertices[indices[baseIndex + 2]];
                    //normal
                    triangles[i].n = Vector3.Cross(triangles[i].c - triangles[i].a, triangles[i].b - triangles[i].a);

                    triangles[i].ba = triangles[i].b - triangles[i].a;
                    triangles[i].cb = triangles[i].c - triangles[i].b;
                    triangles[i].ac = triangles[i].a - triangles[i].c;
                }
            });
            //for (var index = 0; index < points.Length; index++)
            //{
            //    points[index] = Vector3.Transform(points[index], entity.WorldTransform.World);
            //}
        }
示例#24
0
        public async Task <IActionResult> PostBasicEntity([FromBody] BasicEntity basicEntity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            int maxRowVersion = GetNewMaxRowVersion();

            basicEntity.RowVersion = maxRowVersion;
            _context.BasicEntity.Add(basicEntity);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBasicEntity", new { id = basicEntity.Id }, basicEntity));
        }
示例#25
0
    // Use this for initialization
    void Start()
    {
        entity = null;

        skill = null;
        bag   = null;
        UiManager.uiManager = this;
        ShowCondition();
        ShowPropety();
        ShowTips();
        ShowTurn();
        tips.SetActive(false);
        propety.SetActive(false);
    }
示例#26
0
        public void Update(List <BasicEntity> entities, GraphicsDevice graphics, DistanceFieldRenderModule distanceFieldRenderModule, FullScreenTriangle fullScreenTriangle, ref List <SignedDistanceField> sdfDefinitionsOut)
        {
            //First let's check which entities need building, if at all!
            sdfDefinitions.Clear();

            //This should preferably be a list of meshes that are in the scene, instead of a list of entities
            for (var index0 = 0; index0 < entities.Count; index0++)
            {
                BasicEntity entity = entities[index0];


                if (!entity.SignedDistanceField.IsUsed)
                {
                    continue;
                }

                if (entity.SignedDistanceField.NeedsToBeGenerated)
                {
                    GenerateDistanceFields(entity, graphics, distanceFieldRenderModule, fullScreenTriangle);
                }

                bool found = false;
                //Compile a list of all mbbs used right now
                for (var i = 0; i < sdfDefinitions.Count; i++)
                {
                    if (entity.SignedDistanceField == sdfDefinitions[i])
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    sdfDefinitions.Add(entity.SignedDistanceField);
                }
            }

            //Now for the model definitions
            for (var i = 0; i < sdfDefinitions.Count; i++)
            {
                if (GameSettings.sdf_regenerate)
                {
                    sdfDefinitions[i].NeedsToBeGenerated = true;
                }
            }

            GameSettings.sdf_regenerate = false;

            sdfDefinitionsOut = sdfDefinitions;
        }
示例#27
0
        /// <summary>
        /// Create a static physics mesh from a model and scale.
        /// </summary>
        /// <param name="entity"></param>
        private void AddStaticPhysics(BasicEntity entity)
        {
            BEPUutilities.Vector3[] vertices;
            int[] indices;
            ModelDataExtractor.GetVerticesAndIndicesFromModel(entity.Model, out vertices, out indices);
            var mesh = new StaticMesh(vertices, indices,
                                      new AffineTransform(
                                          new BEPUutilities.Vector3(entity.Scale.X, entity.Scale.Y, entity.Scale.Z),
                                          Quaternion.CreateFromRotationMatrix(MathConverter.Convert(entity.RotationMatrix)),
                                          MathConverter.Convert(entity.Position)));

            entity.StaticPhysicsObject = mesh;
            _physicsSpace.Add(mesh);
        }
示例#28
0
    public Heretic(BasicEntity entity) : base(entity)
    {
        m_enemeyTyep = PropertyComponent.CharacterType.Heretic;

        m_decisions = new Dictionary <AIComponent.Decision, BasicDecision <Heretic> > ();
        //根据枚举获取对应实例
        foreach (AIComponent.Decision decision in containDecision)
        {
            m_decisions.Add(decision, CreateDecision(decision));
        }
        //默认状态是巡逻状态
        m_currentDecision  = m_decisions [AIComponent.Decision.Patrol];
        m_previsousDecsion = m_currentDecision;
    }
示例#29
0
    //增加临时组件
    public bool AddTemporaryComponent(BasicEntity entity)
    {
        AbilityComponent ability = entity.GetComponent <AbilityComponent> ();

        if (ability == null)
        {
            return(false);
        }
        foreach (ComponentType c in ability.m_temporaryAbility)
        {
            entity.AddComponent(c);
        }
        return(true);
    }
示例#30
0
    public void ShowSkill(BasicEntity entity)
    {
        if (skill != null)
        {
            return;
        }
        skill = (GameObject)Resources.Load("Prefabs/UI/Panel/UISkill");
        skill = Instantiate(skill);
        skill.transform.SetParent(gameObject.transform);
        skill.transform.localPosition = skill.transform.position;
        skill.transform.localScale    = Vector3.one;
        UiSkill uiSkill = skill.transform.GetChild(1).gameObject.AddComponent <UiSkill>();

        uiSkill.AddClick(entity);
    }
示例#31
0
        public async Task RedisSetMock_CanSetAndFetch()
        {
            // Arrange
            var expected = new BasicEntity
            {
                Id = "RedisSetMock_CanSetAndFetch"
            };

            // Act
            await _context.Entity.InsertAsync(expected);
            var returned = await _context.Entity.FetchAsync(expected.Id);

            // Assert
            Assert.Equal(expected.Id, returned.Id);

            // Cleanup
            await _context.Entity.DeleteAsync(expected);
        }
示例#32
0
        public async Task RedisSetMock_CanDelete()
        {
            // Arrange
            var expected = new BasicEntity
            {
                Id = "RedisSetMock_CanDelete"
            };

            // Act
            await _context.Entity.InsertAsync(expected);
            var returned = await _context.Entity.FetchAsync(expected.Id);
            await _context.Entity.DeleteAsync(expected);
            var returnedAfterDelete = await _context.Entity.FetchAsync(expected.Id);


            // Assert
            Assert.Equal(expected.Id, returned.Id);
            Assert.Null(returnedAfterDelete);
        }
        public void EntityProperties_SerializedClass_CanConvertToEntityProperties()
        {
            // Arrange
            var expectedId = "SomeId";
            var ob = new BasicEntity
            {
                Id = expectedId
            };
            var data = _serializer.PackSingleObject(ob);

            // Act
            var entityProperties = new EntityProperties(data);
            var containsId = entityProperties.ContainsKey("Id");
            string returnedId;
            var isString = entityProperties["Id"].TryGet(out returnedId);

            // Assert
            Assert.True(containsId);
            Assert.True(isString);
            Assert.Equal(expectedId, returnedId);
        }
示例#34
0
        public async Task RedisSetMock_Update_CannotUpdateChangedItem()
        {
            // Arrange
            var entity = new BasicEntity
            {
                Id = "RedisSetMock_Update_CannotUpdateChangedItem",
                StringValue = "Original"
            };

            // Act
            await _context.Entity.InsertOrReplaceAsync(entity);

            var retrieved = await _context.Entity.FetchAsync(entity.Id);
            retrieved.StringValue = "Replacement";
            var canUpdate = await _context.Entity.UpdateAsync(retrieved);

            entity.StringValue = "New Replacement";
            var canUpdateChangedItem = await _context.Entity.UpdateAsync(entity);
            var returned = await _context.Entity.FetchAsync(entity.Id);

            // Assert
            Assert.True(canUpdate);
            Assert.False(canUpdateChangedItem);
            Assert.Equal(retrieved.Id, returned.Id);
            Assert.Equal(retrieved.StringValue, returned.StringValue);

            // Cleanup
            await _context.Entity.DeleteAsync(entity);
        }
示例#35
0
        public async Task RedisSetMock_InsertOrReplace_CanOverwrite()
        {
            // Arrange
            var id = "RedisSetMock_InsertOrReplace_CanOverwrite";
            var entityOld = new BasicEntity
            {
                Id = id,
                StringValue = "Original"
            };
            var entityNew = new BasicEntity
            {
                Id = id,
                StringValue = "Replacement"
            };

            // Act
            await _context.Entity.InsertOrReplaceAsync(entityOld);
            await _context.Entity.InsertOrReplaceAsync(entityNew);
            var returned = await _context.Entity.FetchAsync(id);

            // Assert
            Assert.Equal(entityNew.Id, returned.Id);
            Assert.Equal(entityNew.StringValue, returned.StringValue);

            // Cleanup
            await _context.Entity.DeleteAsync(entityNew);
        }
示例#36
0
        public async Task RedisSetMock_Update_CannotInsertMissingItem()
        {
            // Arrange
            var entity = new BasicEntity
            {
                Id = "RedisSetMock_Update_CannotInsertMissingItem"
            };

            // Act
            var success = await _context.Entity.UpdateAsync(entity);
            var returned = await _context.Entity.FetchAsync(entity.Id);

            // Assert
            Assert.False(success, "Update created missing item");
            Assert.Null(returned);

            // Cleanup
            await _context.Entity.DeleteAsync(entity);
        }
示例#37
0
 public void Setup()
 {
     _matcher = new BasicMatcher();
     _be = new BasicEntity { Id = Guid.NewGuid(), Name = "Dillon", Number = 69 };
     _bm = new BasicModel { id = Guid.NewGuid(), name = "Dillon", number = 69 };
 }
示例#38
0
        public async Task RedisSetMock_Insert_CannotOverwrite()
        {
            // Arrange
            var entity = new BasicEntity
            {
                Id = "RedisSetMock_Insert_CannotOverwrite"
            };

            // Act
            var canInsert = await _context.Entity.InsertAsync(entity);
            var canOverwrite = await _context.Entity.InsertAsync(entity);

            // Assert
            Assert.True(canInsert, "Insert not successful");
            Assert.False(canOverwrite, "Can Overwrite");

            // Cleanup
            await _context.Entity.DeleteAsync(entity);
        }
示例#39
0
        public async Task RedisSetMock_Replace_CannotInsertItem()
        {
            // Arrange
            var entity = new BasicEntity
            {
                Id = "RedisSet_Replace_CannotInsertItem",
                StringValue = "Original"
            };

            // Act
            var success = await _context.Entity.ReplaceAsync(entity);
            var returned = await _context.Entity.FetchAsync(entity.Id);

            // Assert
            Assert.False(success);
            Assert.Null(returned);
        }
示例#40
0
        public void RedisSetMock_Migrate_MigrationFunctionsGetsCalled()
        {
            // Arrange
            var entity = new BasicEntity
            {
                Id = "RedisSet_Migrate_MigrationFunctionsGetsCalled",
                StringValue = "SomeValue"
            };

            // Act
            var result = RedisSetMock<BasicEntityVersioned>.MigrateFrom(entity);

            // Assert
            Assert.Equal(entity.Id, result.Id);
            Assert.Equal(entity.StringValue, result.StringValueRename);
            Assert.Equal("Prefix_" + entity.StringValue, result.StringValuePrefixed);
            Assert.Equal(entity.StringValue + "_Suffix", result.StringValueSuffixed);
        }
示例#41
0
        public async Task RedisSetMock_Replace_CanUpdateExistingItem()
        {
            // Arrange
            var oldEntity = new BasicEntity
            {
                Id = "RedisSet_Replace_CanUpdateExistingItem",
                StringValue = "Original"
            };

            var newEntity = new BasicEntity
            {
                Id = "RedisSet_Replace_CanUpdateExistingItem",
                StringValue = "Repalcement"
            };

            // Act
            await _context.Entity.InsertOrReplaceAsync(oldEntity);
            var success = await _context.Entity.ReplaceAsync(newEntity);
            var returned = await _context.Entity.FetchAsync(oldEntity.Id);

            // Assert
            Assert.True(success);
            Assert.Equal(newEntity.Id, returned.Id);
            Assert.Equal(newEntity.StringValue, returned.StringValue);

            // Cleanup
            await _context.Entity.DeleteAsync(oldEntity);
        }