public MainViewModel(IApriori apriori, IResult resultWindow)
 {
     _items = new ObservableSet<Item>();
     _transactions = new ObservableCollection<string>();
     this._apriori = apriori;
     this._resultWindow = resultWindow;
 }
Esempio n. 2
0
 public void TestAdd()
 {
     var list = new List<string> { "aaa", "bbb", "ccc" };
     var set = new ObservableSet<string>(list);
     bool propertyChangedInvoked = false;
     bool collectionChangedInvoked = false;
     Assert.AreEqual(set.Count, list.Count);
     set.PropertyChanged += (sender, e) =>
     {
         Assert.AreEqual(e.PropertyName, nameof(ObservableSet<string>.Count));
         propertyChangedInvoked = true;
     };
     set.CollectionChanged += (sender, e) =>
     {
         Assert.AreEqual(e.Action, NotifyCollectionChangedAction.Add);
         Assert.AreEqual(e.NewStartingIndex, 3);
         Assert.NotNull(e.NewItems);
         Assert.AreEqual(e.NewItems.Count, 1);
         Assert.AreEqual(e.NewItems[0], "ddd");
         collectionChangedInvoked = true;
     };
     set.Add("ddd");
     Assert.AreEqual(set[0], "aaa");
     Assert.AreEqual(set[1], "bbb");
     Assert.AreEqual(set[2], "ccc");
     Assert.AreEqual(set[3], "ddd");
     Assert.True(propertyChangedInvoked);
     Assert.True(collectionChangedInvoked);
 }
Esempio n. 3
0
 public void TestIndexerSetException()
 {
     var list = new List<string> { "aaa", "bbb", "ccc" };
     var set = new ObservableSet<string>(list);
     Assert.Throws<InvalidOperationException>(() => set[1] = "ccc");
     Assert.AreEqual(set[0], "aaa");
     Assert.AreEqual(set[1], "bbb");
     Assert.AreEqual(set[2], "ccc");
 }
Esempio n. 4
0
 public void TestIndexerSet()
 {
     var list = new List<string> { "aaa", "bbb", "ccc" };
     var set = new ObservableSet<string>(list) { [1] = "ddd" };
     Assert.AreEqual(set.Count, 3);
     Assert.That(set.Contains("aaa"));
     Assert.That(set.Contains("ddd"));
     Assert.That(set.Contains("ccc"));
 }
Esempio n. 5
0
 public void TestEnumerableConstructorWithDuplicate()
 {
     var list = new List<string> { "aaa", "bbb", "ccc", "bbb" };
     var set = new ObservableSet<string>(list);
     Assert.AreEqual(set.Count, 3);
     Assert.That(set.Contains("aaa"));
     Assert.That(set.Contains("bbb"));
     Assert.That(set.Contains("ccc"));
 }
Esempio n. 6
0
 public void TestEnumerableConstructor()
 {
     var list = new List<string> { "aaa", "bbb", "ccc" };
     var set = new ObservableSet<string>(list);
     Assert.AreEqual(set.Count, list.Count);
     Assert.AreEqual(set[0], "aaa");
     Assert.AreEqual(set[1], "bbb");
     Assert.AreEqual(set[2], "ccc");
 }
			/// <summary>
			/// A simple constructor that initializes the object with the given values.
			/// </summary>
			/// <param name="p_txTransaction">The transaction into which we are enlisting.</param>
			/// <param name="p_aplPluginLog">The <see cref="ActivePluginLog"/> whose actions are being transacted.</param>
			public TransactionEnlistment(Transaction p_txTransaction, ActivePluginLog p_aplPluginLog)
			{
				CurrentTransaction = p_txTransaction;
				EnlistedPluginLog = p_aplPluginLog;
				m_ostActivePlugins = new ObservableSet<Plugin>(EnlistedPluginLog.m_ostActivePlugins, PluginComparer.Filename);
				m_rolActivePlugins = new ReadOnlyObservableList<Plugin>(m_ostActivePlugins);

				EnlistedPluginLog.m_ostActivePlugins.CollectionChanged += new NotifyCollectionChangedEventHandler(MasterPlugins_CollectionChanged);
			}
