public MessageListViewModel(IMessageListView view, IApplicationController appc) : base(view, appc) { Parser = new ParserEngine(); _browseLimit = App.UserSettings.BrowseLimit; Messages = new SelectableItemCollection <MessageInfo>(); BindingOperations.EnableCollectionSynchronization(Messages, _syncLock); Progress = new RangeProgress(); Filter = new BrowseFilter(); BuildCommands(); AvailableConverters = new List <LabelValuePair <IByteCharConverter> > { new LabelValuePair <IByteCharConverter> { Label = "CP-1252", Value = new DefaultByteCharConverter() }, new LabelValuePair <IByteCharConverter> { Label = "EBCDIC", Value = new EbcdicByteCharConverter() } }; _currentConverter = AvailableConverters[0].Value; StatusInfoViewModel = new MessageListStatusInfo(this); }
public void ShouldSelectAllItemsInCollection() { // arrange var target = new SelectableItemCollection<string>( new[] { "1", "2", "3" }, "All" ); // assert - initial state Assert.Equal( "All", target[0].Value ); Assert.Equal( 4, target.Count ); Assert.Equal( 0, target.SelectedItems.Count ); Assert.Equal( 0, target.SelectedValues.Count ); // act - select all items target[0].IsSelected = true; // assert - all items selected Assert.Equal( true, target[0].IsSelected ); Assert.Equal( 3, target.SelectedItems.Count ); Assert.Equal( 3, target.SelectedValues.Count ); // act - unselect one item, which causes the 'All' item to be indeterminate (null) target.SelectedItems[0].IsSelected = false; // assert - item unselected Assert.Null( target[0].IsSelected ); Assert.Equal( 2, target.SelectedItems.Count ); Assert.Equal( 2, target.SelectedValues.Count ); // act - unselect all items target[0].IsSelected = false; // assert - all items unselected Assert.Equal( false, target[0].IsSelected ); Assert.Equal( 0, target.SelectedItems.Count ); Assert.Equal( 0, target.SelectedValues.Count ); }
internal QueueListViewModel(QueueManagerViewModel parent) { Progress = new RangeProgress(); BuildCommands(); Queues = new SelectableItemCollection <QueueInfo>(); BindingOperations.EnableCollectionSynchronization(Queues, new object()); Parent = parent; StatusInfoViewModel = new QueueListStatusInfo(this); }
public void ItemsPropertyShouldReturnExpectedResults() { // arrange var expected = new[] { "1", "2", "3" }; var collection = new SelectableItemCollection<string>( expected ); var target = new SelectableItemCollectionDebugView<string>( collection ); // act var actual = target.Items.Select( i => i.Value ); // assert Assert.True( actual.SequenceEqual( expected ) ); }
public void SelectedItemsPropertyShouldReturnExpectedResults() { // arrange var items = new[] { "1", "2", "3" }; var collection = new SelectableItemCollection<string>( items ); var target = new SelectableItemCollectionDebugView<string>( collection ); collection.ForEach( i => i.IsSelected = true ); // act var actual = target.SelectedItems; // assert Assert.True( actual.SequenceEqual( collection ) ); }
public void ShouldUnselectValueInCollectionOnClear() { // arrange var target = new SelectableItemCollection<string>( new[] { "1", "2", "3" } ); var expectedProperties = new[] { "Count", "Item[]" }; var actualProperties = new List<string>(); target.SelectedValues.Add( "2" ); ( (INotifyPropertyChanged) target.SelectedValues ).PropertyChanged += ( s, e ) => actualProperties.Add( e.PropertyName ); // act target.SelectedValues.Clear(); // assert Assert.Equal( 0, target.SelectedItems.Count ); Assert.True( actualProperties.SequenceEqual( expectedProperties ) ); }
public void ShouldSelectItemInCollection() { // arrange var target = new SelectableItemCollection<string>( new[] { "1", "2", "3" } ); // act - select target[1].IsSelected = true; // assert - selected Assert.Equal( 1, target.SelectedItems.Count ); Assert.Equal( 1, target.SelectedValues.Count ); Assert.Equal( "2", target.SelectedItems[0].Value ); Assert.Equal( "2", target.SelectedValues[0] ); // act - unselect target.SelectedItems[0].IsSelected = false; // assert - unselected Assert.Equal( 0, target.SelectedItems.Count ); Assert.Equal( 0, target.SelectedValues.Count ); }
public MainWindow() { InitializeComponent(); DataContext = new SelectableItemCollection(); }