Beispiel #1
0
        public void Execute()
        {
            //
            // All拡張メソッドは、シーケンスの全要素が指定された条件に合致しているか否かを判別するメソッドである。
            //
            // 引数には条件としてpredicateを指定する。
            // このメソッドは、対象シーケンス内の全要素が条件に合致している場合のみTrueを返す。
            // (逆にAny拡張メソッドは、一つでも合致するものが存在した時点でTrueとなる。)
            //
            var names = new[] {"gsf_zero1", "gsf_zero2", "gsf_zero3", "2222"};

            Output.WriteLine("Allメソッドの結果 = {0}", names.All(item => char.IsDigit(item.Last())));
            Output.WriteLine("Allメソッドの結果 = {0}", names.All(item => item.StartsWith("g")));
            Output.WriteLine("Allメソッドの結果 = {0}", names.All(item => !string.IsNullOrEmpty(item)));
        }
Beispiel #2
0
        public void TextTypeTests()
        {
            // Text
            var formats = new[] { "css", "csv", "txt", "xml" };

            Assert.True(formats.All(format => Mime.FromFormat(format).Type == MediaType.Text));
        }
        private void UpdateAppBar()
        {
            var pool = ( (EventPoolViewModel) DataContext ).Pool;
            if ( pool == null )
            {
                return;
            }

            var commandButtons = new[] { CategoriesButton, TagsButton, ScanCodeButton, RequestFavoriteEmailButton };

            foreach ( var button in commandButtons )
            {
                button.Visibility = button.Command.CanExecute( null ) ? Visibility.Visible : Visibility.Collapsed;
            }
            SettingsButton.Visibility = pool.Id == EventPool.RootId ? Visibility.Visible : Visibility.Collapsed;

            if ( commandButtons.All( b => b.Visibility == Visibility.Collapsed ) && SettingsButton.Visibility == Visibility.Collapsed )
            {
                BottomAppBar.Visibility = Visibility.Collapsed;
            }
            else
            {
                BottomAppBar.Visibility = Visibility.Visible;
            }
        }
Beispiel #4
0
        public void VideoTypeTests()
        {
            Assert.Equal(MediaType.Video, Mime.FromPath("DemoReel_01.10.13-HD for Apple Devices.m4v").Type);
            Assert.Equal("mp4", Mime.FromPath("DemoReel_01.10.13-HD for Apple Devices.m4v").Format);

            var formats = new[] { "avi", "f4v", "flv", "m4v", "mp4", "mpg", "mpeg", "qt", "webm", "wmv" };

            Assert.True(formats.All(format => Mime.FromFormat(format).Type == MediaType.Video));
        }