Esempio n. 8
0
 public ServerWrapper()
 {
     Players = new ObservableSet<Player>();
     consoleData = new ObservableCollection<ConsoleInput>();
     TimeSpan ramspan = new TimeSpan(0, 0, 0, 1);
     ramtimer = new Timer();
     ramtimer.Interval = ramspan.TotalMilliseconds;
     ramtimer.Elapsed += ramtimer_Elapsed;
     Stopped = true;
 }
        public static async Task <ComputationViewModel> CreateAsync(
            GameData gameData, IBuilderFactories builderFactories,
            ObservableCalculator observableCalculator, ComputationSchedulerProvider schedulers,
            ObservableSet <IReadOnlyList <Skill> > skills)
        {
            var skillDefinitions = await gameData.Skills;
            var vm = new ComputationViewModel(observableCalculator, schedulers);
            await vm.InitializeAsync(skillDefinitions, builderFactories, skills);

            return(vm);
        }
        public void TestContains()
        {
            var list = new List <string> {
                "aaa", "bbb", "ccc"
            };
            var set = new ObservableSet <string>(list);

            Assert.That(set.Contains("aaa"));
            Assert.That(set.Contains("bbb"));
            Assert.That(set.Contains("ccc"));
            Assert.That(!set.Contains("ddd"));
        }
Esempio n. 11
0
        public void TestEnumerableConstructor()
        {
            var list = new List <string> {
                "aaa", "bbb", "ccc"
            };
            var set = new ObservableSet <string>(list);

            Assert.Equal(list.Count, set.Count);
            Assert.Equal("aaa", set[0]);
            Assert.Equal("bbb", set[1]);
            Assert.Equal("ccc", set[2]);
        }
Esempio n. 12
0
        public void TestEnumerableConstructorWithDuplicate()
        {
            var list = new List <string> {
                "aaa", "bbb", "ccc", "bbb"
            };
            var set = new ObservableSet <string>(list);

            Assert.Equal(3, set.Count);
            Assert.Contains("aaa", set);
            Assert.Contains("bbb", set);
            Assert.Contains("ccc", set);
        }
        public void TestEnumerableConstructor()
        {
            var list = new List <string> {
                "aaa", "bbb", "ccc"
            };
            var set = new ObservableSet <string>(list);

            Assert.AreEqual(set.Count, list.Count);
            Assert.AreEqual(set[0], "aaa");
            Assert.AreEqual(set[1], "bbb");
            Assert.AreEqual(set[2], "ccc");
        }
Esempio n. 14
0
        public void TestContains()
        {
            var list = new List <string> {
                "aaa", "bbb", "ccc"
            };
            var set = new ObservableSet <string>(list);

            Assert.Contains("aaa", set);
            Assert.Contains("bbb", set);
            Assert.Contains("ccc", set);
            Assert.DoesNotContain("ddd", set);
        }
Esempio n. 15
0
        public void TestIndexerSetException()
        {
            var list = new List <string> {
                "aaa", "bbb", "ccc"
            };
            var set = new ObservableSet <string>(list);

            Assert.Throws <InvalidOperationException>(() => set[1] = "ccc");
            Assert.Equal("aaa", set[0]);
            Assert.Equal("bbb", set[1]);
            Assert.Equal("ccc", set[2]);
        }
Esempio n. 16
0
        /// <summary>
        /// Will perform an Add or Insert on the given Collection depending on whether the
        /// insertIndex is null or not. If it is null, will Add, otherwise, will Insert.
        /// </summary>
        public void AddOrInsertItemTest(ObservableSet <string> collection, string itemToAdd, int?insertIndex = null)
        {
            INotifyPropertyChanged collectionPropertyChanged = collection;

            collectionPropertyChanged.PropertyChanged += Collection_PropertyChanged;
            _expectedPropertyChanged = new[]
            {
                new PropertyNameExpected(COUNT),
                //new PropertyNameExpected(ITEMARRAY)
            };

            collection.CollectionChanged += Collection_CollectionChanged;

            ExpectedCollectionChangedFired++;
            ExpectedAction   = NotifyCollectionChangedAction.Add;
            ExpectedNewItems = new string[] { itemToAdd };
            if (insertIndex.HasValue)
            {
                ExpectedNewStartingIndex = insertIndex.Value;
            }
            else
            {
                ExpectedNewStartingIndex = collection.Count;
            }
            ExpectedOldItems         = null;
            ExpectedOldStartingIndex = -1;

            int expectedCount = collection.Count + 1;

            if (insertIndex.HasValue)
            {
                //collection.Insert(insertIndex.Value, itemToAdd);
                //Assert.Equal(itemToAdd, collection[insertIndex.Value]);
            }
            else
            {
                collection.Add(itemToAdd);
                Assert.Equal(itemToAdd, collection.ToArray()[collection.Count - 1]);
            }

            Assert.Equal(expectedCount, collection.Count);
            Assert.Equal(ExpectedCollectionChangedFired, NumCollectionChangedFired);


            foreach (var item in _expectedPropertyChanged)
            {
                Assert.True(item.IsFound, "The propertychanged event should have fired for" + item.Name + ", since we just added an item");
            }

            collection.CollectionChanged -= Collection_CollectionChanged;
            collectionPropertyChanged.PropertyChanged -= Collection_PropertyChanged;
        }
