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


C# ObservableCollection.All方法代码示例

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


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

示例1: CounterServiceReturnsCountedWords

        public void CounterServiceReturnsCountedWords(string sentence, ObservableCollection<WordCountViewModel> expectedResult)
        {
            var searcher = new WordsCounterService();
            var countedWords = new ObservableCollection<WordCountViewModel>();

            searcher.Count(sentence, countedWords);

            Assert.That(countedWords.Count, Is.EqualTo(expectedResult.Count));
            Assert.IsTrue(expectedResult.All(x => Contains(countedWords, x)));
        }
开发者ID:zish82,项目名称:WordCounter,代码行数:10,代码来源:WhenCounting.cs

示例2: SentencesSplitOnSpecialCharacters

        public void SentencesSplitOnSpecialCharacters(string specialCharacter)
        {
            var sentence = string.Format("firstPart{0}secondPart", specialCharacter);
            var counter = new WordsCounterService();
            var countedWords = new ObservableCollection<WordCountViewModel>();
            var wordCountViewModels = new ObservableCollection<WordCountViewModel> { new WordCountViewModel { Word = "firstPart", Count = 1 }, new WordCountViewModel { Word = "secondPart", Count = 1 } };

            counter.Count(sentence, countedWords);

            Assert.That(countedWords.All(x => Contains(wordCountViewModels, x)));
        }
开发者ID:zish82,项目名称:WordCounter,代码行数:11,代码来源:WhenCounting.cs

示例3: ViewModel

        public ViewModel()
        {
            Model model = Model.Instance;

            GroupedList = new ObservableCollection<ResultGroup>();

            model.UnGroupedList.ForEach(result =>
            {
                if (GroupedList.All(x => x.Result != result.result))
                    GroupedList.Add(new ResultGroup(result.result));
            });

            foreach (ResultGroup group in GroupedList)
            {
                model.UnGroupedList.ToList().ForEach(x => { if (x.result == group.Result) group.Results.Add(x); });
            }
        }
开发者ID:tb2johm,项目名称:SimpleGroupedTreeList,代码行数:17,代码来源:ViewModel.cs

