public void Can_get_and_set_current_value_generic() { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky = new Chunky(); context.AddRange(chunky, cherry); var reference = context.Entry(chunky).Reference(e => e.Garcia); Assert.Null(reference.CurrentValue); reference.CurrentValue = cherry; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); Assert.Equal(cherry.Id, chunky.GarciaId); Assert.Same(cherry, reference.CurrentValue); Assert.Same(reference.TargetEntry.GetInfrastructure(), context.Entry(cherry).GetInfrastructure()); reference.CurrentValue = null; Assert.Null(chunky.Garcia); Assert.Empty(cherry.Monkeys); Assert.Null(chunky.GarciaId); Assert.Null(reference.CurrentValue); Assert.Null(reference.TargetEntry); } }
public void Can_get_and_set_current_value_start_tracking_generic() { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky = new Chunky(); context.Add(chunky); var reference = context.Entry(chunky).Reference(e => e.Garcia); Assert.Null(reference.CurrentValue); reference.CurrentValue = cherry; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); Assert.Equal(cherry.Id, chunky.GarciaId); Assert.Same(cherry, reference.CurrentValue); Assert.Equal(EntityState.Added, context.Entry(cherry).State); Assert.Equal(EntityState.Added, context.Entry(chunky).State); reference.CurrentValue = null; Assert.Null(chunky.Garcia); Assert.Empty(cherry.Monkeys); Assert.Null(chunky.GarciaId); Assert.Null(reference.CurrentValue); Assert.Equal(EntityState.Added, context.Entry(cherry).State); Assert.Equal(EntityState.Added, context.Entry(chunky).State); } }
public void Can_get_and_set_current_value_reference() { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky = new Chunky(); context.AddRange(chunky, cherry); var reference = context.Entry(chunky).Navigation("Garcia"); Assert.Null(reference.CurrentValue); reference.CurrentValue = cherry; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); Assert.Equal(cherry.Id, chunky.GarciaId); Assert.Same(cherry, reference.CurrentValue); reference.CurrentValue = null; Assert.Null(chunky.Garcia); Assert.Empty(cherry.Monkeys); Assert.Null(chunky.GarciaId); Assert.Null(reference.CurrentValue); } }
public void IsModified_can_set_fk_to_modified_collection() { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky1 = new Chunky { Garcia = cherry }; var chunky2 = new Chunky { Garcia = cherry }; cherry.Monkeys = new List <Chunky> { chunky1, chunky2 }; context.AttachRange(cherry, chunky1, chunky2); var collection = context.Entry(cherry).Navigation("Monkeys"); Assert.False(collection.IsModified); collection.IsModified = true; Assert.True(collection.IsModified); Assert.True(context.Entry(chunky1).Property(e => e.GarciaId).IsModified); Assert.True(context.Entry(chunky2).Property(e => e.GarciaId).IsModified); collection.IsModified = false; Assert.False(collection.IsModified); Assert.False(context.Entry(chunky1).Property(e => e.GarciaId).IsModified); Assert.False(context.Entry(chunky2).Property(e => e.GarciaId).IsModified); Assert.Equal(EntityState.Unchanged, context.Entry(chunky1).State); Assert.Equal(EntityState.Unchanged, context.Entry(chunky2).State); } }
public void Can_get_and_set_current_value_generic_attached() { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky = new Chunky(); context.AttachRange(chunky, cherry); var reference = context.Entry(chunky).Reference(e => e.Garcia); Assert.Null(reference.CurrentValue); reference.CurrentValue = cherry; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); Assert.Equal(cherry.Id, chunky.GarciaId); Assert.Same(cherry, reference.CurrentValue); Assert.Equal(EntityState.Unchanged, context.Entry(cherry).State); Assert.Equal(EntityState.Modified, context.Entry(chunky).State); Assert.True(context.Entry(chunky).Property(e => e.GarciaId).IsModified); reference.CurrentValue = null; Assert.Null(chunky.Garcia); Assert.Empty(cherry.Monkeys); Assert.Null(chunky.GarciaId); Assert.Null(reference.CurrentValue); Assert.Equal(EntityState.Unchanged, context.Entry(cherry).State); Assert.Equal(EntityState.Modified, context.Entry(chunky).State); Assert.True(context.Entry(chunky).Property(e => e.GarciaId).IsModified); } }
public void Can_get_and_set_current_value_generic_not_tracked() { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky = new Chunky(); var collection = context.Entry(cherry).Collection(e => e.Monkeys); Assert.Null(collection.CurrentValue); collection.CurrentValue = new List <Chunky> { chunky }; Assert.Null(chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); Assert.Null(chunky.GarciaId); Assert.Same(chunky, collection.CurrentValue.Single()); collection.CurrentValue = null; Assert.Null(chunky.Garcia); Assert.Null(cherry.Monkeys); Assert.Null(chunky.GarciaId); Assert.Null(collection.CurrentValue); } }
public void Can_get_and_set_current_value() { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky = new Chunky(); context.AddRange(chunky, cherry); var collection = context.Entry(cherry).Collection("Monkeys"); Assert.Null(collection.CurrentValue); collection.CurrentValue = new List <Chunky> { chunky }; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); Assert.Equal(cherry.Id, chunky.GarciaId); Assert.Same(chunky, collection.CurrentValue.Cast <Chunky>().Single()); collection.CurrentValue = null; Assert.Null(chunky.Garcia); Assert.Null(cherry.Monkeys); Assert.Null(chunky.GarciaId); Assert.Null(collection.CurrentValue); } }
public void Can_get_and_set_current_value_start_tracking_generic() { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky = new Chunky(); context.Add(cherry); var collection = context.Entry(cherry).Collection(e => e.Monkeys); Assert.Null(collection.CurrentValue); collection.CurrentValue = new List <Chunky> { chunky }; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); Assert.Equal(cherry.Id, chunky.GarciaId); Assert.Same(chunky, collection.CurrentValue.Single()); Assert.Equal(EntityState.Added, context.Entry(cherry).State); Assert.Equal(EntityState.Added, context.Entry(chunky).State); collection.CurrentValue = null; Assert.Null(chunky.Garcia); Assert.Null(cherry.Monkeys); Assert.Null(chunky.GarciaId); Assert.Null(collection.CurrentValue); Assert.Equal(EntityState.Added, context.Entry(cherry).State); Assert.Equal(EntityState.Added, context.Entry(chunky).State); } }
public void IsModified_tracks_state_of_FK_property_principal() { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky1 = new Chunky { Id = 1, Garcia = cherry }; var chunky2 = new Chunky { Id = 2, Garcia = cherry }; cherry.Monkeys = new List <Chunky> { chunky1, chunky2 }; context.AttachRange(cherry, chunky1, chunky2); var collection = context.Entry(cherry).Collection(e => e.Monkeys); Assert.False(collection.IsModified); context.Entry(chunky1).State = EntityState.Modified; Assert.True(collection.IsModified); context.Entry(chunky1).State = EntityState.Unchanged; Assert.False(collection.IsModified); } }
public void Can_get_and_set_current_value_generic() { using var context = new FreezerContext(); var cherry = new Cherry(); var chunky = new Chunky(); context.AddRange(chunky, cherry); var collection = context.Entry(cherry).Collection(e => e.Monkeys); Assert.Null(collection.CurrentValue); collection.CurrentValue = new List <Chunky> { chunky }; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); Assert.Equal(cherry.Id, chunky.GarciaId); Assert.Same(chunky, collection.CurrentValue.Single()); Assert.Same(collection.FindEntry(chunky).GetInfrastructure(), context.Entry(chunky).GetInfrastructure()); collection.CurrentValue = null; Assert.Null(chunky.Garcia); Assert.Null(cherry.Monkeys); Assert.Null(chunky.GarciaId); Assert.Null(collection.CurrentValue); Assert.Null(collection.FindEntry(chunky)); }
public void IsModified_tracks_state_of_FK_property() { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky = new Chunky { Garcia = cherry }; cherry.Monkeys = new List <Chunky> { chunky }; context.AttachRange(cherry, chunky); var reference = context.Entry(chunky).Reference(e => e.Garcia); Assert.False(reference.IsModified); chunky.GarciaId = null; context.ChangeTracker.DetectChanges(); Assert.True(reference.IsModified); context.Entry(chunky).State = EntityState.Unchanged; Assert.False(reference.IsModified); } }
public void IsModified_can_set_fk_to_modified() { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky = new Chunky { Garcia = cherry }; cherry.Monkeys = new List <Chunky> { chunky }; context.AttachRange(cherry, chunky); var entityEntry = context.Entry(chunky); var reference = entityEntry.Reference(e => e.Garcia); Assert.False(reference.IsModified); reference.IsModified = true; Assert.True(reference.IsModified); Assert.True(entityEntry.Property(e => e.GarciaId).IsModified); reference.IsModified = false; Assert.False(reference.IsModified); Assert.False(entityEntry.Property(e => e.GarciaId).IsModified); Assert.Equal(EntityState.Unchanged, entityEntry.State); } }
public void Can_get_and_set_current_value_not_tracked_generic() { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky = new Chunky(); var reference = context.Entry(chunky).Reference(e => e.Garcia); Assert.Null(reference.CurrentValue); reference.CurrentValue = cherry; Assert.Same(cherry, chunky.Garcia); Assert.Null(cherry.Monkeys); Assert.Null(chunky.GarciaId); Assert.Same(cherry, reference.CurrentValue); reference.CurrentValue = null; Assert.Null(chunky.Garcia); Assert.Null(cherry.Monkeys); Assert.Null(chunky.GarciaId); Assert.Null(reference.CurrentValue); } }
public void Can_get_and_set_current_value(bool useExplicitPk) { using var context = useExplicitPk ? new ExplicitFreezerContext() : new FreezerContext(); var cherry = new Cherry(); var chunky = new Chunky(); context.AddRange(chunky, cherry); var collection = context.Entry(cherry).Collection("Chunkies"); var inverseCollection = context.Entry(chunky).Collection("Cherries"); Assert.Null(collection.CurrentValue); collection.CurrentValue = new List <Chunky> { chunky }; Assert.Same(chunky, cherry.Chunkies.Single()); Assert.Same(cherry, chunky.Cherries.Single()); Assert.Same(chunky, collection.CurrentValue.Cast <Chunky>().Single()); Assert.Same(cherry, inverseCollection.CurrentValue.Cast <Cherry>().Single()); Assert.Same(collection.FindEntry(chunky).GetInfrastructure(), context.Entry(chunky).GetInfrastructure()); collection.CurrentValue = null; Assert.Empty(chunky.Cherries); Assert.Null(cherry.Chunkies); Assert.Null(collection.CurrentValue); Assert.Empty(inverseCollection.CurrentValue); Assert.Null(collection.FindEntry(chunky)); }
public void IsModified_tracks_adding_items_to_the_join_table(bool useExplicitPk) { using var context = useExplicitPk ? new ExplicitFreezerContext() : new FreezerContext(); var cherry1 = new Cherry { Id = 1 }; var cherry2 = new Cherry { Id = 2 }; var chunky1 = new Chunky { Id = 1 }; var chunky2 = new Chunky { Id = 2 }; AttachGraph(context, cherry1, cherry2, chunky1, chunky2); var relatedToCherry1 = context.Entry(cherry1).Collection(e => e.Chunkies); var relatedToCherry2 = context.Entry(cherry2).Collection(e => e.Chunkies); var relatedToChunky1 = context.Entry(chunky1).Collection(e => e.Cherries); var relatedToChunky2 = context.Entry(chunky2).Collection(e => e.Cherries); cherry2.Chunkies.Add(chunky1); context.ChangeTracker.DetectChanges(); Assert.False(relatedToCherry1.IsModified); Assert.True(relatedToCherry2.IsModified); Assert.True(relatedToChunky1.IsModified); Assert.False(relatedToChunky2.IsModified); }
public void Can_get_and_set_current_value_generic_not_tracked(bool useExplicitPk) { using var context = useExplicitPk ? new ExplicitFreezerContext() : new FreezerContext(); var cherry = new Cherry(); var chunky = new Chunky(); var collection = context.Entry(cherry).Collection(e => e.Chunkies); var inverseCollection = context.Entry(chunky).Collection(e => e.Cherries); Assert.Null(collection.CurrentValue); collection.CurrentValue = new List <Chunky> { chunky }; Assert.Same(chunky, cherry.Chunkies.Single()); Assert.Null(chunky.Cherries); Assert.Same(chunky, collection.CurrentValue.Single()); Assert.Null(inverseCollection.CurrentValue); collection.CurrentValue = null; Assert.Null(chunky.Cherries); Assert.Null(cherry.Chunkies); Assert.Null(collection.CurrentValue); Assert.Null(inverseCollection.CurrentValue); }
public void Can_get_and_set_current_value_collection() { using var context = new FreezerContext(); var cherry = new Cherry(); var chunky = new Chunky(); context.AddRange(chunky, cherry); var collection = context.Entry(cherry).Member("Chunkies"); var inverseCollection = context.Entry(chunky).Member("Cherries"); Assert.Null(collection.CurrentValue); Assert.Null(inverseCollection.CurrentValue); collection.CurrentValue = new List <Chunky> { chunky }; Assert.Same(cherry, chunky.Cherries.Single()); Assert.Same(chunky, cherry.Chunkies.Single()); Assert.Equal(cherry, ((ICollection <Cherry>)inverseCollection.CurrentValue).Single()); Assert.Same(chunky, ((ICollection <Chunky>)collection.CurrentValue).Single()); collection.CurrentValue = null; Assert.Empty(chunky.Cherries); Assert.Null(cherry.Chunkies); Assert.Empty((IEnumerable)inverseCollection.CurrentValue); Assert.Null(collection.CurrentValue); }
public void Can_get_metadata_generic() { using var context = new FreezerContext(); var entity = new Cherry(); context.Add(entity); Assert.Equal("Monkeys", context.Entry(entity).Collection(e => e.Monkeys).Metadata.Name); }
public void Can_get_back_reference_generic() { using var context = new FreezerContext(); var entity = new Cherry(); context.Add(entity); var entityEntry = context.Entry(entity); Assert.Same(entityEntry.Entity, entityEntry.Collection(e => e.Monkeys).EntityEntry.Entity); }
public void Can_get_metadata_collection() { using var context = new FreezerContext(); var entity = new Cherry(); context.Add(entity); Assert.Equal("Chunkies", context.Entry(entity).Member("Chunkies").Metadata.Name); }
public void Can_get_back_reference_collection() { using var context = new FreezerContext(); var entity = new Cherry(); var entityEntry = context.Add(entity); Assert.Same(entityEntry.Entity, entityEntry.Member("Chunkies").EntityEntry.Entity); }
private void SpawnCh() { Cherry cherryClone = (Cherry)Instantiate(cherryPrefab, cherryParent.transform.position, transform.rotation); float cherrySize = 0.3f; //cherryClone.transform.SetParent (cherryParent.transform); //gibt Parent cherryClone.transform.localScale = new Vector3(cherrySize, cherrySize, 0); cherryClone.transform.localPosition = new Vector3(UnityEngine.Random.Range(-5f, +5f), cherryParent.transform.position.y, 5f); //setze lokale Pos cherryClone.GetComponent <Rigidbody2D> ().velocity = new Vector2(0, UnityEngine.Random.Range(-10, -1)); }
public void Can_get_metadata_collection() { using (var context = new FreezerContext()) { var entity = new Cherry(); context.Add(entity); Assert.Equal("Monkeys", context.Entry(entity).Navigation("Monkeys").Metadata.Name); } }
public void Can_get_metadata_generic(bool useExplicitPk) { using var context = useExplicitPk ? new ExplicitFreezerContext() : new FreezerContext(); var entity = new Cherry(); context.Add(entity); Assert.Equal("Chunkies", context.Entry(entity).Collection(e => e.Chunkies).Metadata.Name); }
public void IsModified_can_set_fk_to_modified_principal_with_Added_or_Deleted_dependents( EntityState principalState, EntityState dependentState) { using (var context = new FreezerContext()) { var cherry = new Cherry(); var chunky1 = new Chunky { Id = 1, Garcia = cherry }; var chunky2 = new Chunky { Id = 2, Garcia = cherry }; cherry.Monkeys = new List <Chunky> { chunky1, chunky2 }; context.Entry(cherry).State = principalState; context.Entry(chunky1).State = dependentState; context.Entry(chunky2).State = dependentState; var collection = context.Entry(cherry).Collection(e => e.Monkeys); Assert.True(collection.IsModified); collection.IsModified = false; Assert.True(collection.IsModified); Assert.False(context.Entry(chunky1).Property(e => e.GarciaId).IsModified); Assert.False(context.Entry(chunky2).Property(e => e.GarciaId).IsModified); collection.IsModified = true; Assert.True(collection.IsModified); Assert.False(context.Entry(chunky1).Property(e => e.GarciaId).IsModified); Assert.False(context.Entry(chunky2).Property(e => e.GarciaId).IsModified); Assert.Equal(dependentState, context.Entry(chunky1).State); Assert.Equal(dependentState, context.Entry(chunky2).State); if (dependentState == EntityState.Deleted) { context.Entry(chunky1).State = EntityState.Detached; context.Entry(chunky2).State = EntityState.Detached; } else { context.Entry(chunky1).State = EntityState.Unchanged; context.Entry(chunky2).State = EntityState.Unchanged; } Assert.False(collection.IsModified); Assert.False(context.Entry(chunky1).Property(e => e.GarciaId).IsModified); Assert.False(context.Entry(chunky2).Property(e => e.GarciaId).IsModified); } }
public void Can_get_back_reference_collection() { using (var context = new FreezerContext()) { var entity = new Cherry(); context.Add(entity); var entityEntry = context.Entry(entity); Assert.Same(entityEntry.Entity, entityEntry.Navigation("Monkeys").EntityEntry.Entity); } }
// Use this for initialization void Start() { r2 = gameObject.GetComponent <Rigidbody2D>(); anim = gameObject.GetComponent <Animator>(); gm = GameObject.FindGameObjectWithTag("Gamemaster").GetComponent <Gamemaster>(); newhealth = maxhealth; healthBar.SetMaxHealth(newhealth); cherry = gameObject.GetComponent <Cherry>(); gem = gameObject.GetComponent <Gem>(); location = transform.position; }
private void PlacementObject() { Random random = new Random(); MyHunter = new Bear(300, new Point { X = random.Next(PlayerHero.Position.X + 2, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 2, PlayerField.Height) }, 20); MyHunter = new Wolf(200, new Point { X = random.Next(PlayerHero.Position.X + 2, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 2, PlayerField.Height) }, 15); MyBarrier = new Tree(new Point { X = random.Next(PlayerHero.Position.X + 1, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 3, PlayerField.Height) }, 100); MyBarrier = new Hole(new Point { X = random.Next(PlayerHero.Position.X + 1, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 3, PlayerField.Height) }, 100); MyBonus = new Apple(new Point { X = random.Next(PlayerHero.Position.X + 1, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 3, PlayerField.Height) }, 30); MyBonus = new Cherry(new Point { X = random.Next(PlayerHero.Position.X + 1, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 3, PlayerField.Height) }, 20); MyBonus = new Carrot(new Point { X = random.Next(PlayerHero.Position.X + 1, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 3, PlayerField.Height) }, 50); }
public void Can_get_back_reference_generic(bool useExplicitPk) { using var context = useExplicitPk ? new ExplicitFreezerContext() : new FreezerContext(); var entity = new Cherry(); context.Add(entity); var entityEntry = context.Entry(entity); Assert.Same(entityEntry.Entity, entityEntry.Collection(e => e.Chunkies).EntityEntry.Entity); }
//End Knockback người chơi chạm quái //Coins public void OnTriggerEnter2D(Collider2D col) { Cherry cherry = col.gameObject.GetComponent <Cherry>(); Gem gem = col.gameObject.GetComponent <Gem>(); if (col.CompareTag("Coins"))//Chạm trái cây có tag là coins { //gm.points += 100;// cộng điểm //cherry.Boom();//thay đổi animation nổ //sound.Playsound("coins"); if (checkGem == true) { StartCoroutine(delayboom()); gm.points += 100; // cộng điểm cherry.Boom(); //thay đổi animation nổ sound.Playsound("coins"); } } if (col.CompareTag("CoinsDiamond")) { //gm.points += 300; //gem.Boom(); //sound.Playsound("coins"); if (checkGem == true) { StartCoroutine(delayboom()); gm.points += 300; gem.Boom(); sound.Playsound("coins"); } } //checkpoint if (col.CompareTag("CheckPoint")) { location = col.transform.position; } if (col.CompareTag("landDead")) { transform.position = location; } //tăng tốc độ di chuyển khi chạm giày if (col.CompareTag("Shoe")) { sound.Playsound("powerup"); Destroy(col.gameObject); maxspeed = 4f; speed = 70f; StartCoroutine(timecount(20)); } }
static void GenerateCherry() { /* Тук се генерират черешките на точно зададени координати в 4-те ъгъла * */ cherryTokens[0] = new Cherry(1, 1); cherryTokens[1] = new Cherry(1, MazeHeight-1); cherryTokens[2] = new Cherry(MazeWidth - 2, 1); cherryTokens[3] = new Cherry(MazeWidth - 2, MazeHeight - 1); DrawCherry(); }