Esempio n. 17
0
        public void AddSameIdentifier()
        {
            var set = new ObservableSet <SerialMessage>(new SerialMessageSameIdentifier())
            {
                SerialMessage.Parse("DEADBEEF|01-02-03-04-05-06-07-08"),
                SerialMessage.Parse("DEADBEEF|00-00-00-00-00-00-00-00"),
                SerialMessage.Parse("DEADBEEF|FF-FF-FF-FF-AA-AA-AA-AA")
            };

            Assert.AreEqual(1, set.Count);
            Assert.AreEqual(set[0].Data.Bytes.First(), 0xFF);
            Assert.AreEqual(set[0].Data.Bytes.Last(), 0xAA);
        }
Esempio n. 18
0
        public void InsertItemTest()
        {
            //Arrange
            ObservableSet <string> target = new ObservableSet <string>();
            var item = "Item";

            //Act
            target.Add(item);
            target.Add(item);

            //Assert
            Assert.AreEqual(1, target.Count);
        }
Esempio n. 19
0
        public void InsertItemTest()
        {
            //Arrange
            ObservableSet<string> target = new ObservableSet<string>();
            var item = "Item";

            //Act
            target.Add(item);
            target.Add(item);

            //Assert
            Assert.AreEqual(1, target.Count);
        }
Esempio n. 20
0
        public void SetOperationsTest()
        {
            const int initialCount = 15;
            const int removeItems  = 4;
            const int insertItems  = 2;
            var       items        = new[] { 40, 63, 98, 20, 24, 76, 96, 53, 5, 11, 29, 12, 46, 59, 7, 45, 86, 91, 57, 95 };
            var       indexes      = new[] { 6, 2, 5, 11, 0, 3, 13, 1 };

            var originalSet = new HashSet <Person>(items.Take(initialCount).Select(x => new Person(x)), new PersonEqualityComparer());
            var set         = new ObservableSet <Person>(originalSet);
            var sorted      = new SortedReadOnlyObservableList <Person>(set, (x, y) => x.Age.CompareTo(y.Age),
                                                                        new PersonEqualityComparer(), nameof(Person.Age));

            Assert.AreEqual(initialCount, set.Count);
            Assert.AreEqual(initialCount, sorted.Count);
            Assert.IsTrue(items.Take(initialCount).Select(x => new Person(x)).OrderBy(p => p.Age).SequenceEqual(sorted, new PersonEqualityComparer()));

            foreach (var person in indexes.Take(removeItems).Select(i => new Person(items[i])))
            {
                set.Remove(person);
            }

            Assert.AreEqual(initialCount - removeItems, set.Count);
            Assert.AreEqual(initialCount - removeItems, sorted.Count);
            Assert.IsTrue(originalSet.OrderBy(p => p.Age).SequenceEqual(sorted, new PersonEqualityComparer()));

            foreach (var person in items.Skip(initialCount).Take(insertItems).Select(x => new Person(x)))
            {
                set.Add(person);
            }

            Assert.AreEqual(initialCount - removeItems + insertItems, set.Count);
            Assert.AreEqual(initialCount - removeItems + insertItems, sorted.Count);
            Assert.IsTrue(originalSet.OrderBy(p => p.Age).SequenceEqual(sorted, new PersonEqualityComparer()));

            foreach (var result in indexes.Skip(removeItems)
                     .Zip(items.Skip(initialCount + insertItems),
                          (i, x) => new { OldItem = new Person(items[i]), NewItem = new Person(x) }))
            {
                set.SymmetricExceptWith(new[] { result.OldItem, result.NewItem });
            }

            Assert.AreEqual(initialCount - removeItems + insertItems, set.Count);
            Assert.AreEqual(initialCount - removeItems + insertItems, sorted.Count);
            Assert.IsTrue(originalSet.OrderBy(p => p.Age).SequenceEqual(sorted, new PersonEqualityComparer()));

            set.Clear();

            Assert.AreEqual(0, set.Count);
            Assert.AreEqual(0, sorted.Count);
        }
