/// <summary> /// Pobiera kolekcje z bazy danych i pakuje je w kontenery /// </summary> private async Task GetContainers() { try { HttpWorkItemCollectionClient client = new HttpWorkItemCollectionClient(); IEnumerable <WorkItemCollectionPublic> response = await client.GetAllWorkItemCollections(mTaskBoard.ID).ConfigureAwait(false); foreach (WorkItemCollectionPublic wic in response) { wic.WorkItems = new List <WorkItemPublic>(); await GetWorkItems(wic).ConfigureAwait(false); } await Application.Current.Dispatcher.BeginInvoke(() => { foreach (WorkItemCollectionPublic wic in response) { ContainerCollection.Add(new CtrlWorkItemContainer(mContext, wic)); } }); } catch (Exception ex) { mContext.DialogBuilder.ErrorDialog("Could not retrieve collections, due to server error.", ex); } }
//containers.MouseMove += OnMouseMove; //containers.MouseLeave += OnMouseLeave; //containers.MouseLeftButtonDown += OnMousePress; //containers.MouseLeftButtonUp += OnMouseRelease; #else protected override void OnApplyTemplate() { Containers = this.GetTemplateChild("PART_containers") as ContainerCollection; if (Containers != null) { Containers.Chart = this; } RootDockPanel = this.GetTemplateChild("Part_rootDockPanel") as RootPanel; #endif #if WPF Containers.ClipToBounds = true; #else foreach (SeriesBase series in Series) { Binding dataContextBinding = new Binding { Path = new PropertyPath("DataContext"), Source = this }; BindingOperations.SetBinding(series, SeriesBase.DataContextProperty, dataContextBinding); } #endif BrushTheme(); base.OnApplyTemplate(); legend = (Legend.Legend) this.GetTemplateChild("Part_Legend"); InnerChartPanel = (Grid)this.GetTemplateChild("Part_InnerChartPanel"); OuterChartPanel = (Grid)this.GetTemplateChild("Part_OuterChartPanel"); RefreshLegend(); }
public void Delete_unknown_object_from_container_should_throw() { swiftConnectionData = KeystoneData.GetKeystoneToken(); tokenSource = new CancellationTokenSource(); swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant); ContainerCollection containerCollection = null; Assert.DoesNotThrow(() => { var tsk = swiftclient.GetContainers(tokenSource.Token); containerCollection = tsk.Result; }); Assert.NotNull(containerCollection); Container container = containerCollection.First(); SwiftObject badObject = new SwiftObject() { Name = "##I_am_super_bad##" }; Assert.Throws(typeof(AggregateException), () => { var tsk = swiftclient.DeleteObject(container, badObject, tokenSource.Token); var coll = tsk.Result; Assert.NotNull(coll); }); }
public void TestMethod1() { ContainerCollection containerCollection = new ContainerCollection(); Container container1 = new Container { Weight = 30, IsRefrigerated = false, IsValuable = false }; for (int i = 0; i < 21; i++) { containerCollection.Add(container1); } //containerCollection.Add(container5); //containerCollection.Add(container6); containerCollection.OrderByWeight(); Ship ship = new Ship(); //Deck deck = new Deck(); Row row = new Row(4); //Act row.AddRefrigerated(containerCollection.GetContainers()); //ship.PlaceContainersOnShip(containerCollection.GetContainers()); //deck.Add(containerCollection.GetContainers(), 4); //Assert //Assert.AreEqual(4, row.GetStacks().Count); Assert.AreEqual(1, ship); }
/// <summary> /// Metoda dodajaca nowy kontener do obserwowalnej kolekcji kontenerow /// </summary> private async Task AddContainer() { try { HttpWorkItemCollectionClient client = new HttpWorkItemCollectionClient(); WorkItemCollectionPublic workItemCollection = new WorkItemCollectionPublic() { Name = "Unnamed Collection", TaskBoardID = mTaskBoard.ID }; WorkItemCollectionPublic response = await client.CreateWorkItemCollection(workItemCollection).ConfigureAwait(false); response.WorkItems = new List <WorkItemPublic>(); await Application.Current.Dispatcher.BeginInvoke(() => { ContainerCollection.Add(new CtrlWorkItemContainer(mContext, response)); }); } catch (Exception ex) { mContext.DialogBuilder.ErrorDialog("Could not create a collection, due to server error.", ex); } }
public void Should_throw_on_container_that_does_not_exist() { byte[] bRndName = new byte[10]; new Random().NextBytes(bRndName); string containerName = System.Text.Encoding.Default.GetString(bRndName); swiftConnectionData = KeystoneData.GetKeystoneToken(); tokenSource = new CancellationTokenSource(); swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant); ContainerCollection containerCollection = null; Assert.DoesNotThrow(() => { var tsk = swiftclient.GetContainers(tokenSource.Token); containerCollection = tsk.Result; }); // // Check that it does not exist Assert.False(containerCollection.Any(c => c.Name.Equals(containerName))); // // Should throw Assert.Throws(typeof(ArgumentNullException), () => { var tsk2 = swiftclient.DeleteContainer(containerName, tokenSource.Token); }); }
public void TestCollectionSerializationWithDeleted() { ShadowObject.Enable = true; var obj = new ContainerCollection("Root") { Strings = { "aaa", "bbb" }, Objects = { new ContainerCollection("obj1"), new ContainerCollection("obj2") } }; var stringIds = CollectionItemIdHelper.GetCollectionItemIds(obj.Strings); stringIds[0] = IdentifierGenerator.Get(8); stringIds[1] = IdentifierGenerator.Get(5); stringIds.MarkAsDeleted(IdentifierGenerator.Get(3)); stringIds.MarkAsDeleted(IdentifierGenerator.Get(1)); var objectIds = CollectionItemIdHelper.GetCollectionItemIds(obj.Objects); objectIds[0] = IdentifierGenerator.Get(3); objectIds[1] = IdentifierGenerator.Get(4); objectIds.MarkAsDeleted(IdentifierGenerator.Get(1)); objectIds.MarkAsDeleted(IdentifierGenerator.Get(6)); var yaml = SerializeAsString(obj); Assert.Equal(YamlCollectionWithDeleted, yaml); }
public void Delete_existing_container() { swiftConnectionData = KeystoneData.GetKeystoneToken(); tokenSource = new CancellationTokenSource(); swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant); ContainerCollection containerCollection = null; string containerName = Guid.NewGuid().ToString(); // // Create container Assert.DoesNotThrow(() => { var tsk = swiftclient.CreateContainer(containerName, tokenSource.Token); containerCollection = tsk.Result; }); Assert.NotNull(containerCollection); Assert.True(containerCollection.Any(c => c.Name.Equals(containerName))); ContainerCollection containerCollection2 = null; Container container = containerCollection.First(c => c.Name.Equals(containerName)); // // Delete this container Assert.DoesNotThrow(() => { var tsk1 = swiftclient.DeleteContainer(container, tokenSource.Token); containerCollection2 = tsk1.Result; }); // // Is not exist in new list Assert.False(containerCollection2.Any(c => c.Name.Equals(containerName))); }
public void Delete_unknown_container_should_fail() { swiftConnectionData = KeystoneData.GetKeystoneToken(); tokenSource = new CancellationTokenSource(); swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant); ContainerCollection containersCollection = null; Assert.DoesNotThrow(() => { var tsk = swiftclient.GetContainers(tokenSource.Token); containersCollection = tsk.Result; }); Assert.NotNull(containersCollection); string validUri = containersCollection.First().Endpoint.ToString(); validUri = validUri.Substring(0, validUri.LastIndexOf("/")); Container badContainer = new Container() { Endpoint = new Uri(validUri + "/" + "##I_am_super_bad##") }; Assert.Throws(typeof(AggregateException), () => { var tsk = swiftclient.DeleteContainer(badContainer, tokenSource.Token); var coll = tsk.Result; Assert.Null(coll); }); }
/// <summary> /// When overridden in a derived class, is invoked whenever application code or internal processes (such as a rebuilding layout pass) call <see cref="M:System.Windows.Controls.Control.ApplyTemplate" />. In simplest terms, this means the method is called just before a UI element displays in an application. For more information, see Remarks. /// </summary> public override void OnApplyTemplate() { Containers = (ContainerCollection)this.GetTemplateChild("PART_containers"); if (Containers != null) { Containers.Chart = this; } RootDockPanel = (RootPanel)this.GetTemplateChild("Part_rootDockPanel");
/// <summary> /// Initializes a new instance of the <see cref="SortedReadOnlyObservableList{T}"/> class. /// </summary> /// <param name="source">The source collection.</param> /// <param name="comparison">The comparison used to establish the order of elements.</param> /// <param name="comparer"> /// A comparer for the list items. This is only used if the source collection is not a list /// and does not provide index information in its <see cref="NotifyCollectionChangedEventArgs"/> events. /// </param> /// <param name="triggers">The name of <typeparamref name="T"/>'s properties that can alter the collection's order.</param> public SortedReadOnlyObservableList(IReadOnlyObservableCollection <T> source, Comparison <T> comparison, IEqualityComparer <T> comparer, params string[] triggers) { _source = source; _eqComparer = new ContainerEqualityComparer <T, Container>(comparer); _items = new ContainerCollection(from item in source select new Container(item), new ContainerComparer(comparison), triggers); _items.SortedCollectionChanged += (sender, args) => RaiseEvents(args); CollectionChangedEventManager.AddListener(_source, this); }
public void CreateContainerCollection() { DataCreator <int, Container <Matrix <Position <IPoint <int> > > > > dataCreator = new ContainerCollectionCreator <int, Container <Matrix <Position <IPoint <int> > > > >(); var containerCollection = dataCreator.Create(); var expectedContainerCollection = new ContainerCollection <Container <Matrix <Position <IPoint <int> > > > >(); var expectedType = expectedContainerCollection.GetType(); var realType = containerCollection.GetType(); Assert.AreEqual(expectedType, realType); }
/// <summary> /// 创建一个储存库 /// </summary> /// <param name="conn">连接的数据库</param> public Storage(SQLiteConnection conn) : base(conn) { _transaction = conn.BeginTransaction(); _filtersLocker = new object(); _containersLocker = new object(); _contianerTemplateLocker = new object(); _filters = new FilterCollection(); _containers = new ContainerCollection(); _containerTemplate = new ContainerTemplate(conn); }
public bool AddContainer(IContainer container, List <IStack> stacksOnXAxis) { if (Check(container, stacksOnXAxis)) { ContainerCollection.Add(container); if (container.Valuable) { HasValuable = true; } return(true); } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="SortedReadOnlyObservableList{TSource}"/> class. /// </summary> /// <param name="source">The source collection.</param> /// <param name="keySelector">The key generator.</param> /// <param name="comparison">The comparison used to establish the order of elements (and keys).</param> /// <param name="comparer"> /// A comparer for the list items. This is only used if the source collection is not a list /// and does not provide index information in its <see cref="NotifyCollectionChangedEventArgs"/> events. /// </param> public KeySortedReadOnlyObservableList(IEnumerable <TSource> source, Func <TSource, IObservable <TKey> > keySelector, Comparison <TKey> comparison, IEqualityComparer <TSource> comparer) { _source = source ?? throw new ArgumentNullException(nameof(source)); _keySelector = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); _eqComparer = new ContainerEqualityComparer <TSource, Container>(comparer); _items = new ContainerCollection(from item in source select new Container(item, keySelector(item)), new ContainerComparer(comparison)); _items.SortedCollectionChanged += (sender, args) => RaiseEvents(args); if (_source is INotifyCollectionChanged notifier) { CollectionChangedEventManager.AddListener(notifier, this); } }
public void Delete_all_objects_for_all_containers() { swiftConnectionData = KeystoneData.GetKeystoneToken(); tokenSource = new CancellationTokenSource(); swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant); ContainerCollection containerCollection = null; Assert.DoesNotThrow(() => { var tsk = swiftclient.GetContainers(tokenSource.Token); containerCollection = tsk.Result; }); Assert.NotNull(containerCollection); List <Tuple <Container, SwiftObjectsCollection> > listOfEverything = new List <Tuple <Container, SwiftObjectsCollection> >(); containerCollection.ForEach(container => { Assert.DoesNotThrow(() => { var tsk2 = swiftclient.GetObjects(container, tokenSource.Token); listOfEverything.Add(new Tuple <Container, SwiftObjectsCollection>(container, tsk2.Result)); }); }); Assert.True(listOfEverything.Count > 0); foreach (Tuple <Container, SwiftObjectsCollection> record in listOfEverything) { SwiftObjectsCollection originalCollection = record.Item2; SwiftObjectsCollection generatedCollection = null; originalCollection.ForEach(obj => { Assert.DoesNotThrow(() => { System.Diagnostics.Trace.WriteLine("[Objects] Going to delete object: " + obj.Name + " from container: " + record.Item1.Name); var tsk3 = swiftclient.DeleteObject(record.Item1, obj, tokenSource.Token); generatedCollection = tsk3.Result; }); Assert.NotNull(generatedCollection); Assert.False(originalCollection.Intersect(generatedCollection).Count() == originalCollection.Count); }); } }
public void Add_2NormalContainers_MoreThan30tons_Error() { //arrange ContainerCollection containerCollection = new ContainerCollection(2, 2); //assumption is to add two cooled containers Container container = new Container { Weight = 31 }; Container container1 = new Container { Weight = 32 }; //act containerCollection.AddCn(container); containerCollection.AddCn(container1); //assert Assert.AreEqual(0, containerCollection.GetCc().Count); }
public void Add_2CooledContainers_MoreThan30tons_Error() { //arrange ContainerCollection containerCollection = new ContainerCollection(2, 2); //assumption is to add two cooled containers Container container = new Container { Weight = 31, IsRefrigerated = true }; Container container1 = new Container { Weight = 32, IsRefrigerated = true }; //act containerCollection.AddCc(container); containerCollection.AddCc(container1); //assert Assert.AreEqual(0, containerCollection.GetCc().Count); }
public void Work_normally() { swiftConnectionData = KeystoneData.GetKeystoneToken(); tokenSource = new CancellationTokenSource(); swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant); ContainerCollection containerCollection = null; Assert.DoesNotThrow(() => { var tsk = swiftclient.GetContainers(tokenSource.Token); containerCollection = tsk.Result; }); Assert.NotNull(containerCollection); System.Diagnostics.Trace.WriteLine("Found: " + containerCollection.Count.ToString() + " containers"); containerCollection.AsParallel().ForAll(cont => System.Diagnostics.Trace.WriteLine("Container name: " + cont.Name + " Endpoint: " + cont.Endpoint.ToString())); }
public Repository(string databaseName) { TMDbClient = new TMDbClient("1915ba01826b36e88f574596aa8a7e54", false); ImageClient = new HttpClient(); ImageClient.BaseAddress = new Uri("http://image.tmdb.org/t/p/"); YouTubeClient = new HttpClient(); YouTubeClient.BaseAddress = new Uri("http://img.youtube.com/vi/"); DirectoryInfo directory = Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data")); LiteDatabase database = new LiteDatabase(Path.Combine(directory.FullName, databaseName)); FileStorage = database.FileStorage; Movies = new ContainerCollection <MovieContainer>(database, "Movies"); People = new ContainerCollection <PersonContainer>(database, "People"); TvShows = new ContainerCollection <TvShowContainer>(database, "TvShows"); }
public void Create_container_and_enshure_it() { swiftConnectionData = KeystoneData.GetKeystoneToken(); tokenSource = new CancellationTokenSource(); swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant); ContainerCollection containerCollection = null; string containerName = Guid.NewGuid().ToString(); Assert.DoesNotThrow(() => { var tsk = swiftclient.CreateContainer(containerName, tokenSource.Token); containerCollection = tsk.Result; }); Assert.NotNull(containerCollection); Assert.True(containerCollection.Any(c => c.Name.Equals(containerName))); }
/// <summary> /// Dodaje workItem do kontenera /// </summary> public void AddWorkItemToContainer(WorkItemMediator m, WorkItemEventArgs e) { Ensure.ParamNotNull(e, nameof(e)); WorkItemPublic workItem = e.WorkItem; CtrlWorkItemContainer container = ContainerCollection.FirstOrDefault(cc => ((WorkItemContainerViewModel)cc.DataContext).WorkItemCollection.ID == workItem.WorkItemCollectionID); WorkItemContainerViewModel wic = (WorkItemContainerViewModel)container.DataContext; WorkItemPublic wi = wic.WorkItems.FirstOrDefault(wi => wi.ID == workItem.ID); if (wi == null) { wic.WorkItems.Add(workItem); } else { int index = wic.WorkItems.IndexOf(wi); wic.WorkItems.Remove(wi); wic.WorkItems.Insert(index, workItem); } }
public void Fill_FirstRow_CooledContainersAndValuableContainers_Succes() // Check to always stack valuable on top for first row { //arrange Ship ship = new Ship(2, 2, 20); ContainerCollection containerCollection = new ContainerCollection(2, 2); Container cc = new Container { Weight = 10, IsRefrigerated = true }; Container cc1 = new Container { Weight = 10, IsRefrigerated = true }; Container cv = new Container { Weight = 10, IsValuable = true }; Container cv2 = new Container { Weight = 10, IsValuable = true }; containerCollection.AddCc(cc); containerCollection.AddCc(cc1); containerCollection.AddCv(cv); containerCollection.AddCv(cv2); List <Container> cLastRow = new List <Container>(); cLastRow = ship.ListForFirstRow(containerCollection.GetCc(), containerCollection.GetCv()); bool bCool = true; //Last Row contains cooled containers Stack stack = new Stack(); //act ship.AddFirstLastRow(cLastRow, bCool); //assert foreach (Row row in ship.GetRows()) { row.GetStacks(); Assert.IsTrue(row.GetStacks().Last().BValuable); Assert.IsFalse(row.GetStacks().First().BValuable); } }
public void Fill_LastRow_NormalContainersAndValuableContainers_Succes() // Check to always stack valuable on top for last row { //arrange Ship ship = new Ship(2, 2, 20); ContainerCollection containerCollection = new ContainerCollection(2, 2); Container cn = new Container { Weight = 10 }; Container cn1 = new Container { Weight = 10 }; Container cv = new Container { Weight = 10, IsValuable = true }; Container cv2 = new Container { Weight = 10, IsValuable = true }; containerCollection.AddCn(cn); containerCollection.AddCn(cn1); containerCollection.AddCv(cv); containerCollection.AddCv(cv2); List <Container> cLastRow = new List <Container>(); cLastRow = ship.ListForLastRow(containerCollection.GetCn(), containerCollection.GetCv()); bool bCool = false; //Last Row doesn't contain cooled containers Stack stack = new Stack(); //act ship.AddFirstLastRow(cLastRow, bCool); //assert foreach (Row row in ship.GetRows()) { row.GetStacks(); Assert.IsTrue(row.GetStacks().Last().BValuable); Assert.IsFalse(row.GetStacks().First().BValuable); } }
public void Check_TotalLoadWeight_Ship20ton_Add_TwoCcContainers_4Ton_False() { //arrange Ship ship = new Ship(2, 2, 20); ContainerCollection containerCollection = new ContainerCollection(2, 2); //assumption is to add two cooled containers Container container = new Container { Weight = 31, IsRefrigerated = true }; Container container1 = new Container { Weight = 32, IsRefrigerated = true }; containerCollection.AddCc(container); containerCollection.AddCc(container1); //act ship.CheckLoadWeight(containerCollection.GetCn(), containerCollection.GetCv(), containerCollection.GetCc()); //assert Assert.IsFalse(ship.CheckLoadWeight(containerCollection.GetCn(), containerCollection.GetCv(), containerCollection.GetCc())); }
public void TestCollectionSerializationWithDeleted() { ShadowObject.Enable = true; var obj = new ContainerCollection("Root") { Strings = { "aaa", "bbb" }, Objects = { new ContainerCollection("obj1"), new ContainerCollection("obj2") } }; var stringIds = CollectionItemIdHelper.GetCollectionItemIds(obj.Strings); stringIds[0] = IdentifierGenerator.Get(8); stringIds[1] = IdentifierGenerator.Get(5); stringIds.MarkAsDeleted(IdentifierGenerator.Get(3)); stringIds.MarkAsDeleted(IdentifierGenerator.Get(1)); var objectIds = CollectionItemIdHelper.GetCollectionItemIds(obj.Objects); objectIds[0] = IdentifierGenerator.Get(3); objectIds[1] = IdentifierGenerator.Get(4); objectIds.MarkAsDeleted(IdentifierGenerator.Get(1)); objectIds.MarkAsDeleted(IdentifierGenerator.Get(6)); var yaml = SerializeAsString(obj); Assert.AreEqual(YamlCollectionWithDeleted, yaml); }
public void RemoveContainer(ContainerInfo container) { // remove container from this section Common.DatabaseProvider.RemoveSectionContainerLink(this, container); // reset containers collection this._Containers = null; }
/// <summary> /// Usuwa kontener /// </summary> public void DeleteContainer(WorkItemMediator m, WorkItemCollectionEventArgs e) { ContainerCollection.Remove(ContainerCollection.FirstOrDefault(cc => ((WorkItemContainerViewModel)cc.DataContext).WorkItemCollection == e.Collection)); }
private void InvalidateExternalContainersCollections(object sender, EventArgs e) { this._Containers = null; }
public void TestIdsGeneration() { ShadowObject.Enable = true; CollectionItemIdentifiers ids; var obj1 = new ContainerCollection("Root") { Strings = { "aaa", "bbb", "ccc" }, Objects = { new ContainerCollection("obj1"), new ContainerCollection("obj2") } }; var hashSet = new HashSet <ItemId>(); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj1.Strings, out ids)); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj1.Strings, out ids)); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj1.Objects, out ids)); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj1.Objects, out ids)); AssetCollectionItemIdHelper.GenerateMissingItemIds(obj1); Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(obj1.Strings, out ids)); Assert.Equal(3, ids.KeyCount); Assert.Equal(0, ids.DeletedCount); Assert.True(ids.ContainsKey(0)); Assert.True(ids.ContainsKey(1)); Assert.True(ids.ContainsKey(2)); hashSet.Add(ids[0]); hashSet.Add(ids[1]); hashSet.Add(ids[2]); Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(obj1.Objects, out ids)); Assert.Equal(2, ids.KeyCount); Assert.Equal(0, ids.DeletedCount); Assert.True(ids.ContainsKey(0)); Assert.True(ids.ContainsKey(1)); hashSet.Add(ids[0]); hashSet.Add(ids[1]); Assert.Equal(5, hashSet.Count); var obj2 = new ContainerDictionary("Root") { Strings = { { GuidGenerator.Get(200), "aaa" }, { GuidGenerator.Get(100), "bbb" }, { GuidGenerator.Get(300), "ccc" } }, Objects = { { "key3", new ContainerCollection("obj1") }, { "key4", new ContainerCollection("obj2") } }, }; hashSet.Clear(); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj2.Strings, out ids)); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj2.Strings, out ids)); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj2.Objects, out ids)); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj2.Objects, out ids)); AssetCollectionItemIdHelper.GenerateMissingItemIds(obj2); Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(obj2.Strings, out ids)); Assert.Equal(3, ids.KeyCount); Assert.Equal(0, ids.DeletedCount); Assert.True(ids.ContainsKey(GuidGenerator.Get(200))); Assert.True(ids.ContainsKey(GuidGenerator.Get(100))); Assert.True(ids.ContainsKey(GuidGenerator.Get(300))); hashSet.Add(ids[GuidGenerator.Get(200)]); hashSet.Add(ids[GuidGenerator.Get(100)]); hashSet.Add(ids[GuidGenerator.Get(300)]); Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(obj2.Objects, out ids)); Assert.Equal(2, ids.KeyCount); Assert.Equal(0, ids.DeletedCount); Assert.True(ids.ContainsKey("key3")); Assert.True(ids.ContainsKey("key4")); hashSet.Add(ids["key3"]); hashSet.Add(ids["key4"]); Assert.Equal(5, hashSet.Count); }
public void AddContainer(ContainerInfo container, int order, int position) { // add container to this section Common.DatabaseProvider.AddSectionContainerLink(this, container, order, position); // reset containers collection this._Containers = null; }
public void OpenStatistics() { IFactory <IColorGenerator> colorGeneratorFactory = Factory.Default <RandomColorGenerator>(); ContainerCollection <ContainerCollection <StatisticsViewModel> > viewModel = new ContainerCollection <ContainerCollection <StatisticsViewModel> >(); Stack <StatisticsViewModel> appendTo = new Stack <StatisticsViewModel>(); Container <ContainerCollection <StatisticsViewModel> > allViewModel = new Container <ContainerCollection <StatisticsViewModel> >(); allViewModel.Title = "All"; allViewModel.Data = new ContainerCollection <StatisticsViewModel>() { new Container <StatisticsViewModel>() { Title = "All", Data = new StatisticsViewModel(colorGeneratorFactory.Create()) } }; appendTo.Push(allViewModel.Data[0].Data); viewModel.Add(allViewModel); foreach (IGrouping <int, Month> year in countingService.Months().OrderByDescending(m => m.Year).GroupBy(m => m.Year)) { Container <ContainerCollection <StatisticsViewModel> > yearViewModel = new Container <ContainerCollection <StatisticsViewModel> >(); yearViewModel.Title = year.Key.ToString(); yearViewModel.Data = new ContainerCollection <StatisticsViewModel>(); yearViewModel.Data.Add(new Container <StatisticsViewModel>() { Title = "All", Data = new StatisticsViewModel(colorGeneratorFactory.Create()) }); appendTo.Push(yearViewModel.Data[0].Data); foreach (Month month in year.OrderBy(m => m.Value)) { Container <StatisticsViewModel> monthViewModel = new Container <StatisticsViewModel>(); monthViewModel.Title = month.ToShortString(); monthViewModel.Data = new StatisticsViewModel(colorGeneratorFactory.Create()); appendTo.Push(monthViewModel.Data); foreach (ApplicationCountModel application in countingService.Applications(month, month)) { appendTo.ForEach(vm => vm.AddApplication(application.Path, application.Count)); } foreach (FileCountModel file in countingService.Files(month, month)) { appendTo.ForEach(vm => vm.AddFile(file.Path, file.Count)); } appendTo.Pop(); yearViewModel.Data.Add(monthViewModel); } appendTo.Pop(); viewModel.Add(yearViewModel); } statisticsWindow = new StatisticsWindow(); statisticsWindow.ViewModel = viewModel; statisticsWindow.Owner = configurationWindow; statisticsWindow.Closed += OnStatisticsWindowClosed; statisticsWindow.ShowDialog(); }
IEnumerator <IContainer> IEnumerable <IContainer> .GetEnumerator() { return(ContainerCollection.GetEnumerator()); }
public void TestIdsGeneration() { ShadowObject.Enable = true; CollectionItemIdentifiers ids; var obj1 = new ContainerCollection("Root") { Strings = { "aaa", "bbb", "ccc" }, Objects = { new ContainerCollection("obj1"), new ContainerCollection("obj2") } }; var hashSet = new HashSet<ItemId>(); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj1.Strings, out ids)); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj1.Strings, out ids)); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj1.Objects, out ids)); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj1.Objects, out ids)); AssetCollectionItemIdHelper.GenerateMissingItemIds(obj1); Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(obj1.Strings, out ids)); Assert.AreEqual(3, ids.KeyCount); Assert.AreEqual(0, ids.DeletedCount); Assert.True(ids.ContainsKey(0)); Assert.True(ids.ContainsKey(1)); Assert.True(ids.ContainsKey(2)); hashSet.Add(ids[0]); hashSet.Add(ids[1]); hashSet.Add(ids[2]); Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(obj1.Objects, out ids)); Assert.AreEqual(2, ids.KeyCount); Assert.AreEqual(0, ids.DeletedCount); Assert.True(ids.ContainsKey(0)); Assert.True(ids.ContainsKey(1)); hashSet.Add(ids[0]); hashSet.Add(ids[1]); Assert.AreEqual(5, hashSet.Count); var obj2 = new ContainerDictionary("Root") { Strings = { { GuidGenerator.Get(200), "aaa" }, { GuidGenerator.Get(100), "bbb" }, { GuidGenerator.Get(300), "ccc" } }, Objects = { { "key3", new ContainerCollection("obj1") }, { "key4", new ContainerCollection("obj2") } }, }; hashSet.Clear(); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj2.Strings, out ids)); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj2.Strings, out ids)); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj2.Objects, out ids)); Assert.False(CollectionItemIdHelper.TryGetCollectionItemIds(obj2.Objects, out ids)); AssetCollectionItemIdHelper.GenerateMissingItemIds(obj2); Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(obj2.Strings, out ids)); Assert.AreEqual(3, ids.KeyCount); Assert.AreEqual(0, ids.DeletedCount); Assert.True(ids.ContainsKey(GuidGenerator.Get(200))); Assert.True(ids.ContainsKey(GuidGenerator.Get(100))); Assert.True(ids.ContainsKey(GuidGenerator.Get(300))); hashSet.Add(ids[GuidGenerator.Get(200)]); hashSet.Add(ids[GuidGenerator.Get(100)]); hashSet.Add(ids[GuidGenerator.Get(300)]); Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(obj2.Objects, out ids)); Assert.AreEqual(2, ids.KeyCount); Assert.AreEqual(0, ids.DeletedCount); Assert.True(ids.ContainsKey("key3")); Assert.True(ids.ContainsKey("key4")); hashSet.Add(ids["key3"]); hashSet.Add(ids["key4"]); Assert.AreEqual(5, hashSet.Count); }
public IEnumerator GetEnumerator() { return(ContainerCollection.GetEnumerator()); }