当前位置: 首页>>代码示例>>C#>>正文


C# Banana类代码示例

本文整理汇总了C#中Banana的典型用法代码示例。如果您正苦于以下问题:C# Banana类的具体用法?C# Banana怎么用?C# Banana使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Banana类属于命名空间,在下文中一共展示了Banana类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_read_and_write_values

        public void Can_read_and_write_values()
        {
            var originalBananas = new List<Banana>();
            var originalBanana = new Banana();
            var entity = new Banana { Id = 77, Fk = 78, TopBanana = originalBanana, LesserBananas = originalBananas };
            var sidecar = CreateSidecar(CreateInternalEntry(entity));

            Assert.Equal(78, sidecar[FkProperty]);
            Assert.Same(originalBananas, sidecar[CollectionNavigation]);
            Assert.Same(originalBanana, sidecar[ReferenceNavigation]);

            var newBananas = new List<Banana>();
            var newBanana = new Banana();
            sidecar[FkProperty] = 79;
            sidecar[CollectionNavigation] = newBananas;
            sidecar[ReferenceNavigation] = newBanana;

            Assert.Equal(79, sidecar[FkProperty]);
            Assert.Same(newBananas, sidecar[CollectionNavigation]);
            Assert.Same(newBanana, sidecar[ReferenceNavigation]);

            Assert.Equal(77, entity.Id);
            Assert.Equal(78, entity.Fk);
            Assert.Same(originalBananas, entity.LesserBananas);
            Assert.Same(originalBanana, entity.TopBanana);
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:26,代码来源:RelationshipsSnapshotTest.cs

示例2: Returns_null_if_key_value_is_null

        public void Returns_null_if_key_value_is_null()
        {
            var model = BuildModel();
            var type = model.GetEntityType(typeof(Banana));

            var entity = new Banana { P1 = 7, P2 = null };
            var entry = new ClrStateEntry(TestHelpers.CreateContextConfiguration(model), type, entity);

            Assert.Equal(EntityKey.NullEntityKey, new SimpleEntityKeyFactory<string>().Create(type, new[] { type.GetProperty("P2") }, entry));
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:10,代码来源:SimpleEntityKeyFactoryTest.cs

示例3: Returns_null_if_key_value_is_null

        public void Returns_null_if_key_value_is_null()
        {
            var model = BuildModel();
            var type = model.GetEntityType(typeof(Banana));
            var stateManager = TestHelpers.Instance.CreateContextServices(model).GetRequiredService<IStateManager>();

            var entity = new Banana { P1 = 7, P2 = null };
            var entry = stateManager.GetOrCreateEntry(entity);

            Assert.Equal(EntityKey.InvalidEntityKey, new SimpleEntityKeyFactory<int>(0).Create(type, new[] { type.GetProperty("P2") }, entry));
        }
开发者ID:JamesWang007,项目名称:EntityFramework,代码行数:11,代码来源:SimpleNullableEntityKeyFactoryTest.cs

示例4: Creates_a_new_primary_key_for_key_values_in_the_given_entry

        public void Creates_a_new_primary_key_for_key_values_in_the_given_entry()
        {
            var model = BuildModel();
            var type = model.GetEntityType(typeof(Banana));

            var entity = new Banana { P1 = 7, P2 = "Ate" };
            var entry = new ClrStateEntry(TestHelpers.CreateContextConfiguration(model), type, entity);

            var key = (SimpleEntityKey<int>)new SimpleEntityKeyFactory<int>().Create(type, type.GetKey().Properties, entry);

            Assert.Equal(7, key.Value);
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:12,代码来源:SimpleEntityKeyFactoryTest.cs

示例5: Returns_null_if_any_value_in_the_entry_properties_is_null

        public void Returns_null_if_any_value_in_the_entry_properties_is_null()
        {
            var model = BuildModel();
            var type = model.GetEntityType(typeof(Banana));

            var random = new Random();
            var entity = new Banana { P1 = 7, P2 = null, P3 = random };

            var entry = new ClrStateEntry(TestHelpers.CreateContextConfiguration(model), type, entity);

            Assert.Equal(EntityKey.NullEntityKey, new CompositeEntityKeyFactory().Create(type, type.GetKey().Properties, entry));
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:12,代码来源:CompositeEntityKeyFactoryTest.cs

示例6: Can_read_and_write_null

        public virtual void Can_read_and_write_null()
        {
            var entity = new Banana { Name = "Stand", Fk = 88 };
            var sidecar = CreateSidecar(CreateInternalEntry(entity));

            sidecar[FkProperty] = null;

            Assert.True(sidecar.HasValue(FkProperty));
            Assert.Null(sidecar[FkProperty]);

            Assert.Equal(88, entity.Fk);
        }
开发者ID:aishaloshik,项目名称:EntityFramework,代码行数:12,代码来源:SidecarTest.cs

示例7: Creates_a_new_key_for_values_in_the_given_entry

        public void Creates_a_new_key_for_values_in_the_given_entry()
        {
            var model = BuildModel();
            var type = model.GetEntityType(typeof(Banana));
            var stateManager = TestHelpers.Instance.CreateContextServices(model).GetRequiredService<IStateManager>();

            var entity = new Banana { P1 = 7 };
            var entry = stateManager.GetOrCreateEntry(entity);

            var key = (SimpleEntityKey<int>)new SimpleEntityKeyFactory<int>(0).Create(type, type.GetPrimaryKey().Properties, entry);

            Assert.Equal(7, key.Value);
        }
开发者ID:JamesWang007,项目名称:EntityFramework,代码行数:13,代码来源:SimpleNullableEntityKeyFactoryTest.cs

示例8: Creates_a_new_primary_key_for_key_values_in_the_given_entry

        public void Creates_a_new_primary_key_for_key_values_in_the_given_entry()
        {
            var model = BuildModel();
            var type = model.GetEntityType(typeof(Banana));

            var random = new Random();
            var entity = new Banana { P1 = 7, P2 = "Ate", P3 = random };

            var entry = new ClrStateEntry(TestHelpers.CreateContextConfiguration(model), type, entity);

            var key = (CompositeEntityKey)new CompositeEntityKeyFactory().Create(type, type.GetKey().Properties, entry);

            Assert.Equal(new object[] { 7, "Ate", random }, key.Value);
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:14,代码来源:CompositeEntityKeyFactoryTest.cs

示例9: Creates_a_new_key_for_CLR_defaults_of_nullable_types

        public void Creates_a_new_key_for_CLR_defaults_of_nullable_types()
        {
            var model = BuildModel();
            var type = model.FindEntityType(typeof(Banana));
            var stateManager = TestHelpers.Instance.CreateContextServices(model).GetRequiredService<IStateManager>();

            var entity = new Banana { P1 = 7, P2 = 0 };
            var entry = stateManager.GetOrCreateEntry(entity);

            var key = (SimpleKeyValue<int?>)new SimpleKeyValueFactory<int?>(type.FindPrimaryKey())
                .Create(new[] { type.FindProperty("P2") }, entry);

            Assert.Equal(0, key.Value);
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:14,代码来源:SimpleEntityKeyFactoryTest.cs

示例10: Creates_a_new_key_for_non_primary_key_values_in_the_given_entry

        public void Creates_a_new_key_for_non_primary_key_values_in_the_given_entry()
        {
            var model = BuildModel();
            var type = model.FindEntityType(typeof(Banana));
            var stateManager = TestHelpers.Instance.CreateContextServices(model).GetRequiredService<IStateManager>();

            var entity = new Banana { P1 = 7, P2 = 8 };
            var entry = stateManager.GetOrCreateEntry(entity);

            var key = (SimpleKeyValue<int>)new SimpleKeyValueFactory<int>(type.FindPrimaryKey())
                .Create(new[] { type.FindProperty("P2") }, entry);

            Assert.Equal(8, key.Value);
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:14,代码来源:SimpleEntityKeyFactoryTest.cs

示例11: Creates_a_new_key_from_current_value_when_value_not_yet_set_in_sidecar

        public void Creates_a_new_key_from_current_value_when_value_not_yet_set_in_sidecar()
        {
            var model = BuildModel();
            var type = model.GetEntityType(typeof(Banana));

            var entity = new Banana { P1 = 7, P2 = 77 };
            var entry = new ClrStateEntry(TestHelpers.CreateContextConfiguration(model), type, entity);

            var sidecar = new RelationshipsSnapshot(entry);

            var key = (SimpleEntityKey<int>)new SimpleNullableEntityKeyFactory<int, int?>().Create(
                type, new[] { type.GetProperty("P2") }, sidecar);

            Assert.Equal(77, key.Value);
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:15,代码来源:SimpleNullableEntityKeyFactoryTest.cs

示例12: CreateCollectible

        public static Collectible CreateCollectible(CollectibleType collectibleType, Vector2 position, Tile currentTile)
        {
            Collectible newCollectible = null;

            switch (collectibleType)
            {
                case CollectibleType.POWERUP:
                    int randomType = RandomManager.GetRandomInt(0, 1);
                    switch (randomType)
                    {
                        case 0:
                            newCollectible = new Powerup(DespicableGame.GetTexture(DespicableGame.GameTextures.SPEEDBOOST), position, currentTile, Powerup.PowerupType.SPEEDBOOST);
                            break;

                        case 1:
                            if (RandomManager.GetRandomTrueFalse(75))
                            {
                                newCollectible = new Powerup(DespicableGame.GetTexture(DespicableGame.GameTextures.TOY_PISTOL), position, currentTile, Powerup.PowerupType.TOY_PISTOL);
                            }
                            else
                            {
                                newCollectible = new Powerup(DespicableGame.GetTexture(DespicableGame.GameTextures.PLAYERTRAP_COLLECTIBLE), position, currentTile, Powerup.PowerupType.PLAYERTRAP);
                            }

                            break;

                    }
                    break;

                case CollectibleType.GOAL:
                    newCollectible = new Goal(DespicableGame.GetTexture(DespicableGame.GameTextures.GOAL), position, currentTile);
                    break;

                case CollectibleType.TRAP:
                    newCollectible =  new Trap(DespicableGame.GetTexture(DespicableGame.GameTextures.TRAP), position, currentTile);
                    break;

                case CollectibleType.SHIP:
                    newCollectible = new Ship(DespicableGame.GetTexture(DespicableGame.GameTextures.LEVEL_EXIT), position, currentTile);
                    break;

                case CollectibleType.BANANA:
                    newCollectible = new Banana(DespicableGame.GetTexture(DespicableGame.GameTextures.BANANA), position, currentTile);
                    break;
            }

            return newCollectible;
        }
开发者ID:keylax,项目名称:TP2-Prog-DespicableGame,代码行数:48,代码来源:CollectibleFactory.cs

示例13: Creates_a_new_key_from_a_sidecar_value

        public void Creates_a_new_key_from_a_sidecar_value()
        {
            var model = BuildModel();
            var type = model.GetEntityType(typeof(Banana));

            var entity = new Banana { P1 = 7, P2 = "Ate" };
            var entry = new ClrStateEntry(TestHelpers.CreateContextConfiguration(model), type, entity);

            var sidecar = new RelationshipsSnapshot(entry);
            sidecar[type.GetProperty("P2")] = "Eaten";

            var key = (SimpleEntityKey<string>)new SimpleEntityKeyFactory<string>().Create(
                type, new[] { type.GetProperty("P2") }, sidecar);

            Assert.Equal("Eaten", key.Value);
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:16,代码来源:SimpleEntityKeyFactoryTest.cs

示例14: Creates_a_new_primary_key_for_key_values_in_the_given_entry

        public void Creates_a_new_primary_key_for_key_values_in_the_given_entry()
        {
            var model = BuildModel();
            var type = model.FindEntityType(typeof(Banana));
            var stateManager = TestHelpers.Instance.CreateContextServices(model).GetRequiredService<IStateManager>();

            var random = new Random();
            var entity = new Banana { P1 = 7, P2 = "Ate", P3 = random };

            var entry = stateManager.GetOrCreateEntry(entity);

            var key = (CompositeKeyValue)new CompositeKeyValueFactory(
                type.FindPrimaryKey())
                .Create(type.FindPrimaryKey().Properties, entry);

            Assert.Equal(new object[] { 7, "Ate", random }, key.Value);
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:17,代码来源:CompositeEntityKeyFactoryTest.cs

示例15: CalculateBananaMinimum

        public void CalculateBananaMinimum()
        {
            int _dim=2;
            double []_data = {5,34};
            double []_reference = {1,1};
            double _epsilon=1e-7;
            double _realEpsilon = System.Math.Sqrt(_epsilon);
            double _step=1000;
            int _itmax=1000;
            double diff;

            Banana func = new Banana();
            Rosenbrock objRosenbrock = new Rosenbrock(_dim, _data, func, _step, _epsilon, _itmax);
            objRosenbrock.FindMinimum();
            diff = NumericNet.CalcDiff(_dim,_reference,_data);
            Assert.IsTrue(diff<_realEpsilon);
        }
开发者ID:kriskniaz,项目名称:pCode,代码行数:17,代码来源:RosenTests.cs


注:本文中的Banana类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。