當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。