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


C# List.Find方法代码示例

本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.Find方法的典型用法代码示例。如果您正苦于以下问题:C# List.Find方法的具体用法?C# List.Find怎么用?C# List.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.VisualStudio.TestTools.UnitTesting.List的用法示例。


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

示例1: TestBDD_AjoutSupprJedi

        public void TestBDD_AjoutSupprJedi()
        {
            List<Jedi> lj = new List<Jedi>(data.getAllJedi());
            // Création du jedi
            int id = 42;
            String name = "Sloubi";
            bool isSith = true;
            Caracteristique carac = data.getAllCaracteristic().Find(c => c.Id == 1);

            List<Caracteristique> lc = new List<Caracteristique>();
            lc.Add(carac);

            Jedi jedi = new Jedi(id, name, isSith, lc);

            // Modifications BDD
            Assert.IsFalse(data.getAllJedi().Any(j => j.Id == id), "Ce jedi est déjà présent dans la BDD !");    // On vérifie que le jedi n'est pas déjà présent dans la BDD

            lj.Add(jedi);
            data.updateJedi(lj);

            Assert.IsTrue(data.getAllJedi().Any(j => j.Id == id), "Le jedi n'a pas été ajouté");     // On vérifie que le jedi a bien été rajouté
            Assert.AreEqual(data.getAllJedi().Find(j => j.Id == id).Nom, name, "Le nom du jedi ne correspond pas");
            Assert.AreEqual(data.getAllJedi().Find(j => j.Id == id).IsSith, isSith, "Le côté de la force du jedi ne correspond pas");

            lj.Remove(lj.Find(j => j.Id == id));
            data.updateJedi(lj);

            Assert.IsFalse(data.getAllJedi().Any(j => j.Id == id), "Le jedi n'a pas été supprimé");    // On vérifie que le jedi a bien été supprimé
        }
开发者ID:theCmaker,项目名称:ZZ2_services_reseau,代码行数:29,代码来源:BusinessManagerTests.cs

示例2: Initialize

        public void Initialize()
        {
            //Initialize_data
            User user1 = new User() { Id = 1, Email = "123", CreatedTime = DateTime.Now, Name = "user1", NickName = "梁贵", Password = "123", };
            User user2 = new User() { Id = 2, Email = "123", CreatedTime = DateTime.Now, Name = "user2", NickName = "梁贵2", Password = "123", };
            _users = new List<User> { user1, user2 };

            Role role1 = new Role() { Id = 1, Name = "role1", Remark = "role1" };
            Role role2 = new Role() { Id = 2, Name = "role2", Remark = "role2" };
            _roles = new List<Role> { role1, role2 };
            user1.Roles = _roles;

            //Initialize_interface
            _unitOfWork = Substitute.For<IUnitOfWork>();
            _identityService = Substitute.For<IdentityService>(_unitOfWork);
            _userRepository = Substitute.For<IRepository<User, int>>();
            _roleRepository = Substitute.For<IRepository<Role, int>>();
            _userRepository.GetByKey(Arg.Any<int>()).ReturnsForAnyArgs(x => _users.Find(r => r.Id == (int)x[0]));
            _userRepository.Entities.Returns(_users.AsQueryable());

            _roleRepository.Entities.Returns(_roles.AsQueryable());
            _roleRepository.GetByKey(Arg.Any<int>()).Returns(x => _roles.Find(r => r.Id == (int)x[0]));
            _identityService.UserRepository.Returns(_userRepository);
            _identityService.RoleRepository.Returns(_roleRepository);
        }
开发者ID:TGHGH,项目名称:MesDemo,代码行数:25,代码来源:UnitTestIdentityService.cs

示例3: TestBDD_AjoutSupprCarac

        public void TestBDD_AjoutSupprCarac()
        {
            List<Caracteristique> lc = new List<Caracteristique>(data.getAllCaracteristic());
            // Création de la caractéristique
            int id = 42;
            EDefCaracteristique def = EDefCaracteristique.Chance;
            String text = "Carac ajoutée Jedi";
            ETypeCaracteristique type = ETypeCaracteristique.Jedi;
            int val = 20;
            Caracteristique carac = new Caracteristique(id, def, text, type, val);

            // Modifications BDD
            Assert.IsFalse(data.getAllCaracteristic().Any(c => c.Id == id), "Cette caractéristique est déjà présente dans la BDD !");    // On vérifie que la caractéristique n'est pas déjà présente dans la BDD
            
            lc.Add(carac);
            data.updateCaracteristique(lc);

            Assert.IsTrue(data.getAllCaracteristic().Any(c => c.Id == id), "La caractéristique n'a pas été ajoutée");     // On vérifie que la caractéristique a bien été rajoutée
            Assert.AreEqual(data.getAllCaracteristic().Find(c => c.Id == id).Definition, def);
            Assert.AreEqual(data.getAllCaracteristic().Find(c => c.Id == id).Nom, text);
            Assert.AreEqual(data.getAllCaracteristic().Find(c => c.Id == id).Type, type);
            Assert.AreEqual(data.getAllCaracteristic().Find(c => c.Id == id).Valeur, val);

            lc.Remove(lc.Find(c => c.Id == id));
            data.updateCaracteristique(lc);

            Assert.IsFalse(data.getAllCaracteristic().Any(c => c.Id == id), "La caractéristique n'a pas été supprimée");    // On vérifie que la caractéristique a bien été supprimée
        }