Esempio n. 21
0
        public void AddMultiple()
        {
            var set = new ObservableSet <SerialMessage>(new SerialMessageSameIdentifier())
            {
                SerialMessage.Parse("DEADBEEF|01-02-03-04-05-06-07-08"),
                SerialMessage.Parse("DEADBEEC|01-02-03-04-05-06-07-08"),
                SerialMessage.Parse("DEADBEED|00-00-00-00-00-00-00-00"),
                SerialMessage.Parse("DEADBEEF|FF-FF-FF-FF-FF-FF-FF-FF")
            };

            Assert.AreEqual(3, set.Count);
            Assert.IsFalse(set.Any(x => x.Equals(SerialMessage.Parse("DEADBEEF|01-02-03-04-05-06-07-08"))));
            Assert.IsTrue(set.Any(x => x.Equals(SerialMessage.Parse("DEADBEEF|FF-FF-FF-FF-FF-FF-FF-FF"))));
        }
Esempio n. 22
0
        public void ConnectTo(ItemAttributes itemAttributes)
        {
            if (_skillEnabler != null)
            {
                _skillEnabler.EnabledChangedForSlots -= SkillEnablerOnEnabledChangedForSlots;
            }
            _skillEnabler         = itemAttributes.SkillEnabler;
            _itemAttributesSkills = itemAttributes.Skills;

            Collection.ResetTo(GetDefaultSkills().Select(Update));
            _itemAttributesSkills.ResetTo(Collection);

            _skillEnabler.EnabledChangedForSlots += SkillEnablerOnEnabledChangedForSlots;
        }
Esempio n. 23
0
        /// <summary>
        /// Empty trace configuration, connected to <paramref name="logManagerConfig"/>.
        /// </summary>
        public TraceManagerConfig(LogManagerConfig logManagerConfig)
        {
            Contract.Requires <ArgumentNullException>(logManagerConfig != null);

            LogManagerConfig = logManagerConfig;

            _traceWriterConfigs               = new ObservableSet <TraceWriterConfig>();
            _traceWriterConfigs.AddingItem   += OnAddingTraceWriterConfig;
            _traceWriterConfigs.RemovingItem += OnRemovingTraceWriterConfig;

            var observableLogWriterConfigSet = (ObservableSet <ILogWriterConfig>)logManagerConfig.Writers;

            observableLogWriterConfigSet.RemovingItem += OnRemovingLogWriterConfig;
        }
        public void TestIndexerSet()
        {
            var list = new List <string> {
                "aaa", "bbb", "ccc"
            };
            var set = new ObservableSet <string>(list)
            {
                [1] = "ddd"
            };

            Assert.AreEqual(set.Count, 3);
            Assert.That(set.Contains("aaa"));
            Assert.That(set.Contains("ddd"));
            Assert.That(set.Contains("ccc"));
        }
Esempio n. 25
0
        public void TestIndexerSet()
        {
            var list = new List <string> {
                "aaa", "bbb", "ccc"
            };
            var set = new ObservableSet <string>(list)
            {
                [1] = "ddd"
            };

            Assert.Equal(3, set.Count);
            Assert.Contains("aaa", set);
            Assert.Contains("ddd", set);
            Assert.Contains("ccc", set);
        }
