From 822b290bb636936c493cd6277a2cd54bb3def989 Mon Sep 17 00:00:00 2001
From: Livar Cunha <livar@live.com>
Date: Mon, 22 May 2017 09:51:30 -0700
Subject: [PATCH] Updating the global.json creation to use the IFile interface
 and adding a unit test to cover it.

---
 src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs  | 10 +++++-----
 .../GivenANuGetCachePrimer.cs                        | 12 ++++++++++++
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs b/src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs
index d4718c002..0414c5ca1 100644
--- a/src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs
+++ b/src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs
@@ -96,13 +96,13 @@ namespace Microsoft.DotNet.Configurer
   </packageSources>
 </configuration>");
 
-                        File.WriteAllText(
+                        _file.WriteAllText(
                             Path.Combine(workingDirectory, "global.json"),
                             $@"{{
-                                 ""sdk"": {{
-                                    ""version"":""{Product.Version}""
-                                 }}
-                               }}");
+ ""sdk"": {{
+    ""version"":""{Product.Version}""
+ }}
+}}");
 
                         succeeded &= CreateTemporaryProject(workingDirectory, templateInfo);
 
diff --git a/test/Microsoft.DotNet.Configurer.UnitTests/GivenANuGetCachePrimer.cs b/test/Microsoft.DotNet.Configurer.UnitTests/GivenANuGetCachePrimer.cs
index 79769e8db..e1c8168b3 100644
--- a/test/Microsoft.DotNet.Configurer.UnitTests/GivenANuGetCachePrimer.cs
+++ b/test/Microsoft.DotNet.Configurer.UnitTests/GivenANuGetCachePrimer.cs
@@ -163,6 +163,18 @@ namespace Microsoft.DotNet.Configurer.UnitTests
 </configuration>");
         }
 
+        [Fact]
+        public void It_writes_a_global_json_file_with_the_current_cli_version()
+        {
+            var nugetConfigPath = Path.Combine(_temporaryDirectoryMock.DirectoryPath, "global.json");
+            _fileSystemMock.File.ReadAllText(nugetConfigPath).Should().Be(
+                $@"{{
+ ""sdk"": {{
+    ""version"":""{Product.Version}""
+ }}
+}}");
+        }
+
         [Fact]
         public void It_uses_a_config_file_with_dotnet_restore()
         {