1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 
4 using System;
5 using System.Collections;
6 using System.Collections.Generic;
7 using System.Configuration;
8 using System.IO;
9 using NUnit.Framework;
10 using Microsoft.Build.Framework;
11 using Microsoft.Build.BuildEngine;
12 using System.Xml;
13 
14 namespace Microsoft.Build.UnitTests
15 {
16     [TestFixture]
17     public class Toolset_Tests
18     {
19         [Test]
20         [ExpectedException(typeof(ArgumentNullException))]
ToolsetCtorErrors1()21         public void ToolsetCtorErrors1()
22         {
23             Toolset t = new Toolset(null, "x");
24         }
25 
26         [Test]
27         [ExpectedException(typeof(ArgumentNullException))]
ToolsetCtorErrors2()28         public void ToolsetCtorErrors2()
29         {
30             Toolset t = new Toolset("x", null);
31         }
32 
33         [Test]
34         [ExpectedException(typeof(ArgumentException))]
ToolsetCtorErrors3()35         public void ToolsetCtorErrors3()
36         {
37             Toolset t = new Toolset(String.Empty, "x");
38         }
39 
40         [Test]
Regress27993_TrailingSlashTrimmedFromMSBuildToolsPath()41         public void Regress27993_TrailingSlashTrimmedFromMSBuildToolsPath()
42         {
43             Toolset t;
44 
45             t = new Toolset("x", "C:");
46             Assertion.AssertEquals(@"C:", t.ToolsPath);
47             t = new Toolset("x", @"C:\");
48             Assertion.AssertEquals(@"C:\", t.ToolsPath);
49             t = new Toolset("x", @"C:\\");
50             Assertion.AssertEquals(@"C:\", t.ToolsPath);
51 
52             t = new Toolset("x", @"C:\foo");
53             Assertion.AssertEquals(@"C:\foo", t.ToolsPath);
54             t = new Toolset("x", @"C:\foo\");
55             Assertion.AssertEquals(@"C:\foo", t.ToolsPath);
56             t = new Toolset("x", @"C:\foo\\");
57             Assertion.AssertEquals(@"C:\foo\", t.ToolsPath); // trim at most one slash
58 
59             t = new Toolset("x", @"\\foo\share");
60             Assertion.AssertEquals(@"\\foo\share", t.ToolsPath);
61             t = new Toolset("x", @"\\foo\share\");
62             Assertion.AssertEquals(@"\\foo\share", t.ToolsPath);
63             t = new Toolset("x", @"\\foo\share\\");
64             Assertion.AssertEquals(@"\\foo\share\", t.ToolsPath); // trim at most one slash
65         }
66     }
67  }
68