示例4: ApplyFilter

        public void ApplyFilter(bool reset,bool notifications=true)
        {
            if (AllDownloads == null || !AllDownloads.Any())
            {
                Fetch();
                return;
            }

            _mutexFilter.WaitOne();

            FavSeasonData currentFavSeason = null;
            SeasonData currentSeasonData = null;
            int seasonNr = -1;

            ObservableCollection<FavSeasonData> newSeasons = new ObservableCollection<FavSeasonData>();
            ObservableCollection<DownloadData> newNonSeasons = new ObservableCollection<DownloadData>();

            bool setNewEpisodes = false;
            bool setNewUpdates = false;

            if (_isNewShow) notifications = false;
            reset = reset || _isNewShow;
            if (!reset)
            {
                newSeasons = Seasons;
                newNonSeasons = NonSeasons;
            }

            UploadData currentUpload = null;
            bool ignoreCurrentUpload = false;
            foreach (var download in AllDownloads)
            {
                //upload stuff --------------------------------------------------------------------
                if (currentUpload == null || currentUpload != download.Upload)
                {
                    currentUpload = download.Upload;
                    ignoreCurrentUpload = true;
                    do
                    {

                        UploadLanguage language = currentUpload.Language;
                        if (!Settings.Instance.MarkSubbedAsGerman && currentUpload.Subbed) //dont mark german-subbed as german
                        {
                            language&=~UploadLanguage.German; //remove german
                        }

                        if ((language & FilterLanguage) == 0) //Filter: Language
                            break;

                        if (!String.IsNullOrWhiteSpace(FilterRuntime) &&     //Filter: Runtime
                            !(new Regex(FilterRuntime).Match(currentUpload.Runtime).Success))
                            break;

                        if (!String.IsNullOrWhiteSpace(FilterSize) &&     //Filter: Size
                            !(new Regex(FilterSize).Match(currentUpload.Size).Success))
                            break;

                        if (!String.IsNullOrWhiteSpace(FilterUploader) &&     //Filter: Uploader
                            !(new Regex(FilterUploader).Match(currentUpload.Uploader).Success))
                            break;

                        if (!String.IsNullOrWhiteSpace(FilterFormat) &&     //Filter: Format
                            !(new Regex(FilterFormat).Match(currentUpload.Format).Success))
                            break;

                        ignoreCurrentUpload = false;

                    } while (false);
                }

                if (ignoreCurrentUpload) //Filter: All upload stuff
                {
                    continue;
                }

                //episode stuff ---------------------

                if (!String.IsNullOrWhiteSpace(FilterName) && //Filter: Name
                    !(new Regex(FilterName).Match(download.Title).Success))
                    continue;

                if (!String.IsNullOrWhiteSpace(FilterHoster))
                {
                    var r = new Regex(FilterHoster);
                    var dls = download.Links.Keys.Where(hoster => r.Match(hoster).Success).ToList(); //all keys that match the regex
                    if (!dls.Any()) //Filter: Hoster
                        continue;
                    for (int i = download.Links.Keys.Count - 1; i >= 0; i--)
                    {
                        string key = download.Links.Keys.ElementAt(i);
                        if (!dls.Contains(key))
                        {
                            download.Links.Remove(key);
                        }
                    }
                }

                //------------------------------------------

                //Season stuff ------------------------------------------------------------------------------------
//.........这里部分代码省略.........
开发者ID:Bernybon,项目名称:sjupdater,代码行数:101,代码来源:FavShowData.cs

示例5: SchedulerViewModel_Validation_IfDuplicateNames

        public void SchedulerViewModel_Validation_IfDuplicateNames()
        {
            var resourceModel = new Mock<IScheduledResourceModel>();
            var resources = new ObservableCollection<IScheduledResource> { new ScheduledResource("bob", SchedulerStatus.Enabled, DateTime.MaxValue, new Mock<IScheduleTrigger>().Object, "c") { NumberOfHistoryToKeep = 1 }, new ScheduledResource("dave", SchedulerStatus.Enabled, DateTime.MaxValue, new Mock<IScheduleTrigger>().Object, "c") };
            resourceModel.Setup(a => a.ScheduledResources).Returns(resources);

            var schedulerViewModel = new SchedulerViewModel
                {
                    ScheduledResourceModel = resourceModel.Object,
                    SelectedTask = resources[0],
                    Name = "dave"
                };
            //create duplicate name
            Assert.IsTrue(schedulerViewModel.HasErrors);
            Assert.AreEqual("There is already a task with the same name", schedulerViewModel.Error);
            Assert.IsTrue(resources.All(a => a.Errors.HasErrors()));
            Assert.IsTrue(resources.All(a => a.Errors.FetchErrors()[0] == "There is already a task with the same name"));


        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:20,代码来源:SchedulerViewModelTests.cs

示例6: SortRolesWithAll

        /// <summary>
        /// Sorts the roles with all.
        /// </summary>
        /// <param name="roles">The roles.</param>
        /// <returns>ObservableCollection{RoleInfo}.</returns>
        public ObservableCollection<RoleInfo> SortRolesWithAll(IEnumerable<IRoleInfo> roles)
        {
                var retVal = new ObservableCollection<RoleInfo>();

                if (roles != null)
                {
                    foreach (var role in roles.OrderBy(r => r.ReadValueByPropertyName<string>(Constants.Name)))
                    {
                        var name = role.ReadValueByPropertyName<string>(Constants.Name);
                        var id = role.ReadValueByPropertyName<int>(Constants.IdColumnName);

                        if (string.IsNullOrWhiteSpace(name))
                        {
                            continue;
                        }

                        retVal.Add(new RoleInfo() { Id = id, Name = name });
                    }
                }

            if (retVal.All(x => x.Id != Constants.AllRolesId))
            {
                retVal.Insert(0, new RoleInfo { Id = Constants.AllRolesId, Name = Constants.AllRolesName });
            }

            return retVal;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:32,代码来源:CollectionUtilities.cs

示例7: SortBusinessUnitsWithAll

        /// <summary>
        /// Sorts the business units with all.
        /// </summary>
        /// <param name="businessUnits">The business units.</param>
        /// <returns>ObservableCollection{BusinessUnitInfo}.</returns>
        public ObservableCollection<BusinessUnitInfo> SortBusinessUnitsWithAll(IEnumerable<IBusinessUnitInfo> businessUnits)
        {
            var retVal = new ObservableCollection<BusinessUnitInfo>();

            if (businessUnits != null)
            {
                foreach (var bu in businessUnits.OrderBy(r => r.ReadValueByPropertyName<string>(Constants.Name)))
                {
                    var name = bu.ReadValueByPropertyName<string>(Constants.Name);
                    var id = bu.ReadValueByPropertyName<int>(Constants.IdColumnName);

                    if (string.IsNullOrWhiteSpace(name))
                    {
                        continue;
                    }

                    retVal.Add(new BusinessUnitInfo() { Id = id, Name = name });
                }
            }

            if (retVal.All(x => x.Id != Constants.AllBusinessUnitsId))
            {
                retVal.Insert(0, new BusinessUnitInfo { Id = Constants.AllBusinessUnitsId, Name = Constants.AllBusinessUnitsName });
            }

            return retVal;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:32,代码来源:CollectionUtilities.cs

示例8: LoadDistinctPhysicalStores

 private void LoadDistinctPhysicalStores()
 {
     _distinctPhysicalStoresForAllItems = new ObservableCollection<PhysicalStoreViewModel>();
     foreach (
         var physicalStore in
             _orderDetails.SelectMany(orderDetail => orderDetail.getPhysicalStoreViewModels(),
                 (orderDetail, p) =>
                     new PhysicalStoreViewModel {Name = p.Name, PhysicalStoreID = p.PhysicalStoreID})
                 .Where(
                     physicalStore =>
                         _distinctPhysicalStoresForAllItems.All(
                             ps =>
                                 ps.PhysicalStoreID != physicalStore.PhysicalStoreID &&
                                 physicalStore.PhysicalStoreID != 0)))
         _distinctPhysicalStoresForAllItems.Add(physicalStore);
     _distinctPhysicalStoresForAllItems.Add(new PhysicalStoreViewModel
     {
         PhysicalStoreID = 0,
         Name = "No Preferences"
     });
 }
开发者ID:USAID-DELIVER-PROJECT,项目名称:ethiopia-hcmis-warehouse,代码行数:21,代码来源:OrderViewModel.cs

示例9: AddStoresToAccount

 private void AddStoresToAccount(List<int> storesNumbers)
 {
     if (storesNumbers.Count <= 0) return;
     var storesForAddList = new ObservableCollection<AccountsStoreDetailsSet>();
     foreach (var storeNumber in storesNumbers.Where(storeNumber => AccountStoresList.All(s => s.StoreNumber != storeNumber) && storesForAddList.All(s => s.AccountStore != storeNumber)))
     {
         storesForAddList.Add(new AccountsStoreDetailsSet { AccountsMainId = CurrentAccount.Id, AccountStore = storeNumber });
     }
     if (storesForAddList.Count == 0) return;
     _accountStoresService.AddStoresToAccount(storesForAddList);
     AccountStoresList = new ObservableCollection<StoresSet>(_accountStoresService.GetAccountStoresById(CurrentAccount.Id));
     StoresWorkList = new ObservableCollection<StoreProvenWorkSet>(_storesWorkService.GetWorksList(AccountStoresList, false));
     Application.Current.Dispatcher.BeginInvoke(new Action(() => StoresForLoad = string.Empty));
 }
开发者ID:Fredoq,项目名称:AccountsWork,代码行数:14,代码来源:AdditionalInfoViewModel.cs

示例10: RefreshAsync

        /// <summary>
        /// Refresh the changeset data asynchronously.
        /// </summary>
        private async Task RefreshAsync()
        {
            try
            {
                var pc = GetService<IPendingChangesExt>();
                var currentlyAssociatedWorkItems = pc.WorkItems;

                // Set our busy flag and clear the previous data
                this.IsBusy = true;
                this.RecentWorkItems.Clear();

                var workItems = new ObservableCollection<AssociatedWorkItemInfo>();

                // Make the server call asynchronously to avoid blocking the UI
                await Task.Run(() =>
                {
                    ITeamFoundationContext context = this.CurrentContext;
                    if (context != null && context.HasCollection && context.HasTeamProject)
                    {
                        var vcs = context.TeamProjectCollection.GetService<VersionControlServer>();
                        if (vcs != null)
                        {
                            string path = "$/" + context.TeamProjectName;
                            foreach (Changeset changeset in vcs.QueryHistory(path, VersionSpec.Latest, 0, RecursionType.Full,
                                                                             vcs.AuthorizedUser, null, null, 10, false, true))
                            {
                                foreach (var wi in changeset.AssociatedWorkItems)
                                {
                                    if (workItems.All(w => w.Id != wi.Id) && currentlyAssociatedWorkItems.All(w => w.WorkItem.Id != wi.Id))
                                    {
                                        workItems.Add(wi);
                                    }
                                }
                            }
                        }
                    }
                });

                // Now back on the UI thread, update the bound collection and section title
                this.RecentWorkItems = new ObservableCollection<AssociatedWorkItemInfo>(workItems.Take(5));
                this.Title = this.RecentWorkItems.Count > 0 ? String.Format(" {0} ({1})", SectionTitle, this.RecentWorkItems.Count)
                                                       : SectionTitle;
            }
            catch (Exception ex)
            {
                ShowNotification(ex.Message, NotificationType.Error);
            }
            finally
            {
                // Always clear our busy flag when done
                this.IsBusy = false;
            }
        }
开发者ID:ptittof57,项目名称:AssociateRecentWorkItems,代码行数:56,代码来源:RecentWorkItemsSection.cs

示例11: contextLoadBookmarks_Click

        private void contextLoadBookmarks_Click(object sender, RoutedEventArgs e)
        {
            if (TagsBookmarked != null && TagsBookmarked.Count > 0)
            {
                if (MetroMessageBox.Show("You already have bookmarks!", "If you continue, your current bookmarks will be overwritten with the bookmarks you choose. \n\nAre you sure you wish to continue?", MetroMessageBox.MessageBoxButtons.YesNoCancel) != MetroMessageBox.MessageBoxResult.Yes)
                    return;
            }

            var ofd = new OpenFileDialog
                          {
                              Title = "Assembly - Select a Tag Bookmark File",
                              Filter = "Assembly Tag Bookmark File (*.astb)|*.astb"
                          };
            if (!(bool)ofd.ShowDialog())
                return;

            var bookmarkStorage = JsonConvert.DeserializeObject<BookmarkStorageFormat>(File.ReadAllText(ofd.FileName));

            TagsBookmarked = new ObservableCollection<TagClass>();
            if (bookmarkStorage.StorageUsingTagNames)
            {
                foreach(var bookmarkedTag in bookmarkStorage.BookmarkedTagNames)
                {
                    var tag = bookmarkedTag;
                    foreach (var tagClass in _tagsComplete.Where(tagClass => tagClass.TagClassMagic == tag[0]))
                    {
                        foreach (var tagEntry in tagClass.Children)
                        {
                            if (tagEntry.TagFileName.ToLowerInvariant() != tag[1])
                                tagEntry.IsBookmark = false;
                            else
                            {
                                // Check boomarked tags has the relevant Tag Class
                                if (TagsBookmarked.All(tagClasss => tagClasss.RawClass != tagClass.RawClass))
                                    TagsBookmarked.Add(new TagClass(tagClass.RawClass, tagClass.TagClassMagic, tagClass.Description));

                                // Set boomark to true
                                tagEntry.IsBookmark = true;

                                // Add Tag Entry
                                TagsBookmarked.First(tagClasss => tagClasss.RawClass == tagClass.RawClass).Children.Add(tagEntry);
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (var tagDatumIndex in bookmarkStorage.BookmarkedDatumIndices)
                {
                    foreach (var tagClass in _tagsComplete)
                    {
                        var index = tagDatumIndex;
                        foreach (var tagEntry in tagClass.Children)
                        {
                            if (tagEntry.RawTag.Index.Value != index)
                                tagEntry.IsBookmark = false;
                            else
                            {
                                // Check boomarked tags has the relevant Tag Class
                                if (TagsBookmarked.All(tagClasss => tagClasss.RawClass != tagClass.RawClass))
                                    TagsBookmarked.Add(new TagClass(tagClass.RawClass, tagClass.TagClassMagic, tagClass.Description));

                                // Set boomark to true
                                tagEntry.IsBookmark = true;

                                // Add Tag Entry
                                TagsBookmarked.First(tagClasss => tagClasss.RawClass == tagClass.RawClass).Children.Add(tagEntry);
                            }
                        }
                    }
                }
            }
        }
开发者ID:iBotPeaches,项目名称:Assembly,代码行数:74,代码来源:HaloMap.xaml.cs

示例12: Network

        public Network(string host, int port, User userirc, string[] initialChannels)
        {
            Name = host; // By default, name is host.
            Users = new ObservableCollection<UiUser>();
            DisplayUsers = new ObservableCollection<UiUser>();
            Channels = new ObservableCollection<UiChannel>();

            Me = new UiUser(userirc, ViewModelLocator.Main.GenColor());
            Users.Add(Me);

            // Create IRC client and handle connection.
            Client = new Client(host, port, userirc);
            Client.IRCMessage += message => Console.WriteLine(message.Text);
            Client.Connect += () =>
            {
                foreach (var chan in initialChannels)
                    Client.Send(new JoinMessage(chan));
            };
            Client.ReplyISupport += message =>
            {
                // Use the NETWORK= parameter in 005 to set the server name.
                string networkName;
                if (message.TryGetParameter("Network", out networkName))
                    Name = networkName;
            };

            // Update user list on certain events.
            Client.Nick += message => { SortUsers(); };
            Client.RankChange += (user, channel, rank) => { SortUsers(); };
            Client.AwayChange += (user, away) => { SortUsers(); };

            // Subscribe to events when a channel is joined.
            Client.ChannelJoin += message =>
            {
                var channelJoined = new UiChannel(message.Channel, this);
                if (ViewModelLocator.Main.Channel == null)
                    ViewModelLocator.Main.Channel = channelJoined;
                DispatcherHelper.CheckBeginInvokeOnUI(() => Channels.Add(channelJoined));
                message.Channel.Message += privateMessage => //Subscribe to the joined channel's messages
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(
                        () =>
                        {
                            var chan = Channels.FirstOrDefault(c => c.Channel == message.Channel);
                            chan?.AddLine(privateMessage);
                        });
                };
                // Show system messages (will be moved to cause/effect system eventually)
                message.Channel.UserJoin +=
                    joinMessage =>
                    {
                        AddSystemLine(
                            $"{joinMessage.User.Nick} ({joinMessage.User.Ident}@{joinMessage.User.Host}) has joined.", channelJoined.Channel);
                    };
                message.Channel.UserPart +=
                    partMessage =>
                    {
                        var reason = string.IsNullOrEmpty(partMessage.Reason) ? string.Empty : $"({partMessage.Reason})";
                        AddSystemLine($"{partMessage.User.Nick} has left. {reason}", channelJoined.Channel);
                    };

                message.Channel.UserAdd += user =>
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        //Don't add duplicate users to the master list.
                        if (Users.All(u => u.User != user))
                        {
                            Users.Add(new UiUser(user, ViewModelLocator.Main.GenColor()));
                            SortUsers();
                        }
                    });
                };

                message.Channel.UserRemove += user =>
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        Users.Remove(Users.FirstOrDefault(x => x.User == user));
                        SortUsers();
                    });
                };
            };
            // Show system messages (will be moved to cause/effect system eventually)
            Client.Quit +=
                message =>
                {
                    var reason = string.IsNullOrEmpty(message.Reason) ? string.Empty : $"({message.Reason})";
                    AddSystemLine($"{message.User.Nick} has quit. {reason}", message.User.Channels.ToArray());
                };
            Client.Nick += message =>
            {
                AddSystemLine($"{message.OldNick} is now known as {message.Nick}.", message.User.Channels.ToArray());
            };
            //irc.ReplyMOTDEnd += delegate(MOTDEndMessage message) { Text += message.MOTD + Environment.NewLine; };
            Client.Start();
        }
开发者ID:Pyratron,项目名称:PyraChat,代码行数:97,代码来源:Network.cs

示例13: PopulateSecurityConfigurations

        public void PopulateSecurityConfigurations()
        {
            var catalog = new TypeCatalog();

            var container = new CompositionContainer(catalog, false);

            var expressionServiceBase = Mock.Create<IExpressionServiceBase>(Behavior.Loose);
            container.ComposeExportedValue(expressionServiceBase);

            Ioc.InjectContainer(container);

            var vm = new ProcessCommandsViewModel();
            var process = new ProcessEditMock();
            var processEditExtensionsMock = Mock.Create<ProcessEditExtensions>(Behavior.Loose);
            process.ProcessEditExtensions = processEditExtensionsMock;

            vm.Model = process;

            process.ProcessOptionChoose = ProcessOption.VersionEnabled;

            Assert.AreEqual(1, vm.Model.CommandList.Count);

            var collectionUtilities = Mock.Create<ICollectionUtilities>(Behavior.Loose);

            Mock.Arrange(() => collectionUtilities.SortStatesInfoWithAll(Arg.IsAny<IEnumerable<StateEdit>>())).Returns<IEnumerable<StateEdit>>(
                list =>
                    {
                        var result = new ObservableCollection<StateInfo>(list.Select(s => new StateInfo { Name = s.Name, Guid = s.Guid }));

                        if (result.All(x => x.Guid != Constants.AllStatesGuid)) result.Insert(0, new StateInfo { Guid = Constants.AllStatesGuid, Name = Constants.AllStatesName });

                        return result;
                    });
            
            vm.CollectionUtilities = collectionUtilities;

            vm.Roles =
                new ObservableCollection<RoleInfo>(
                    new[] { new RoleInfo { Id = Constants.AllRolesId, Name = Constants.AllRolesName }, new RoleInfo { Id = 1, Name = "Role 1" }, new RoleInfo { Id = 2, Name = "Role 2" } });

            vm.BusinessUnits =
                new ObservableCollection<BusinessUnitInfo>(
                    new[]
                        {
                            new BusinessUnitInfo { Id = Constants.AllBusinessUnitsId, Name = Constants.AllBusinessUnitsName }, new BusinessUnitInfo { Id = 1, Name = "BU 1" },
                            new BusinessUnitInfo { Id = 2, Name = "BU 2" }
                        });

            vm.SelectedCommand = vm.Model.CommandList.First();
            vm.SecurityConfigurationList.Add(ProcessCommandSecurityConfigurationEdit.NewProcessCommandSecurityConfigurationEdit());
            vm.OnRefreshed();

            Assert.AreEqual(1, vm.Model.CommandList[0].SecurityConfigurationList.Count);

            //default description
            Assert.AreEqual(1, vm.Model.CommandList[0].SecurityConfigurationList.Count);
            var configuration = vm.Model.CommandList[0].SecurityConfigurationList[0];
            Assert.IsTrue(configuration.BusinessUnitName.Equals(Constants.AllBusinessUnitsName) && configuration.RoleName.Equals(Constants.AllRolesName));

            configuration = vm.Model.CommandList[0].SecurityConfigurationList[0];
            vm.SelectedSecurityConfiguration = configuration;
            vm.SelectedRoleId = 1;
            vm.SelectedBusinessUnitId = 2;

            //first configuration
            Assert.AreEqual(1, vm.Model.CommandList[0].SecurityConfigurationList.Count);
            Assert.IsTrue(vm.RoleName.Equals("Role 1") && vm.BusinessUnitName.Equals("BU 2"));

            vm.SecurityConfigurationList.Add(ProcessCommandSecurityConfigurationEdit.NewProcessCommandSecurityConfigurationEdit());

            configuration = vm.Model.CommandList[0].SecurityConfigurationList[1];
            vm.SelectedSecurityConfiguration = configuration;
            vm.SelectedRoleId = 2;
            vm.SelectedBusinessUnitId = 1;

            //second configuration
            Assert.AreEqual(2, vm.Model.CommandList[0].SecurityConfigurationList.Count);
            Assert.IsTrue(vm.RoleName.Equals("Role 2") && vm.BusinessUnitName.Equals("BU 1"));

            Ioc.InjectContainer(null);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:81,代码来源:ProcessCommandsViewModelTest.cs

示例14: WhenProcessStatesIsChanged_ProcessCommandTabStatesUpdated

        public void WhenProcessStatesIsChanged_ProcessCommandTabStatesUpdated()
        {
            var catalog = new TypeCatalog();

            var container = new CompositionContainer(catalog, false);

            var expressionServiceBase = Mock.Create<IExpressionServiceBase>(Behavior.Loose);
            container.ComposeExportedValue(expressionServiceBase);

            Ioc.InjectContainer(container);

            var vm = new ProcessCommandsViewModel();
            var process = new ProcessEditMock();
            var processEditExtensionsMock = Mock.Create<ProcessEditExtensions>();
            process.ProcessEditExtensions = processEditExtensionsMock;

            vm.Model = process;

            var collectionUtilities = Mock.Create<ICollectionUtilities>();

            Mock.Arrange(() => collectionUtilities.SortStatesInfoWithAll(Arg.IsAny<IEnumerable<StateEdit>>())).Returns<IEnumerable<StateEdit>>(
                list =>
                    {
                        var result = new ObservableCollection<StateInfo>(list.Select(s => new StateInfo { Name = s.Name, Guid = s.Guid }));

                        if (result.All(x => x.Guid != Constants.AllStatesGuid)) result.Insert(0, new StateInfo { Guid = Constants.AllStatesGuid, Name = Constants.AllStatesName });

                        return result;
                    });

            vm.CollectionUtilities = collectionUtilities;

            process.ProcessOptionChoose = ProcessOption.VersionEnabled;

            Assert.AreEqual(1, vm.Model.CommandList.Count);

            var statesBeforechanges = vm.StateInfoList.Count;

            ((BindingList<StateEdit>)process.StateList).AddNew();

            Assert.AreEqual(statesBeforechanges + 1, vm.StateInfoList.Count);

            Ioc.InjectContainer(null);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:44,代码来源:ProcessCommandsViewModelTest.cs


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