Beispiel #5
0
        public void EachExecutesActionOnEachEnumeratedElement()
        {
            var elements = new[]
            {
                new IntContainer(),
                new IntContainer(),
                new IntContainer()
            };

            elements.Each( x => x.Number++ );

            Assert.IsTrue( elements.All( x=>x.Number == 1 ) );
        }
        public void BuildContainer_ContainerHasAllExpectedServices(
            ContainerBuilder builder,
            RepositoryModule sut)
        {
            // Given
            var expectedServices = new[] { typeof(IUnitOfWork), typeof(IRepository<>) };

            // When
            builder.RegisterModule(sut);
            var container = builder.Build();

            // Then
            Assert.True(expectedServices.All(container.IsRegistered));
        }
        public override bool IsValueValid(string value, ApiHttpClient apiClient)
        {
            if (value.HasValue() && !File.Exists(value))
            {
                Program.WriteWarning("The file '" + value + "' in column '" + Header + "' does not exist or is not accessible.");
                return false;
            }

            var extension = (Path.GetExtension(value) ?? "").Trim('.').ToLowerInvariant();
            var allowedExtensions = new[] { "jpg", "jpeg", "png", "bmp" };
            if (allowedExtensions.All(x => x != extension))
            {
                Program.WriteWarning("The file '" + value + "' in column '" + Header + "' does not have a valid file extension for a photo.");
                return false;
            }

            return true;
        }
        public void Does_resolve_nested_files_and_folders()
        {
            var pathProvider = GetPathProvider();

            var allFilePaths = new[] {
                "testfile.txt",
                "a/testfile-a1.txt",
                "a/testfile-a2.txt",
                "a/b/testfile-ab1.txt",
                "a/b/testfile-ab2.txt",
                "a/b/c/testfile-abc1.txt",
                "a/b/c/testfile-abc2.txt",
                "a/d/testfile-ad1.txt",
                "e/testfile-e1.txt",
            };

            allFilePaths.Each(x => pathProvider.WriteFile(x, x.SplitOnLast('.').First().SplitOnLast('/').Last()));

            Assert.That(allFilePaths.All(x => pathProvider.IsFile(x)));
            Assert.That(new[] { "a", "a/b", "a/b/c", "a/d", "e" }.All(x => pathProvider.IsDirectory(x)));

            Assert.That(!pathProvider.IsFile("notfound.txt"));
            Assert.That(!pathProvider.IsFile("a/notfound.txt"));
            Assert.That(!pathProvider.IsDirectory("f"));
            Assert.That(!pathProvider.IsDirectory("a/f"));
            Assert.That(!pathProvider.IsDirectory("testfile.txt"));
            Assert.That(!pathProvider.IsDirectory("a/testfile-a1.txt"));

            AssertContents(pathProvider.RootDirectory, new[] {
                    "testfile.txt",
                }, new[] {
                    "a",
                    "e"
                });

            AssertContents(pathProvider.GetDirectory("a"), new[] {
                    "a/testfile-a1.txt",
                    "a/testfile-a2.txt",
                }, new[] {
                    "a/b",
                    "a/d"
                });

            AssertContents(pathProvider.GetDirectory("a/b"), new[] {
                    "a/b/testfile-ab1.txt",
                    "a/b/testfile-ab2.txt",
                }, new[] {
                    "a/b/c"
                });

            AssertContents(pathProvider.GetDirectory("a").GetDirectory("b"), new[] {
                    "a/b/testfile-ab1.txt",
                    "a/b/testfile-ab2.txt",
                }, new[] {
                    "a/b/c"
                });

            AssertContents(pathProvider.GetDirectory("a/b/c"), new[] {
                    "a/b/c/testfile-abc1.txt",
                    "a/b/c/testfile-abc2.txt",
                }, new string[0]);

            AssertContents(pathProvider.GetDirectory("a/d"), new[] {
                    "a/d/testfile-ad1.txt",
                }, new string[0]);

            AssertContents(pathProvider.GetDirectory("e"), new[] {
                    "e/testfile-e1.txt",
                }, new string[0]);

            Assert.That(pathProvider.GetFile("a/b/c/testfile-abc1.txt").ReadAllText(), Is.EqualTo("testfile-abc1"));
            Assert.That(pathProvider.GetDirectory("a").GetFile("b/c/testfile-abc1.txt").ReadAllText(), Is.EqualTo("testfile-abc1"));
            Assert.That(pathProvider.GetDirectory("a/b").GetFile("c/testfile-abc1.txt").ReadAllText(), Is.EqualTo("testfile-abc1"));
            Assert.That(pathProvider.GetDirectory("a").GetDirectory("b").GetDirectory("c").GetFile("testfile-abc1.txt").ReadAllText(), Is.EqualTo("testfile-abc1"));

            var dirs = pathProvider.RootDirectory.Directories.Map(x => x.VirtualPath);
            Assert.That(dirs, Is.EquivalentTo(new[] { "a", "e" }));

            var rootDirFiles = pathProvider.RootDirectory.GetAllMatchingFiles("*", 1).Map(x => x.VirtualPath);
            Assert.That(rootDirFiles, Is.EquivalentTo(new[] { "testfile.txt" }));

            var allFiles = pathProvider.GetAllMatchingFiles("*").Map(x => x.VirtualPath);
            Assert.That(allFiles, Is.EquivalentTo(allFilePaths));

            allFiles = pathProvider.GetAllFiles().Map(x => x.VirtualPath);
            Assert.That(allFiles, Is.EquivalentTo(allFilePaths));

            pathProvider.DeleteFile("testfile.txt");
            pathProvider.DeleteFolder("a");
            pathProvider.DeleteFolder("e");

            Assert.That(pathProvider.GetAllFiles().ToList().Count, Is.EqualTo(0));
        }
            public void Then_only_connected_node_should_be_visited_01()
            {
                var startingNode = _graph.Nodes.Single(n => n.Label == 1);
                _bfs.Execute(startingNode);

                var visited = new[] { 1, 3, 5, 7, 9 };
                visited.All(v => _graph.Nodes.Single(n => n.Label == v).Visited).ShouldBeTrue();

                _graph.Nodes.Where(n => !visited.Contains(n.Label)).All(n => n.Visited).ShouldBeFalse();
            }
Beispiel #10
0
        public void ImageTypeTests()
        {
            var formats = new[] { "bmp", "gif", "ico", "jpg", "jpeg", "jxr", "png", "tif", "tiff", "webp" };

            Assert.True(formats.All(format => Mime.FromFormat(format).Type == MediaType.Image));
        }
Beispiel #11
0
        public void AudioTypeTests()
        {
            var formats = new[] { "aiff", "aif", "aac", "mp3", "m4a", "opus", "ra", "wav", "wma" };

            Assert.True(formats.All(format => Mime.FromFormat(format).Type == MediaType.Audio));
        }
Beispiel #12
0
        public void ApplicationTypeTests()
        {
            var formats = new[] { "js", "json", "swf", "xap", "zip" };

            Assert.True(formats.All(format => Mime.FromFormat(format).Type == MediaType.Application));
        }