예제 #1
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)}");
        }