开发者ID:theCmaker,项目名称:ZZ2_services_reseau,代码行数:28,代码来源:BusinessManagerTests.cs

示例4: AssertViewModelContents

        private void AssertViewModelContents( AllFoodGroupsViewModel viewModel, List<FoodGroup> foodGroups )
        {
            Assert.AreEqual( foodGroups.Count, viewModel.Items.Count );

             foreach (var foodGroup in viewModel.Items)
             {
            var foodGroupFromRepository = foodGroups.Find( fg => fg.ID == foodGroup.ID );

            Assert.IsNotNull( foodGroup );
            Assert.AreEqual( foodGroupFromRepository.Name, foodGroup.Name );
             }
        }
开发者ID:nagyist,项目名称:HealthTracker-1,代码行数:12,代码来源:AllFoodGroupsViewModelTest.cs

示例5: AssertViewModelContents

        private void AssertViewModelContents( AllFoodItemsViewModel viewModel, List<FoodItem> foods )
        {
            Assert.AreEqual( foods.Count, viewModel.Items.Count );

             foreach (var food in viewModel.Items)
             {
            var foodItemFromRepository = foods.Find( f => f.ID == food.ID );

            Assert.IsNotNull( food );
            Assert.AreEqual( foodItemFromRepository.Name, food.Name );
             }
        }
开发者ID:nagyist,项目名称:HealthTracker-1,代码行数:12,代码来源:AllFoodItemsViewModelTest.cs

示例6: AssertViewModelContents

        private void AssertViewModelContents( AllMealTypesViewModel viewModel, List<MealType> mealTypes )
        {
            Assert.AreEqual( mealTypes.Count, viewModel.Items.Count );

             foreach (var mealType in viewModel.Items)
             {
            var mealTypeFromRepository = mealTypes.Find( mt => mt.ID == mealType.ID );

            Assert.IsNotNull( mealType );
            Assert.AreEqual( mealTypeFromRepository.Name, mealType.Name );
             }
        }
开发者ID:nagyist,项目名称:HealthTracker-1,代码行数:12,代码来源:AllMealTypesViewModelTest.cs

示例7: AssertViewModelContents

        private void AssertViewModelContents( AllMealTemplatesViewModel viewModel, List<MealTemplate> mealTemplates )
        {
            Assert.AreEqual( mealTemplates.Count, viewModel.Items.Count );

             foreach (var template in viewModel.Items)
             {
            var templateFromRepository = mealTemplates.Find( mt => mt.ID == template.ID );

            Assert.IsNotNull( template );
            Assert.AreEqual( templateFromRepository.Name, template.Name );
            Assert.AreEqual( templateFromRepository.Calories, template.Calories );
             }
        }
开发者ID:nagyist,项目名称:HealthTracker-1,代码行数:13,代码来源:AllMealTemplatesViewModelTest.cs

示例8: DeleteProduct

        public void DeleteProduct()
        {
            var data = new List<Product>
            {
                new Product {Name = "BBB", BarCode = "112115", InStock = 15, Id = 1},
                new Product {Name = "ZZZ", BarCode = "112116", InStock = 23, Id = 2},
                new Product {Name = "AAA", BarCode = "112116", InStock = 30, Id = 3}
            };

            var mockSet = new Mock<DbSet<Product>>()
                .SetupData(data, objects => data.SingleOrDefault(d => d.Id == (int)objects.First()));
            

            var mockContext = new Mock<DAL.IDbContext>();
            mockContext.Setup(m => m.Set<Product>()).Returns(mockSet.Object);
            var service = new ProductService(mockContext.Object);

            service.Delete(1);
            Assert.IsNull(data.Find(x => x.Id == 1));
        }
开发者ID:Goblinftw,项目名称:Upteka,代码行数:20,代码来源:ServiceTest.cs

示例9: Must_be_able_to_follow_another_user

        public void Must_be_able_to_follow_another_user()
        {
            var test = new List<User>()
                       {
                           new User()
                           {
                               Name = "Alice",
                               _peopleFollowing = new List<User>()
                           }
                       };
            _userList = new UserList();
            _userList.ListOfUsers = test;

            var username = "Alice";
            var usernameOfFollowed = "Bob";

            _sut = new Follow(_userList);

            _sut.FollowUser(username, usernameOfFollowed);

            var user = test.Find(u => u.Name == username);
            Assert.AreEqual(user._peopleFollowing.Count, 1);
        }
开发者ID:msurekci,项目名称:console-twitter,代码行数:23,代码来源:FollowingTests.cs