Esempio n. 26
0
        public static void GetEnumeratorTest()
        {
            Guid[] anArray           = { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            ObservableSet <Guid> col = new ObservableSet <Guid>((IEnumerable <Guid>)anArray);

            int i = 0;
            IEnumerator <Guid> e;

            for (e = col.GetEnumerator(); e.MoveNext(); ++i)
            {
                Assert.Equal(anArray[i], e.Current);
            }
            Assert.Equal(col.Count, i);
            e.Dispose();
        }
        private async Task InitializeAsync(
            SkillDefinitions skillDefinitions, IBuilderFactories f, ObservableSet <IReadOnlyList <Skill> > skills)
        {
            MainSkillSelection = MainSkillSelectionViewModel.Create(skillDefinitions, f, _nodeFactory, skills);

            InitializeOffensiveStats(f);
            InitializeDefensiveStats(f);

            ConfigurationStats = await ConfigurationStatsViewModel.CreateAsync(_observableCalculator, _nodeFactory);

            AddConfigurationStat(f.StatBuilders.Level, Entity.Enemy);

            GainOnActionStats = await GainOnActionStatsViewModel.CreateAsync(_observableCalculator, _nodeFactory);

            SharedConfiguration = SharedConfigurationViewModel.Create(_nodeFactory, f);
        }
Esempio n. 28
0
        internal MainViewModel()
        {
            Settings = SettingsUtility.Get();

            if (string.IsNullOrEmpty(Settings.Port))
            {
                Settings.Port = Options.Ports.FirstOrDefault();
            }

            FirstChunkMath  = "$A + $B + $C + $D / 256";
            SecondChunkMath = "$E + $F + $G + $H / 256";

            Messages                 = new ObservableSet <SerialMessage>(new SerialMessageSameIdentifier());
            MessageViewSource        = CollectionViewSource.GetDefaultView(Messages);
            MessageViewSource.Filter = FilterMessages;
        }
Esempio n. 29
0
        public void add_object_should_raise_collectionchanged()
        {
            int  value          = 1;
            var  observableSet  = new ObservableSet <int>();
            bool eventWasRaised = false;

            observableSet.CollectionChanged += (sender, args) =>
            {
                sender.Should().Be.EqualTo(observableSet);
                args.Action.Should().Be.EqualTo(NotifyCollectionChangedAction.Add);
                args.NewItems[0].Should().Be.EqualTo(value);
                eventWasRaised = true;
            };
            observableSet.Add(value);
            eventWasRaised.Should().Be.True();
        }
Esempio n. 30
0
        public static void ClearTest()
        {
            string[] anArray           = { "one", "two", "three", "four" };
            ObservableSet <string> col = new ObservableSet <string>(anArray);

            col.Clear();
            Assert.Equal(0, col.Count);
            Assert.Empty(col);

            //AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => col.ToArray()[1]);

            //tests that the collectionChanged events are fired.
            CollectionAndPropertyChangedTester helper = new CollectionAndPropertyChangedTester();

            col = new ObservableSet <string>(anArray);
            helper.ClearTest(col);
        }
Esempio n. 31
0
        public void TestIndexOf()
        {
            var list = new List <string> {
                "aaa", "bbb", "ccc"
            };
            var set = new ObservableSet <string>(list);

            Assert.Equal(set.IndexOf("aaa"), 0);
            Assert.Equal(set.IndexOf("bbb"), 1);
            Assert.Equal(set.IndexOf("ccc"), 2);
            Assert.Equal(set.IndexOf("ddd"), -1);
            set.Add("ddd");
            Assert.Equal(set.IndexOf("ddd"), 3);
            set.Remove("bbb");
            Assert.Equal(set.IndexOf("bbb"), -1);
            Assert.Equal(set.IndexOf("ddd"), 2);
        }
Esempio n. 32
0
 public void Initialize()
 {
     _set = new ObservableSet <string>
     {
         "item 1",
         "item 2",
         "item 3"
     };
     _set.CollectionChanged += (sender, args) => _collectionChangedInvocations++;
     _set.PropertyChanged   += (sender, args) =>
     {
         _propertyChangedInvocations++;
         Assert.AreEqual(nameof(ObservableSet <string> .Count), args.PropertyName);
     };
     _collectionChangedInvocations = 0;
     _propertyChangedInvocations   = 0;
 }
Esempio n. 33
0
        public void TestIndexOf()
        {
            var list = new List <string> {
                "aaa", "bbb", "ccc"
            };
            var set = new ObservableSet <string>(list);

            Assert.Equal(0, set.IndexOf("aaa"));
            Assert.Equal(1, set.IndexOf("bbb"));
            Assert.Equal(2, set.IndexOf("ccc"));
            Assert.Equal(-1, set.IndexOf("ddd"));
            set.Add("ddd");
            Assert.Equal(3, set.IndexOf("ddd"));
            set.Remove("bbb");
            Assert.Equal(-1, set.IndexOf("bbb"));
            Assert.Equal(2, set.IndexOf("ddd"));
        }
Esempio n. 34
0
        public void clear_should_raise_collectionchanged()
        {
            bool eventWasRaised = false;


            var observableSet = new ObservableSet <int> {
                1, 2, 3
            };

            observableSet.CollectionChanged += (sender, args) =>
            {
                sender.Should().Be.EqualTo(observableSet);
                args.Action.Should().Be.EqualTo(
                    NotifyCollectionChangedAction.Reset);
                eventWasRaised = true;
            };

            observableSet.Clear();
            eventWasRaised.Should().Be.True();
        }
        private async Task InitializeAsync(
            GameData gameData, IBuilderFactories f, ObservableSet <IReadOnlyList <Skill> > skills)
        {
            MainSkillSelection = MainSkillSelectionViewModel.Create(await gameData.Skills, f, _nodeFactory, skills);

            InitializeOffensiveStats(f);
            InitializeDefensiveStats(f);

            ConfigurationStats = await ConfigurationStatsViewModel.CreateAsync(_observableCalculator, _nodeFactory);

            AddConfigurationStat(f.StatBuilders.Level, Entity.Enemy);

            GainOnActionStats = await GainOnActionStatsViewModel.CreateAsync(_observableCalculator, _nodeFactory);

            SharedConfiguration    = SharedConfigurationViewModel.Create(_nodeFactory, f);
            IndependentResultStats = await IndependentResultStatsViewModel.CreateAsync(_observableCalculator, _nodeFactory);

            PassiveTreeConnections = await PassiveTreeConnectionsViewModel.CreateAsync(_observableCalculator, _nodeFactory);

            AttributesInJewelRadius = new AttributesInJewelRadiusViewModel(await gameData.PassiveTree, f, _observableCalculator);
        }
Esempio n. 36
0
        public static void ContainsTest()
        {
            string[] anArray = new string[] { "one", "two", "three", "four" };
            ObservableSet <string> collection = new ObservableSet <string>((IEnumerable <string>)anArray);
            string collectionString           = "";

            foreach (var item in collection)
            {
                collectionString += item + ", ";
            }

            for (int i = 0; i < collection.Count; ++i)
            {
                Assert.True(collection.Contains(anArray[i]), "ObservableCollection did not contain the item: " + anArray[i] + " Collection: " + collectionString);
            }

            string g = "six";

            Assert.False(collection.Contains(g), "Collection contained an item that should not have been there. guid: " + g + " Collection: " + collectionString);
            Assert.False(collection.Contains(null), "Collection should not have contained null. Collection: " + collectionString);
        }
Esempio n. 37
0
        public void SetOperationsTest()
        {
            var values = new[] { 15, 14, 89, 56, 8, 68, 17, 39, 31, 93, 78, 80, 87, 85, 57, 20, 6, 1 };

            var people     = new ObservableSet <Observable>(values.Select(x => new Observable(x)).ToList());
            var transfList = new DynamicTransformingReadOnlyObservableList <Observable, int>(people,
                                                                                             x => x.Subject);
            var copy = new TransformingReadOnlyObservableList <int, int>(transfList, x => x);

            Assert.AreEqual(people.Count, transfList.Count);
            Assert.IsTrue(new HashSet <int>(people.Select(x => x.Prop)).SetEquals(transfList));
            Assert.IsTrue(new HashSet <int>(people.Select(x => x.Prop)).SetEquals(copy));

            people.Add(new Observable(19));
            people.First().Prop = 82;
            people.Remove(people.Last());

            Assert.AreEqual(people.Count, transfList.Count);
            Assert.IsTrue(new HashSet <int>(people.Select(x => x.Prop)).SetEquals(transfList));
            Assert.IsTrue(new HashSet <int>(people.Select(x => x.Prop)).SetEquals(copy));
        }
Esempio n. 38
0
        public void remove_should_raise_collectionchanged()
        {
            bool eventWasRaised = false;


            var observableSet = new ObservableSet <int> {
                1, 2, 3
            };

            observableSet.CollectionChanged += (sender, args) =>
            {
                sender.Should().Be.EqualTo(observableSet);
                args.Action.Should().Be.EqualTo(
                    NotifyCollectionChangedAction.Remove);
                args.OldItems[0].Should().Be.EqualTo(2);
                args.OldStartingIndex.Should().Be.EqualTo(1);
                eventWasRaised = true;
            };

            observableSet.Remove(2);
            eventWasRaised.Should().Be.True();
        }
        public void Reentrancy_MultipleListeners_Throws()
        {
            bool handler1Called = false;
            bool handler2Called = false;

            var collection = new ObservableSet <int>();

            collection.CollectionChanged += (sender, e) => { handler1Called = true; };
            collection.CollectionChanged += (sender, e) =>
            {
                handler2Called = true;

                // More than one listener; throws.
                Assert.Throws <InvalidOperationException>(() => collection.Add(2));
            };
            collection.Add(1);

            Assert.True(handler1Called);
            Assert.True(handler2Called);
            Assert.Equal(1, collection.Count);
            Assert.Equal(1, collection.ToArray()[0]);
        }
Esempio n. 40
0
 public void TestClear()
 {
     var list = new List<string> { "aaa", "bbb", "ccc" };
     var set = new ObservableSet<string>(list);
     Assert.AreEqual(set.Count, list.Count);
     bool propertyChangedInvoked = false;
     bool collectionChangedInvoked = false;
     set.PropertyChanged += (sender, e) =>
     {
         Assert.AreEqual(e.PropertyName, nameof(ObservableSet<string>.Count));
         propertyChangedInvoked = true;
     };
     set.CollectionChanged += (sender, e) =>
     {
         Assert.AreEqual(e.Action, NotifyCollectionChangedAction.Reset);
         collectionChangedInvoked = true;
     };
     set.Clear();
     Assert.AreEqual(set.Count, 0);
     Assert.True(propertyChangedInvoked);
     Assert.True(collectionChangedInvoked);
 }
Esempio n. 41
0
 public void TestContains()
 {
     var list = new List<string> { "aaa", "bbb", "ccc" };
     var set = new ObservableSet<string>(list);
     Assert.That(set.Contains("aaa"));
     Assert.That(set.Contains("bbb"));
     Assert.That(set.Contains("ccc"));
     Assert.That(!set.Contains("ddd"));
 }
Esempio n. 42
0
 public void TestIndexOf()
 {
     var list = new List<string> { "aaa", "bbb", "ccc" };
     var set = new ObservableSet<string>(list);
     Assert.AreEqual(set.IndexOf("aaa"), 0);
     Assert.AreEqual(set.IndexOf("bbb"), 1);
     Assert.AreEqual(set.IndexOf("ccc"), 2);
     Assert.AreEqual(set.IndexOf("ddd"), -1);
     set.Add("ddd");
     Assert.AreEqual(set.IndexOf("ddd"), 3);
     set.Remove("bbb");
     Assert.AreEqual(set.IndexOf("bbb"), -1);
     Assert.AreEqual(set.IndexOf("ddd"), 2);
 }
		/// <summary>
		/// Loads the data from the Install Log file.
		/// </summary>
		private void LoadPluginLog()
		{
			if (m_ostActivePlugins != null)
				m_ostActivePlugins.Clear();
			else
				m_ostActivePlugins = new ObservableSet<Plugin>(PluginComparer.Filename);

			if (LogSerializer != null)
				foreach (string strPlugin in LogSerializer.LoadPluginLog())
					if (!String.IsNullOrEmpty(strPlugin))
						m_ostActivePlugins.Add(ManagedPluginRegistry.GetPlugin(strPlugin));
		}
Esempio n. 44
0
 private GroupSymbol(GroupSymbol original, Cloner cloner)
   : base(original, cloner) {
   symbols = new ObservableSet<ISymbol>(original.Symbols.Select(s => cloner.Clone(s)));
 }
Esempio n. 45
0
 public GroupSymbol(string name, IEnumerable<ISymbol> symbols)
   : base(name, "A symbol which groups other symbols") {
   this.symbols = new ObservableSet<ISymbol>(symbols);
   InitialFrequency = 0.0;
 }
Esempio n. 46
0
 protected GraphVisualizationInfo(GraphVisualizationInfo original, Cloner cloner)
   : base(original, cloner) {
   shapeInfos = new ObservableSet<IShapeInfo>(original.shapeInfos.Select(x => cloner.Clone(x)));
   connectionInfos = new ObservableSet<IConnectionInfo>(original.connectionInfos.Select(x => cloner.Clone(x)));
   initialShape = cloner.Clone(original.initialShape);
 }