Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1383D18A0C for ; Wed, 2 Mar 2016 08:11:22 +0000 (UTC) Received: (qmail 6626 invoked by uid 500); 2 Mar 2016 08:11:21 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 6577 invoked by uid 500); 2 Mar 2016 08:11:21 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 6469 invoked by uid 99); 2 Mar 2016 08:11:21 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Mar 2016 08:11:21 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 22B9AE78B6; Wed, 2 Mar 2016 08:11:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Wed, 02 Mar 2016 08:11:34 -0000 Message-Id: In-Reply-To: <416ae73fd8d1403a804eeafa1ddf1a12@git.apache.org> References: <416ae73fd8d1403a804eeafa1ddf1a12@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [15/19] ignite git commit: IGNITE-2705: .NET: Added test for tools version. This closes #529. IGNITE-2705: .NET: Added test for tools version. This closes #529. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a4391d79 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a4391d79 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a4391d79 Branch: refs/heads/ignite-1232 Commit: a4391d7935199a658d6dd4ac3fc8fa601e36c3f5 Parents: 3b44cc4 Author: Pavel Tupitsyn Authored: Wed Mar 2 09:11:06 2016 +0300 Committer: thatcoach Committed: Wed Mar 2 09:11:06 2016 +0300 ---------------------------------------------------------------------- .../Apache.Ignite.Core.Tests.csproj | 1 + .../ProjectFilesTest.cs | 94 ++++++++++++++++++++ 2 files changed, 95 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/a4391d79/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj index 6f0e630..4ba05e1 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj @@ -130,6 +130,7 @@ + http://git-wip-us.apache.org/repos/asf/ignite/blob/a4391d79/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ProjectFilesTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ProjectFilesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ProjectFilesTest.cs new file mode 100644 index 0000000..081dd89 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ProjectFilesTest.cs @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Tests +{ + using System; + using System.IO; + using System.Linq; + using System.Reflection; + using NUnit.Framework; + + /// + /// Verifies source files. + /// + public class ProjectFilesTest + { + /// + /// Tests that tools version is compatible with VS2010. + /// + [Test] + public void TestCsprojToolsVersion() + { + var projFiles = GetDotNetSourceDir().GetFiles("*.csproj", SearchOption.AllDirectories); + Assert.GreaterOrEqual(projFiles.Length, 7); + + var invalidFiles = + projFiles.Where(x => + { + var text = File.ReadAllText(x.FullName); + + return !text.Contains("ToolsVersion=\"4.0\"") || + text.IndexOf("AnyCPU", StringComparison.OrdinalIgnoreCase) >= 0; + }).ToArray(); + + Assert.AreEqual(0, invalidFiles.Length, + "Invalid csproj files: " + string.Join(", ", invalidFiles.Select(x => x.FullName))); + } + + /// + /// Tests that tools version is compatible with VS2010. + /// + [Test] + public void TestSlnToolsVersion() + { + var slnFiles = GetDotNetSourceDir().GetFiles("*.sln", SearchOption.AllDirectories); + Assert.GreaterOrEqual(slnFiles.Length, 2); + + var invalidFiles = + slnFiles.Where(x => + { + var text = File.ReadAllText(x.FullName); + + return !text.Contains("# Visual Studio 2010") || + !text.Contains("Microsoft Visual Studio Solution File, Format Version 11.00"); + }).ToArray(); + + Assert.AreEqual(0, invalidFiles.Length, + "Invalid sln files: " + string.Join(", ", invalidFiles.Select(x => x.FullName))); + } + + /// + /// Gets the dot net source dir. + /// + private static DirectoryInfo GetDotNetSourceDir() + { + // ReSharper disable once AssignNullToNotNullAttribute + var dir = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); + + while (dir != null) + { + if (dir.GetFiles().Any(x => x.Name == "Apache.Ignite.sln")) + return dir; + + dir = dir.Parent; + } + + throw new InvalidOperationException("Could not resolve Ignite.NET source directory."); + } + } +}