Пример #1
0
        public void TestDirectoriesLoadedEvents()
        {
            CreatedEvents.Clear();
            var discCache = new DiscCache();

            discCache.Created += DiscCache_Created;
            discCache.Loaded  += DiscCache_Loaded;

            discCache.LoadAsync(testDir).Wait();

            discCache.Created -= DiscCache_Created;

            var rootDriveCache = discCache.drivesCache[0];

            Assert.AreEqual(CreatedEvents.Count, 4600);
            Assert.AreEqual(CreatedEvents.FindAll(x => x is FileCache).Sum(x => x.Length), rootDriveCache.Length);
        }
Пример #2
0
 public override bool Equals(object obj)
 {
     return(this.Compare(obj, rhs => _hashCode == rhs._hashCode && Offset == rhs.Offset && WorkflowId == rhs.WorkflowId && !CreatedEvents.Except(rhs.CreatedEvents).Any()));
 }
Пример #3
0
        public void TestMethodLoadAndParents()
        {
            var discCache = new DiscCache();
            var discSpaceCanvasViewModel = new DiscSpaceCanvasViewModel();

            discCache.Created += discSpaceCanvasViewModel.Manager.Create;
            discCache.Loaded  += discSpaceCanvasViewModel.Manager.Load;

            discSpaceCanvasViewModel.Manager.Loaded  += discSpaceCanvasViewModel.Loaded;
            discSpaceCanvasViewModel.Manager.Created += discSpaceCanvasViewModel.Create;
            discSpaceCanvasViewModel.Manager.Created += Manager_Created;

            discCache.LoadAsync(testDir).Wait();

            foreach (var rectangle in discSpaceCanvasViewModel.VisibleRectangles)
            {
                Assert.IsNotNull(rectangle.ManagerRectangle);
            }

            Assert.IsNotNull(discSpaceCanvasViewModel.VisibleRoot);

            Assert.AreEqual(discSpaceCanvasViewModel.VisibleRoot.Height, 600);
            Assert.AreEqual(discSpaceCanvasViewModel.VisibleRectangles.Count, 31);

            Assert.AreEqual(discSpaceCanvasViewModel.VisibleRectangles.Where(x => x.Parent == discSpaceCanvasViewModel.VisibleRoot).Count(), 3);

            Assert.AreEqual(discSpaceCanvasViewModel.VisibleRoot.ChildrenRectangle.Count, 3);
            Assert.AreEqual(discSpaceCanvasViewModel.VisibleRoot.ChildrenRectangle[0].Height, 600 - 6);
            Assert.AreEqual(discSpaceCanvasViewModel.VisibleRoot.ChildrenRectangle[1].Height, 600 - 6);
            Assert.AreEqual(discSpaceCanvasViewModel.VisibleRoot.ChildrenRectangle[2].Height, 600 - 6);

            //Assert.AreEqual(discSpaceCanvasViewModel.VisibleRoot.Children[2].Width + discSpaceCanvasViewModel.VisibleRoot.Children[2].X, 600 - 6);

            Assert.AreEqual(discSpaceCanvasViewModel.VisibleRoot.ChildrenRectangle[0].X, 3);
            Assert.AreNotEqual(discSpaceCanvasViewModel.VisibleRoot.ChildrenRectangle[1].X, 3);
            Assert.AreNotEqual(discSpaceCanvasViewModel.VisibleRoot.ChildrenRectangle[2].X, 3);

            Assert.AreEqual(discSpaceCanvasViewModel.VisibleRoot.ChildrenRectangle[0].Y, 3);
            Assert.AreEqual(discSpaceCanvasViewModel.VisibleRoot.ChildrenRectangle[1].Y, 3);
            Assert.AreEqual(discSpaceCanvasViewModel.VisibleRoot.ChildrenRectangle[2].Y, 3);

            var first = discSpaceCanvasViewModel.VisibleRoot.ChildrenRectangle[0];

            Assert.AreEqual(first.Children.Count(), 2);
            Assert.AreEqual(first.ChildrenRectangle[0].Width, first.Width - 6);
            Assert.AreEqual(first.ChildrenRectangle[1].Width, first.Width - 6);

            Assert.AreEqual(first.ChildrenRectangle[0].X, first.X + 3);
            Assert.AreEqual(first.ChildrenRectangle[1].X, first.X + 3);

            Assert.AreEqual(first.ChildrenRectangle[0].Y, first.Y + 3);
            Assert.AreNotEqual(first.ChildrenRectangle[1].Y, first.Y + 3);

            var second = discSpaceCanvasViewModel.VisibleRoot.ChildrenRectangle[1];

            Assert.AreEqual(second.Children.Count(), 2);
            Assert.AreEqual(second.ChildrenRectangle[0].Width, second.Width - 6);
            Assert.AreEqual(second.ChildrenRectangle[1].Width, second.Width - 6);

            Assert.AreEqual(second.ChildrenRectangle[0].Parent, second);
            Assert.AreEqual(second.ChildrenRectangle[1].Parent, second);

            Assert.AreEqual(second.ChildrenRectangle[0].X, second.X + 3);
            Assert.AreEqual(second.ChildrenRectangle[1].X, second.X + 3);

            Assert.AreEqual(second.ChildrenRectangle[0].Y, second.Y + 3);
            Assert.AreNotEqual(second.ChildrenRectangle[1].Y, second.Y + 3);

            Assert.AreEqual(CreatedEvents.Where(x => x.Height >= 6 && x.Width >= 6).Count(), discSpaceCanvasViewModel.VisibleRectangles.Count);
        }