public void SetUp() { MongoFlatMapper.EnableFlatMapping(true); MongoDbTestConnectionProvider.ReadModelDb.Drop(); var mngr = new IdentityManager(new CounterService(MongoDbTestConnectionProvider.ReadModelDb)); mngr.RegisterIdentitiesFromAssembly(typeof(DocumentDescriptorId).Assembly); MongoFlatIdSerializerHelper.Initialize(mngr); EventStoreIdentityCustomBsonTypeMapper.Register<DocumentDescriptorId>(); EventStoreIdentityCustomBsonTypeMapper.Register<DocumentId>(); StringValueCustomBsonTypeMapper.Register<BlobId>(); StringValueCustomBsonTypeMapper.Register<DocumentHandle>(); StringValueCustomBsonTypeMapper.Register<FileHash>(); _writer = new DocumentWriter(MongoDbTestConnectionProvider.ReadModelDb); var _documentDescriptorCollection = new MongoReaderForProjections<DocumentDescriptorReadModel, DocumentDescriptorId> ( new MongoStorageFactory(MongoDbTestConnectionProvider.ReadModelDb, new RebuildContext(true))); var _documentDeletedCollection = new CollectionWrapper<DocumentDeletedReadModel, String> ( new MongoStorageFactory(MongoDbTestConnectionProvider.ReadModelDb, new RebuildContext(true)), null); _sut = new DocumentProjection(_writer, _documentDescriptorCollection, _documentDeletedCollection); }
protected void AddFileList(CollectionWrapper<BuildFileWrapper, MFBuildFile> source_list, string path) { List<string> unicue_path_list = new List<string>(); foreach (BuildFileWrapper source_file in source_list) { string text = ExpandPath(source_file.File); if (!File.Exists(text)) { text = Path.GetFullPath(text); } if (!File.Exists(text)) { text = Path.GetFullPath(ExpandPath(Path.GetDirectoryName(path) + "\\" + ExpandPath(source_file.File))); } if (!File.Exists(text)) { } if (!unicue_path_list.Contains(text)) { source_file.FullPath = text; unicue_path_list.Add(text); MFTreeNodeBase SourceNode = new MFSourceFileTreeNode(source_file);//this.NewNode(Path.GetFileName(source_file.File), MFTreeNodeBase.TreeNodeType.SourceFile, source_file, key); this.Nodes.Add(SourceNode); } else { } } }
internal static IDictionary GetDictionary(IDictionary prev, XmlNode region, string nameAtt, string valueAtt) { Hashtable hash; if (prev == null) { hash = new Hashtable(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default); } else { Hashtable aux = (Hashtable)prev; hash = (Hashtable)aux.Clone(); } CollectionWrapper result = new CollectionWrapper(hash); result = GoGetThem(result, region, nameAtt, valueAtt); if (result == null) { return(null); } return(result.UnWrap() as IDictionary); }
public IEnumerator <TElement> GetEnumerator() { foreach (var item in collection) { yield return(CollectionWrapper.Wrap(item)); } }
public IMongoCollection <T> GetCollection <T>(string name = null) { lock (_types) { _types.Add(typeof(T)); return(CollectionWrapper <T> .GetInstance(this, name).GetCollection()); } }
protected void AddFileList(CollectionWrapper <BuildFileWrapper, MFBuildFile> source_list, string path) { List <string> unicue_path_list = new List <string>(); foreach (BuildFileWrapper source_file in source_list) { string text = ExpandPath(source_file.File); if (!File.Exists(text)) { text = Path.GetFullPath(text); } if (!File.Exists(text)) { text = Path.GetFullPath(ExpandPath(Path.GetDirectoryName(path) + "\\" + ExpandPath(source_file.File))); } if (!File.Exists(text)) { } if (!unicue_path_list.Contains(text)) { source_file.FullPath = text; unicue_path_list.Add(text); MFTreeNodeBase SourceNode = new MFSourceFileTreeNode(source_file);//this.NewNode(Path.GetFileName(source_file.File), MFTreeNodeBase.TreeNodeType.SourceFile, source_file, key); this.Nodes.Add(SourceNode); } else { } } }
protected CollectionWrapper <TModel> WrapCollection(TModel[] data, QueryContext context) { Func <TModel, string> cursorSelector = x => x?.ModifiedDate.Ticks.ToString(); var wrapper = new CollectionWrapper <TModel> { Data = data, Paging = new PagingModel() }; if (data.Length == context.Limit) { wrapper.Paging.Before = cursorSelector(data.First()); wrapper.Paging.After = cursorSelector(data.Last()); } else { if (context.BeforeDate.HasValue) { wrapper.Paging.Before = null; wrapper.Paging.After = cursorSelector(data.LastOrDefault()); } else { wrapper.Paging.Before = cursorSelector(data.FirstOrDefault()); wrapper.Paging.After = null; } } return(wrapper); }
private IProjection[] SetupTwoProjectionsError() { _concurrentCheckpointTrackerSut = new ConcurrentCheckpointTracker(_db, 60); var rebuildContext = new RebuildContext(false); var storageFactory = new MongoStorageFactory(_db, rebuildContext); var writer1 = new CollectionWrapper <SampleReadModel, string>(storageFactory, new NotifyToNobody()); var writer2 = new CollectionWrapper <SampleReadModel2, string>(storageFactory, new NotifyToNobody()); var projection1 = new Projection(writer1); var projection2 = new Projection2(writer2); var projections = new IProjection[] { projection1, projection2 }; var p1 = new Checkpoint(projection1.Info.CommonName, 42, projection1.Info.Signature); p1.Current = p1.Value; p1.Slot = projection1.Info.SlotName; _checkPoints.Save(p1, p1.Id); var p2 = new Checkpoint(projection2.Info.CommonName, 40, projection2.Info.Signature); p2.Slot = projection1.Info.SlotName; p2.Current = p2.Value; _checkPoints.Save(p2, p2.Id); _concurrentCheckpointTrackerSut.SetUp(projections, 1, false); _slotStatusCheckerSut = new SlotStatusManager(_db, projections.Select(p => p.Info).ToArray()); return(projections); }
public void SetUp() { MongoDbTestConnectionProvider.ReadModelDb.Drop(); var mngr = new IdentityManager(new CounterService(MongoDbTestConnectionProvider.ReadModelDb)); mngr.RegisterIdentitiesFromAssembly(typeof(DocumentDescriptorId).Assembly); MongoFlatIdSerializerHelper.Initialize(mngr); EventStoreIdentityCustomBsonTypeMapper.Register <DocumentDescriptorId>(); EventStoreIdentityCustomBsonTypeMapper.Register <DocumentId>(); StringValueCustomBsonTypeMapper.Register <BlobId>(); StringValueCustomBsonTypeMapper.Register <DocumentHandle>(); StringValueCustomBsonTypeMapper.Register <FileHash>(); var _writer = new DocumentWriter(MongoDbTestConnectionProvider.ReadModelDb); var _documentDescriptorCollection = new CollectionWrapper <DocumentDescriptorReadModel, DocumentDescriptorId> ( new MongoStorageFactory(MongoDbTestConnectionProvider.ReadModelDb, new RebuildContext(false)), null); _documentReader = new MongoReader <DocumentDescriptorReadModel, DocumentDescriptorId>(MongoDbTestConnectionProvider.ReadModelDb); _sut = new DocumentDescriptorProjection(_documentDescriptorCollection, _writer); }
public void Source_can_be_changed() { var w = new CollectionWrapper<String, Object>(new String[0]); var s1 = w.Source; w.Source = new String[0]; Assert.AreNotSame(s1, w.Source); }
protected override IEnumerable <IProjection> BuildProjections() { _writer1 = new CollectionWrapper <SampleReadModel, string>(_storageFactory, new NotifyToNobody()); yield return(_projection1 = new Projection(_writer1)); _writer3 = new CollectionWrapper <SampleReadModel3, string>(_storageFactory, new NotifyToNobody()); yield return(_projection3 = new Projection3(_writer3)); //projection3 has a different slot }
protected override IEnumerable <IProjection> BuildProjections() { var writer = new CollectionWrapper <SampleReadModel, string>(StorageFactory, new NotifyToNobody()); var writer2 = new CollectionWrapper <SampleReadModel2, string>(StorageFactory, new NotifyToNobody()); yield return(new Projection(writer)); yield return(new Projection2(writer2)); }
public void SetUp() { _client.DropDatabase(_db.DatabaseNamespace.DatabaseName); var rebuildContext = new RebuildContext(false); var storageFactory = new MongoStorageFactory(_db, rebuildContext); sut = new CollectionWrapper <SampleReadModelTestId, TestId>(storageFactory, new NotifyToNobody()); var projection = new ProjectionTypedId(sut); }
public ActiveListWrapper(IActiveValue <IReadOnlyList <T> > source) { _source = source; _collection = new CollectionWrapper <T>(_source.Value); _collection.CountChanged += (s) => NotifyOfPropertyChange(new PropertyChangedEventArgs(nameof(Count))); _collection.CollectionChanged += (s, e) => NotifyOfCollectionChange(e); PropertyChangedEventManager.AddHandler(source, SourceChanged, nameof(IActiveValue <IReadOnlyList <T> > .Value)); }
public void DoStuff(Action <ICollection <int> > task) { lock (_lock) { using (var wrapper = new CollectionWrapper(_instance)) { task(wrapper); } } }
public static InventoryBrowserModel GetModel(CollectionWrapper <ComponentDescriptorWrapper, MFComponentDescriptor> components) { InventoryBrowserModel model = new InventoryBrowserModel(); foreach (ComponentDescriptorWrapper component in components) { model.Roots.Add(new ComponentDescriptorNode(component, null)); } return(model); }
private ActiveJoin(ActiveListJoinBehaviour joinBehaviour, IActiveList <KeyValuePair <TKey, TLeft> > left, IActiveLookup <TKey, TRight> right, IActiveValue <TParameter> parameter, Func <JoinOption <TLeft>, JoinOption <TRight>, TParameter, TResult> resultSelector, IEnumerable <string> leftResultSelectorPropertiesToWatch, IEnumerable <string> rightResultSelectorPropertiesToWatch, IEnumerable <string> resultSelectorParameterPropertiesToWatch) { _joinBehaviour = joinBehaviour; _parameter = parameter; _resultSelector = resultSelector; _leftResultSelectorPropertiesToWatch = leftResultSelectorPropertiesToWatch; _rightResultSelectorPropertiesToWatch = rightResultSelectorPropertiesToWatch; if (parameter != null) { _parameterWatcher = new ValueWatcher <TParameter>(parameter, resultSelectorParameterPropertiesToWatch); _parameterWatcher.ValueOrValuePropertyChanged += () => OnParameterChanged(); } _leftJoiners = new QuickList <ActiveListJoinerData <TLeft, TRight, TResult, TKey> >(); _rightJoiners = new QuickList <ActiveListJoinerData <TLeft, TRight, TResult, TKey> >(); _joinerLookup = new Dictionary <TKey, ActiveListJoinerSet <TLeft, TRight, TResult, TKey> >(); _leftItems = new CollectionWrapper <KeyValuePair <TKey, TLeft> >(left); _leftItems.ItemModified += (s, i, v) => OnLeftReplaced(i, v, v); _leftItems.ItemAdded += (s, i, v) => OnLeftAdded(i, v); _leftItems.ItemRemoved += (s, i, v) => OnLeftRemoved(i, v); _leftItems.ItemReplaced += (s, i, o, n) => OnLeftReplaced(i, o, n); _leftItems.ItemMoved += (s, o, n, v) => OnLeftMoved(o, n, v); _leftItems.ItemsReset += s => FullReset(); _rightItems = right; _rightGroups = new CollectionWrapper <IActiveGrouping <TKey, TRight> >(right); _rightGroups.ItemModified += (s, i, v) => OnRightReplaced(i, v, v); _rightGroups.ItemAdded += (s, i, v) => OnRightAdded(i, v); _rightGroups.ItemRemoved += (s, i, v) => OnRightRemoved(i, v); _rightGroups.ItemReplaced += (s, i, o, n) => OnRightReplaced(i, o, n); _rightGroups.ItemMoved += (s, o, n, v) => OnRightMoved(o, n, v); _rightGroups.ItemsReset += s => FullReset(); _resultList = new ObservableList <TResult>(); _resultList.PropertyChanged += (s, e) => { if (!_fullResetInProgress) { NotifyOfPropertyChange(e); } }; _resultList.CollectionChanged += (s, e) => { if (!_fullResetInProgress) { NotifyOfCollectionChange(e); } }; FullReset(); }
public void AddCollection() { var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 }; var wrapper = new CollectionWrapper <int>() { Collection = { toAdd } }; Assert.AreEqual(toAdd, wrapper.Collection); }
public void TestFixtureSetUp() { var url = new MongoUrl(ConfigurationManager.ConnectionStrings["readmodel"].ConnectionString); var client = new MongoClient(url); var db = client.GetServer().GetDatabase(url.DatabaseName); db.Drop(); _collection = new CollectionWrapper <MyReadModel, string>(new MongoStorageFactory(db, new RebuildContext(false)), new SpyNotifier()); _projection = new MyProjection(_collection); _collection.Attach(_projection); }
public void EqualTest() { Assert.AreNotEqual(cwrapper, ewrapper); IEnumerable <string> cwrapper2 = new CollectionWrapper <string>(list); Assert.AreEqual(cwrapper2, cwrapper); ArrayList list2 = new ArrayList(); list2.Add("four"); IEnumerable <string> cwrapper3 = new CollectionWrapper <string>(list2); Assert.AreNotEqual(cwrapper3, cwrapper); }
public void AddToNullCollection() { var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 }; #pragma warning disable CS8670 // Object or collection initializer implicitly dereferences possibly null member. Assert.Throws <ArgumentNullException>(() => { var wrapper = new CollectionWrapper <int>() { NullCollection = { toAdd } }; }); #pragma warning restore CS8670 // Object or collection initializer implicitly dereferences possibly null member. }
/// <summary> /// This class normally just delegates to the current HttpContext's Session, /// but if that is null, it falls back on the context's Application state, /// prefixing the key with the user name (e.g. "vb:LastUnhandledError" instead of just "LastUnhandledError"). /// It is useful when handling uncaught errors (Global.asax and Authenticate/AppErrors.aspx.cs). /// </summary> private SafeSession() { Context = HttpContext.Current; SessionWrapper = new CollectionWrapper(key => key, (key, val) => { if (Session != null) Session[key] = val; }, key => (Session != null ? Session[key] : null), key => { if (Session != null) Session.Remove(key); }); ApplicationWrapper = new CollectionWrapper(key => string.Format("{0}:{1}", Context.User.Identity.Name, key), (key, val) => { Application[key] = val; }, key => Application[key], key => { Application.Remove(key); }); }
public void SetUp() { _client.DropDatabase(_db.DatabaseNamespace.DatabaseName); var rebuildContext = new RebuildContext(false); var storageFactory = new MongoStorageFactory(_db, rebuildContext); _notifyToSubscribersDouble = Substitute.For <INotifyToSubscribers>(); _notifyToSubscribersDouble.Send(null).ReturnsForAnyArgs(Task.CompletedTask); sut = new CollectionWrapper <SampleReadModelTest, String>(storageFactory, _notifyToSubscribersDouble); //It is important to create the projection to attach the collection wrapper new TypedIdProjection(sut); }
protected Collection <BaseNode> AddFiles(ref List <string> filenames, CollectionWrapper <BuildFileWrapper, MFBuildFile> files, string path) { List <BaseNode> items = new List <BaseNode>(); foreach (BuildFileWrapper file in files) { BuildFileNode fileNode = new BuildFileNode(file, this, path); if (filenames.Contains(fileNode.TypedContent.FullPath) == false) { items.Add(fileNode); filenames.Add(file.FullPath); } } return(new Collection <BaseNode>(items)); }
public void TestFixtureSetUp() { var connectionString = ConfigurationManager.ConnectionStrings["readmodel"].ConnectionString; var url = new MongoUrl(connectionString); _client = new MongoClient(url); _db = _client.GetDatabase(url.DatabaseName); TestHelper.RegisterSerializerForFlatId <TestId>(); var rebuildContext = new RebuildContext(false); var storageFactory = new MongoStorageFactory(_db, rebuildContext); sut = new CollectionWrapper <SampleReadModelPollableTest, TestId>(storageFactory, new NotifyToNobody()); new ProjectionPollableReadmodel(sut); }
public ActiveListListenerBase(IActiveList <TSource> source, IActiveValue <TParameter> parameter, IEnumerable <string> sourcePropertiesToWatch = null, IEnumerable <string> parameterPropertiesToWatch = null) { _sourceList = new CollectionWrapper <TSource>(source, sourcePropertiesToWatch?.ToArray()); _sourceList.ItemModified += (s, i, v) => ItemModified(i, v); _sourceList.ItemAdded += (s, i, v) => OnAdded(i, v); _sourceList.ItemRemoved += (s, i, v) => OnRemoved(i, v); _sourceList.ItemReplaced += (s, i, o, n) => OnReplaced(i, o, n); _sourceList.ItemMoved += (s, o, n, v) => OnMoved(o, n, v); _sourceList.ItemsReset += s => OnReset(s); if (parameter != null) { _parameterWatcher = new ValueWatcher <TParameter>(parameter, parameterPropertiesToWatch); _parameterWatcher.ValueOrValuePropertyChanged += () => OnParameterChanged(); } }
public void GetEnumerator_returns_IEnumerator() { var w = new CollectionWrapper<String, Object>(CreateList()); var er = (w as IEnumerable).GetEnumerator(); Assert.IsTrue(er.MoveNext()); Assert.AreEqual("A", er.Current); Assert.IsTrue(er.MoveNext()); Assert.AreEqual("B", er.Current); Assert.IsTrue(er.MoveNext()); Assert.AreEqual("C", er.Current); Assert.IsFalse(er.MoveNext()); }
protected override IEnumerable <IProjection> BuildProjections() { var writer = new CollectionWrapper <SampleReadModel, string>(StorageFactory, new NotifyToNobody()); var firstProjection = new Projection(writer); //We simulate that projection Projection in slot default was dispatched already at 42. var existingCheckpoint = new Checkpoint("Projection", 42, "signature"); existingCheckpoint.Current = 42; base._checkpoints.Save(existingCheckpoint, existingCheckpoint.Id); yield return(firstProjection); var otherProjectionWriter = new CollectionWrapper <SampleReadModel3, string>(StorageFactory, new NotifyToNobody()); yield return(new Projection3(otherProjectionWriter)); }
private void SetupOneProjectionNew() { _sut = new ConcurrentCheckpointTracker(_db); var rebuildContext = new RebuildContext(false); var storageFactory = new MongoStorageFactory(_db, rebuildContext); var writer1 = new CollectionWrapper <SampleReadModel, string>(storageFactory, new NotifyToNobody()); var writer2 = new CollectionWrapper <SampleReadModel2, string>(storageFactory, new NotifyToNobody()); var projection1 = new Projection(writer1); var projection2 = new Projection2(writer2); var projections = new IProjection[] { projection1, projection2 }; var p1 = new Checkpoint(projection1.GetCommonName(), "42"); p1.Slot = projection1.GetSlotName(); _checkPoints.Save(p1); _sut.SetUp(projections, 1); }
/// <summary> /// If a rebuild starts then stops, we have a particular situation where signature is ok, current is null /// and if the slot is not marked as to rebuild, the engine will simply restart the slot redispatching everything. /// </summary> private void SetupOneProjectionWithCurrentNull() { _concurrentCheckpointTrackerSut = new ConcurrentCheckpointTracker(_db, 60); var rebuildContext = new RebuildContext(false); var storageFactory = new MongoStorageFactory(_db, rebuildContext); var writer1 = new CollectionWrapper <SampleReadModel, string>(storageFactory, new NotifyToNobody()); var projection1 = new Projection(writer1); var projections = new IProjection[] { projection1 }; var p1 = new Checkpoint(projection1.Info.CommonName, 42, projection1.Info.Signature); p1.Slot = projection1.Info.SlotName; p1.Value = 42; p1.Current = null; _checkPoints.Save(p1, p1.Id); _concurrentCheckpointTrackerSut.SetUp(projections, 1, false); _slotStatusCheckerSut = new SlotStatusManager(_db, projections.Select(p => p.Info).ToArray()); }
static void Main(string[] args) { List <int> list = new List <int>(); list.Add(1); list.Add(2); list.Add(3); list.Add(4); CollectionWrapper <int> collection = new CollectionWrapper <int>(list); Console.WriteLine("Count:{0}", collection.Count); foreach (var x in collection) { Console.WriteLine(x); } foreach (var x in (IEnumerable)collection) { Console.WriteLine(x); } }
private void UpdateCells(CollectionWrapper <ProjectWrapper, MFProject> projects) { ProjectDataGridView.Rows.Clear(); ProjectDataGridView.Rows.Add(projects.Count); for (int i = 0; i < projects.Count; i++) { ProjectWrapper proj = sol.Projects[i]; DataGridViewRow row = ProjectDataGridView.Rows[i]; DataGridViewCheckBoxCell CheckBoxCell = (DataGridViewCheckBoxCell)row.Cells[0]; DataGridViewTextBoxCell NameCell = (DataGridViewTextBoxCell)row.Cells[1]; DataGridViewComboBoxCell BuildTypeCell = (DataGridViewComboBoxCell)row.Cells[2]; DataGridViewComboBoxCell MediaTypeCell = (DataGridViewComboBoxCell)row.Cells[3]; CheckBoxCell.Value = true; NameCell.Value = proj.Name.Trim(); BuildTypeCell.Items.Clear(); BuildTypeCell.Items.Add("Debug"); BuildTypeCell.Items.Add("Release"); BuildTypeCell.Items.Add("RTM"); BuildTypeCell.Value = "Debug"; BuildTypeCell.Sorted = false; MediaTypeCell.Items.Clear(); MediaTypeCell.Items.Add("FLASH"); MediaTypeCell.Items.Add("RAM"); MediaTypeCell.Value = "FLASH"; MediaTypeCell.Sorted = false; //BuildTypeCell.Value = "Debug"; //MediaTypeCell.Value = "FLASH"; row.Tag = proj; } }
private void UpdateCells(CollectionWrapper<ProjectWrapper, MFProject> projects) { ProjectDataGridView.Rows.Clear(); ProjectDataGridView.Rows.Add(projects.Count); for (int i = 0; i < projects.Count; i++) { ProjectWrapper proj = sol.Projects[i]; DataGridViewRow row = ProjectDataGridView.Rows[i]; DataGridViewCheckBoxCell CheckBoxCell = (DataGridViewCheckBoxCell)row.Cells[0]; DataGridViewTextBoxCell NameCell = (DataGridViewTextBoxCell)row.Cells[1]; DataGridViewComboBoxCell BuildTypeCell = (DataGridViewComboBoxCell)row.Cells[2]; DataGridViewComboBoxCell MediaTypeCell = (DataGridViewComboBoxCell)row.Cells[3]; CheckBoxCell.Value = true; NameCell.Value = proj.Name.Trim(); BuildTypeCell.Items.Clear(); BuildTypeCell.Items.Add("Debug"); BuildTypeCell.Items.Add("Release"); BuildTypeCell.Items.Add("RTM"); BuildTypeCell.Value = "Debug"; BuildTypeCell.Sorted = false; MediaTypeCell.Items.Clear(); MediaTypeCell.Items.Add("FLASH"); MediaTypeCell.Items.Add("RAM"); MediaTypeCell.Value = "FLASH"; MediaTypeCell.Sorted = false; //BuildTypeCell.Value = "Debug"; //MediaTypeCell.Value = "FLASH"; row.Tag = proj; } }
internal static ConfigNameValueCollection GetNameValueCollection(NameValueCollection prev, XmlNode region, string nameAtt, string valueAtt) { ConfigNameValueCollection coll = new ConfigNameValueCollection(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default); if (prev != null) { coll.Add(prev); } CollectionWrapper result = new CollectionWrapper(coll); result = GoGetThem(result, region, nameAtt, valueAtt); if (result == null) { return(null); } return(result.UnWrap() as ConfigNameValueCollection); }
public void TestMethod1() { Console.WriteLine(CollectionWrapper.Insert("Row 0")); Console.WriteLine(CollectionWrapper.Insert("Row 2")); Console.WriteLine(CollectionWrapper.Insert("Row 4")); Console.WriteLine(CollectionWrapper.Insert("Row 5")); Console.WriteLine(CollectionWrapper.Insert("Row 6")); Console.WriteLine("***"); Console.WriteLine(CollectionWrapper.GetElement()); Console.WriteLine(CollectionWrapper.GetElement()); Console.WriteLine(CollectionWrapper.GetElement()); Console.WriteLine(CollectionWrapper.GetElement()); Console.WriteLine(CollectionWrapper.GetElement()); Console.WriteLine(CollectionWrapper.GetElement()); Console.WriteLine(CollectionWrapper.GetElement()); Console.WriteLine("***"); Console.WriteLine(CollectionWrapper.GetElementAt(1)); Console.WriteLine(CollectionWrapper.GetElementAt(0)); Console.WriteLine(CollectionWrapper.GetCount()); Console.WriteLine(CollectionWrapper.ClearCollection()); Console.WriteLine(CollectionWrapper.ClearCollection()); }
private IProjection[] SetupTwoProjectionsError() { _sut = new ConcurrentCheckpointTracker(_db); var rebuildContext = new RebuildContext(false); var storageFactory = new MongoStorageFactory(_db, rebuildContext); var writer1 = new CollectionWrapper <SampleReadModel, string>(storageFactory, new NotifyToNobody()); var writer2 = new CollectionWrapper <SampleReadModel2, string>(storageFactory, new NotifyToNobody()); var projection1 = new Projection(writer1); var projection2 = new Projection2(writer2); var projections = new IProjection[] { projection1, projection2 }; var p1 = new Checkpoint(projection1.GetCommonName(), 42, projection1.GetSignature()); p1.Slot = projection1.GetSlotName(); _checkPoints.Save(p1, p1.Id); var p2 = new Checkpoint(projection2.GetCommonName(), 40, projection2.GetSignature()); p2.Slot = projection1.GetSlotName(); _checkPoints.Save(p2, p2.Id); _sut.SetUp(projections, 1, false); return(projections); }
public void IsReadOnly_returns_the_readonly_status_of_its_source() { var w = new CollectionWrapper<String, Object>(CreateList()); Assert.IsFalse(w.IsReadOnly); var w2 = new CollectionWrapper<String, Object>(new String[0]); Assert.IsTrue(w2.IsReadOnly); }
internal static ConfigNameValueCollection GetNameValueCollection (NameValueCollection prev, XmlNode region, string nameAtt, string valueAtt) { ConfigNameValueCollection coll = new ConfigNameValueCollection (CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default); if (prev != null) coll.Add (prev); CollectionWrapper result = new CollectionWrapper (coll); result = GoGetThem (result, region, nameAtt, valueAtt); if (result == null) return null; return result.UnWrap () as ConfigNameValueCollection; }
public void Contains_returns_the_existence_of_an_element() { var w = new CollectionWrapper<String, Object>(CreateList()); Assert.IsTrue(w.Contains("A")); Assert.IsFalse(w.Contains("D")); }
public void Source_throws_when_value_is_null() { var w = new CollectionWrapper<String, Object>(new String[0]); Assert.Throws<ArgumentNullException>(() => w.Source = null).ForArg("value"); }
public void Clear_clears_items() { var w = new CollectionWrapper<String, Object>(CreateList()); w.Clear(); Assert.AreEqual(0, w.Count); }
public void Add_adds_new_item_to_Source() { var w = new CollectionWrapper<String, Object>(CreateList()); w.Add("D"); Assert.IsTrue(CollectionUtil.ArrayEquals(new[] {"A", "B", "C", "D"}, w.Source.ToArray())); }
internal static IDictionary GetDictionary (IDictionary prev, XmlNode region, string nameAtt, string valueAtt) { Hashtable hash; if (prev == null) hash = new Hashtable (CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default); else { Hashtable aux = (Hashtable) prev; hash = (Hashtable) aux.Clone (); } CollectionWrapper result = new CollectionWrapper (hash); result = GoGetThem (result, region, nameAtt, valueAtt); if (result == null) return null; return result.UnWrap () as IDictionary; }
private static CollectionWrapper GoGetThem (CollectionWrapper result, XmlNode region, string nameAtt, string valueAtt) { if (region.Attributes != null && region.Attributes.Count != 0) { if (region.Attributes.Count != 1 || region.Attributes[0].Name != "xmlns") { throw new ConfigurationException ("Unknown attribute", region); } } XmlNode keyNode; XmlNode valueNode; XmlNodeList childs = region.ChildNodes; foreach (XmlNode node in childs) { XmlNodeType ntype = node.NodeType; if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment) continue; if (ntype != XmlNodeType.Element) throw new ConfigurationException ("Only XmlElement allowed", node); string nodeName = node.Name; if (nodeName == "clear") { if (node.Attributes != null && node.Attributes.Count != 0) throw new ConfigurationException ("Unknown attribute", node); result.Clear (); } else if (nodeName == "remove") { keyNode = null; if (node.Attributes != null) keyNode = node.Attributes.RemoveNamedItem (nameAtt); if (keyNode == null) throw new ConfigurationException ("Required attribute not found", node); if (keyNode.Value == String.Empty) throw new ConfigurationException ("Required attribute is empty", node); if (node.Attributes.Count != 0) throw new ConfigurationException ("Unknown attribute", node); result.Remove (keyNode.Value); } else if (nodeName == "add") { keyNode = null; if (node.Attributes != null) keyNode = node.Attributes.RemoveNamedItem (nameAtt); if (keyNode == null) throw new ConfigurationException ("Required attribute not found", node); if (keyNode.Value == String.Empty) throw new ConfigurationException ("Required attribute is empty", node); valueNode = node.Attributes.RemoveNamedItem (valueAtt); if (valueNode == null) throw new ConfigurationException ("Required attribute not found", node); if (node.Attributes.Count != 0) throw new ConfigurationException ("Unknown attribute", node); result [keyNode.Value] = valueNode.Value; } else { throw new ConfigurationException ("Unknown element", node); } } return result; }
public void CopyTo_copies_elements_to_array() { var w = new CollectionWrapper<String, Object>(CreateList()); Object[] dest = new object[w.Count]; w.CopyTo(dest, 0); Assert.IsTrue(CollectionUtil.ArrayEquals(new object[] {"A", "B", "C"}, dest)); }
public void Remove_removes_element_from_collection() { var w = new CollectionWrapper<String, Object>(CreateList()); w.Remove("B"); Assert.AreEqual(new Object[] {"A", "C"}, w.ToArray()); }