示例10: Game

        public Game(List<Player> players, int bb, int sb, Boolean train)
	    {
            log.Debug("Game() - Begin");
            log.Debug("New Game - Player: " + players.Count + " Stakes: " + sb + "/" + bb);
            trainMode = train;
            boolCancel = false;
            blindLevel = 0;
            foreach (Player p in players)
            {
                log.Info("Name: " + p.name + "; Position: " + p.position + "; Stack: " + p.stack);
            }
            this.players = players;
            this.smallBlind = sb;
            this.bigBlind = bb;
            pot = new Pot();
            round = 0;
            players.Sort((x, y) => x.position.CompareTo(y.position));
            for (int i = 2; i < players.Count + 2; i++)
            {
                players.Find(x => (x.position > (i - 2)) && (x.ingamePosition == -1)).ingamePosition = i;
            }
            log.Debug("Game() - End");
	    }
开发者ID:B3J4y,项目名称:Poker,代码行数:23,代码来源:Game.cs

示例11: Verify_IsSelected_PublishesDebugSelectionChangedEventArgs

        static void Verify_IsSelected_PublishesDebugSelectionChangedEventArgs(ActivityType activityType, ActivitySelectionType expectedSelectionType, int expectedCount, bool setIsSelected = false)
        {
            var expected = new DebugState { DisplayName = "IsSelectedTest", ID = Guid.NewGuid(), ActivityType = activityType };

            var events = new List<DebugSelectionChangedEventArgs>();

            var selectionChangedEvents = EventPublishers.Studio.GetEvent<DebugSelectionChangedEventArgs>();
            selectionChangedEvents.Subscribe(events.Add);

            var envRep = CreateEnvironmentRepository();

            var vm = new DebugStateTreeViewItemViewModelMock(envRep.Object) { Content = expected };

            if(setIsSelected)
            {
                // clear constructor events
                events.Clear();

                // events are only triggered when property changes to true
                vm.IsSelected = false;

                vm.SelectionType = expectedSelectionType;
                vm.IsSelected = true;
            }
            else
            {
                vm.IsSelected = false;
                vm.SelectionType = expectedSelectionType;
            }

            EventPublishers.Studio.RemoveEvent<DebugSelectionChangedEventArgs>();

            Assert.AreEqual(expectedCount, events.Count);
            if(events.Count > 0)
            {
                var foundEvent = events.Find(args => args.SelectionType == expectedSelectionType);
                Assert.IsNotNull(foundEvent);
                Assert.AreSame(expected, foundEvent.DebugState);
            }
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:40,代码来源:DebugStateTreeViewItemViewModelTests.cs

示例12: SearchCollection1SearchTermMultiplePropertiesDuplicateResultTest

 public void SearchCollection1SearchTermMultiplePropertiesDuplicateResultTest()
 {
     //Happy flow
     var searchCollection = new List<HelpItem>(_helpItems);
     searchCollection.Insert(2, searchCollection[3]);
     var target = new SearchList<HelpItem>(searchCollection);
     const string searchTerm = "Help omschrijving 4";
     var expected = searchCollection.Find(s => s.HelpDescription == searchTerm);
     _propertyNames[4] = string.Empty;
     var actual = target.SearchCollection1SearchTermAllProperties(searchTerm, _propertyNames);
     Assert.IsTrue(actual.Contains(expected));
 }
开发者ID:lebroit,项目名称:LeBroITSolutions,代码行数:12,代码来源:SearchListTest.cs

示例13: FindDisplaysClearErrorMessageWhenMoreThanOneElementMatchesCondition

		public void FindDisplaysClearErrorMessageWhenMoreThanOneElementMatchesCondition()
		{
			var emptyList = new List<int> { 2, 4, 6 };
			Expression<Func<int, bool>> condition = x => x > 2;
			var ex = TestUtils.ExpectException<InvalidOperationException>(() => emptyList.Find(condition));
			Assert.AreEqual("Sequence of type '" + IntTypeName + "' contains more than element that matches the condition '" + condition + "'. The first 2 are '4' and '6'", ex.Message);
		}
开发者ID:arnonax,项目名称:TestEssentials,代码行数:7,代码来源:ExtensionMethodsUnitTests.cs

示例14: FindDisplaysClearErrorMessageWhenNoElementMatchesCondition

		public void FindDisplaysClearErrorMessageWhenNoElementMatchesCondition()
		{
			var emptyList = new List<int> { 1, 2,3};
			Expression<Func<int, bool>> expr = x => x == 4;
			var ex = TestUtils.ExpectException<InvalidOperationException>(() => emptyList.Find(expr));
			Assert.AreEqual("Sequence of type '" + IntTypeName + "' contains no element that matches the condition '" + expr + "'", ex.Message);
		}
开发者ID:arnonax,项目名称:TestEssentials,代码行数:7,代码来源:ExtensionMethodsUnitTests.cs

示例15: TestFind_NullComparer_Throws

 public void TestFind_NullComparer_Throws()
 {
     IExpandableSublist<List<int>, int> list = new List<int>().ToSublist();
     int value = 0;
     IEqualityComparer<int> comparer = null;
     list.Find(value, comparer);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:FindTester.cs


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