예제 #1
0
        public void AnyTestStatusAll()
        {
            FileObjectCollection foc = new FileObjectCollection();

            Assert.IsFalse(foc.Any(FileStatus.all));

            foc.Add(new FileObject());
            Assert.IsTrue(foc.Any(FileStatus.all));

            foc.Clear();
            Assert.IsFalse(foc.Any());
            foc.Add(new FileObject()
            {
                Status = FileStatus.downloading
            });
            Assert.IsTrue(foc.Any(FileStatus.all));

            foc.Clear();
            Assert.IsFalse(foc.Any());
            foc.AddRange(new FileObject[2] {
                new FileObject()
                {
                    Status = FileStatus.downloading
                }, new FileObject()
                {
                    Status = FileStatus.downloading
                }
            });
            Assert.IsTrue(foc.Count(FileStatus.all) == 2);

            foc.Clear();
            Assert.IsFalse(foc.Any());
            foc.AddRange(new FileObject[2] {
                new FileObject()
                {
                    Status = FileStatus.downloading
                }, new FileObject()
                {
                    Status = FileStatus.unknown
                }
            });
            Assert.IsTrue(foc.Count(FileStatus.all) == 2);
        }
예제 #2
0
        public void AnyTestAll()
        {
            FileStatus           fsAllOptions = FileStatus.uploading | FileStatus.downloading | FileStatus.enumerated | FileStatus.existing | FileStatus.failed | FileStatus.formatting | FileStatus.queued | FileStatus.succeeded;
            FileObjectCollection foc          = new FileObjectCollection();

            Assert.IsFalse(foc.Any(fsAllOptions));

            foc.Add(new FileObject());
            Assert.IsFalse(foc.Any(fsAllOptions));

            foc.Add(new FileObject()
            {
                Status = FileStatus.unknown
            });
            Assert.IsFalse(foc.Any(fsAllOptions));

            foc.Add(new FileObject()
            {
                Status = FileStatus.enumerated
            });
            Assert.IsTrue(foc.Any(fsAllOptions));

            foc.Clear();
            Assert.IsFalse(foc.Any());
            foc.AddRange(new FileObject[4]
            {
                new FileObject()
                {
                    Status = FileStatus.uploading
                },
                new FileObject()
                {
                    Status = FileStatus.downloading
                },
                new FileObject()
                {
                    Status = FileStatus.downloading
                },
                new FileObject()
                {
                    Status = FileStatus.failed
                },
            });
            Assert.IsTrue(foc.Any(fsAllOptions));

            Assert.IsTrue(foc.Count(fsAllOptions) == 4, $"expected:4 got:{foc.Count(fsAllOptions)}");
        }
예제 #3
0
        public void FindAllSingleTest()
        {
            FileStatus           fsSingleOption = FileStatus.failed;
            FileObjectCollection foc            = new FileObjectCollection();

            Assert.IsFalse(foc.FindAll(fsSingleOption).Count > 0);

            foc.Add(new FileObject());
            Assert.IsFalse(foc.FindAll(fsSingleOption).Count > 0);

            foc.Add(new FileObject()
            {
                Status = FileStatus.unknown
            });
            Assert.IsFalse(foc.FindAll(fsSingleOption).Count > 0);

            foc.Add(new FileObject()
            {
                Status = fsSingleOption
            });
            Assert.IsTrue(foc.FindAll(fsSingleOption).Count > 0);

            foc.Clear();
            Assert.IsFalse(foc.Any());
            foc.AddRange(new FileObject[4]
            {
                new FileObject()
                {
                    Status = FileStatus.uploading
                },
                new FileObject()
                {
                    Status = FileStatus.downloading
                },
                new FileObject()
                {
                    Status = FileStatus.downloading
                },
                new FileObject()
                {
                    Status = FileStatus.enumerated
                },
            });
            Assert.IsFalse(foc.FindAll(fsSingleOption).Count > 0);

            foc.Clear();
            Assert.IsFalse(foc.Any());
            foc.AddRange(new FileObject[4]
            {
                new FileObject()
                {
                    Status = FileStatus.uploading
                },
                new FileObject()
                {
                    Status = fsSingleOption
                },
                new FileObject()
                {
                    Status = fsSingleOption
                },
                new FileObject()
                {
                    Status = FileStatus.downloading
                },
            });
            Assert.IsTrue(foc.Count(fsSingleOption) == 2, $"expected:2 got:{foc.Count(fsSingleOption)}");

            Assert.IsTrue(foc.FindAll(fsSingleOption).Count(x => x.Status == fsSingleOption) == 2, $"expected:2 got:{foc.Count(fsSingleOption)}");
        }
예제 #4
0
        public void AnyTestMultiple()
        {
            FileStatus           fsSingleOption   = FileStatus.succeeded;
            FileStatus           fsMultipleOption = FileStatus.failed | FileStatus.succeeded;
            FileObjectCollection foc = new FileObjectCollection();

            Assert.IsFalse(foc.Any(fsMultipleOption));

            foc.Add(new FileObject());
            Assert.IsFalse(foc.Any(fsMultipleOption));

            foc.Add(new FileObject()
            {
                Status = FileStatus.unknown
            });
            Assert.IsFalse(foc.Any(fsMultipleOption));

            foc.Add(new FileObject()
            {
                Status = fsSingleOption
            });
            Assert.IsTrue(foc.Any(fsMultipleOption));

            foc.Clear();
            Assert.IsFalse(foc.Any());
            foc.AddRange(new FileObject[4]
            {
                new FileObject()
                {
                    Status = FileStatus.uploading
                },
                new FileObject()
                {
                    Status = FileStatus.downloading
                },
                new FileObject()
                {
                    Status = FileStatus.downloading
                },
                new FileObject()
                {
                    Status = FileStatus.enumerated
                },
            });
            Assert.IsFalse(foc.Any(fsMultipleOption));

            foc.Clear();
            Assert.IsFalse(foc.Any());
            foc.AddRange(new FileObject[4]
            {
                new FileObject()
                {
                    Status = FileStatus.uploading
                },
                new FileObject()
                {
                    Status = fsSingleOption
                },
                new FileObject()
                {
                    Status = FileStatus.failed
                },
                new FileObject()
                {
                    Status = FileStatus.downloading
                },
            });
            Assert.IsTrue(foc.Any(fsMultipleOption));

            Assert.IsTrue(foc.Count(fsMultipleOption) == 2, $"expected:2 got:{foc.Count(fsMultipleOption)}");

            foc.Clear();
            fsMultipleOption = FileStatus.existing | FileStatus.succeeded;
            Assert.IsFalse(foc.Any());
            foc.AddRange(new FileObject[10]
            {
                new FileObject()
                {
                    Status = FileStatus.uploading
                },
                new FileObject()
                {
                    Status = FileStatus.existing
                },
                new FileObject()
                {
                    Status = FileStatus.succeeded
                },
                new FileObject()
                {
                    Status = FileStatus.succeeded
                },
                new FileObject()
                {
                    Status = FileStatus.succeeded
                },
                new FileObject()
                {
                    Status = FileStatus.existing
                },
                new FileObject()
                {
                    Status = FileStatus.failed
                },
                new FileObject()
                {
                    Status = FileStatus.succeeded
                },
                new FileObject()
                {
                    Status = FileStatus.succeeded
                },
                new FileObject()
                {
                    Status = FileStatus.downloading
                },
            });
            Assert.IsTrue(foc.Any(fsMultipleOption));

            Assert.IsTrue(foc.Count(fsMultipleOption) == 7, $"expected:7 got:{foc.Count(fsMultipleOption)}");
        }