{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/26091521","id":26091521,"diff_hunk":"@@ -0,0 +1,194 @@\n+﻿// Copyright (c) Microsoft. All rights reserved.\n+// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n+\n+using System;\n+using System.IO;\n+using System.Collections;\n+using System.Collections.Generic;\n+using System.Linq;\n+using System.Runtime.InteropServices;\n+using Xunit;\n+using System.Text;\n+\n+namespace System.IO.FileSystem.DriveInfoTests\n+{\n+    public class DriveInfoTests\n+    {\n+        [Fact]\n+        public void TestConstructor()\n+        {\n+            string[] invalidInput = { \":\", \"://\", @\":\\\", \":/\", @\":\\\\\", \"Az\", \"1\", \"a1\", \"\\\\share\", \"\\\\\", \"c \", string.Empty, \" c\" };\n+            string[] variableInput = { \"{0}\", \"{0}\", \"{0}:\", \"{0}:\", @\"{0}:\\\", \"{0}:\\\\\", \"{0}://\" };\n+\n+            // Test Invalid input\n+            foreach (var input in invalidInput)\n+            {\n+                Assert.Throws<ArgumentException>(() => { new DriveInfo(input); });\n+            }\n+\n+            // Test Null\n+            Assert.Throws<ArgumentNullException>(() => { new DriveInfo(null); });\n+\n+            // Test Valid DriveLetter\n+            var validDriveLetter = GetValidDriveLettersOnMachine().First();\n+            foreach (var input in variableInput)\n+            {\n+                string name = string.Format(input, validDriveLetter);\n+                DriveInfo dInfo = new DriveInfo(name);\n+                Assert.Equal(string.Format(@\"{0}:\\\", validDriveLetter), dInfo.Name);\n+            }\n+        }\n+        \n+        [Fact]\n+        public void TestGetDrives()\n+        {\n+            var validExpectedDrives = GetValidDriveLettersOnMachine();\n+            var validActualDrives = DriveInfo.GetDrives();\n+\n+            // Test count\n+            Assert.Equal(validExpectedDrives.Count(), validActualDrives.Count());\n+\n+            for (int i = 0; i < validActualDrives.Count(); i++)\n+            {\n+                // Test if the driveletter is correct\n+                Assert.True(validExpectedDrives.Contains(validActualDrives[i].Name[0]));\n+            }\n+        }\n+\n+        [Fact]\n+        public void TestDriveFormat()\n+        {\n+            var validDrive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).First();\n+            const int volNameLen = 50;\n+            StringBuilder volumeName = new StringBuilder(volNameLen);\n+            const int fileSystemNameLen = 50;\n+            StringBuilder fileSystemName = new StringBuilder(fileSystemNameLen);\n+            int serialNumber, maxFileNameLen, fileSystemFlags;\n+            bool r = GetVolumeInformation(validDrive.Name, volumeName, volNameLen, out serialNumber, out maxFileNameLen, out fileSystemFlags, fileSystemName, fileSystemNameLen);\n+            var fileSystem = fileSystemName.ToString();\n+            if (r)\n+            {\n+                if (fileSystem != validDrive.DriveFormat)\n+                {\n+                    Assert.False(true, string.Format(\"Error, unexpected result returned: {0}, Expected: {1}\", validDrive.DriveFormat, fileSystem));\n+                }\n+            }\n+            else\n+            {\n+                Assert.Throws<IOException>(() => { var df = validDrive.DriveFormat; });\n+            }\n+\n+            // Test Invalid drive\n+            var invalidDrive = new DriveInfo(GetInvalidDriveLettersOnMachine().First().ToString());\n+            Assert.Throws<DriveNotFoundException>(() => { var df = invalidDrive.DriveFormat; });\n+        }\n+\n+        [Fact]\n+        public void TestDriveType()\n+        {\n+            var validDrive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).First();\n+            var expectedDriveType = GetDriveType(validDrive.Name);\n+            Assert.Equal((DriveType)expectedDriveType, validDrive.DriveType);\n+\n+            // Test Invalid drive\n+            var invalidDrive = new DriveInfo(GetInvalidDriveLettersOnMachine().First().ToString());\n+            Assert.True(invalidDrive.DriveType == DriveType.NoRootDirectory);\n+        }\n+\n+        [OuterLoop]\n+        public void TestVolumeLabel()\n+        {\n+            // Get Volume Label - valid drive\n+            var validDrive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).First();\n+            const int volNameLen = 50;\n+            StringBuilder volumeName = new StringBuilder(volNameLen);\n+            const int fileSystemNameLen = 50;\n+            StringBuilder fileSystemName = new StringBuilder(fileSystemNameLen);\n+            int serialNumber, maxFileNameLen, fileSystemFlags;\n+            bool r = GetVolumeInformation(validDrive.Name, volumeName, volNameLen, out serialNumber, out maxFileNameLen, out fileSystemFlags, fileSystemName, fileSystemNameLen);\n+            if (r)\n+            {\n+                Assert.Equal(volumeName.ToString(), validDrive.VolumeLabel);\n+            }\n+\n+            // Set Volume Label - valid drive\n+            string newLabel = \"DriveInfoTests\";\n+            string originalLabel = validDrive.VolumeLabel;\n+\n+            if (validDrive.IsReady)\n+            {\n+                bool haveAccess = true;\n+                try\n+                {\n+                    validDrive.VolumeLabel = newLabel;\n+                    Assert.Equal(newLabel, validDrive.VolumeLabel);\n+                }\n+                catch (UnauthorizedAccessException) { haveAccess = false; }\n+                finally\n+                {\n+                    if (haveAccess)\n+                        validDrive.VolumeLabel = originalLabel;\n+                }\n+            }\n+\n+            // Test UnauthorizedAccess on Network or CD-ROM\n+            var noAccessDrive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Network || d.DriveType == DriveType.CDRom);","path":"src/System.IO.FileSystem.DriveInfo/tests/DriveInfo.Windows.Tests.cs","position":135,"original_position":135,"commit_id":"605e99684f11d284c4c40bd23d6d7c8e3169b40c","original_commit_id":"605e99684f11d284c4c40bd23d6d7c8e3169b40c","user":{"login":"Priya91","id":7853870,"avatar_url":"https://avatars.githubusercontent.com/u/7853870?v=3","gravatar_id":"","url":"https://api.github.com/users/Priya91","html_url":"https://github.com/Priya91","followers_url":"https://api.github.com/users/Priya91/followers","following_url":"https://api.github.com/users/Priya91/following{/other_user}","gists_url":"https://api.github.com/users/Priya91/gists{/gist_id}","starred_url":"https://api.github.com/users/Priya91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Priya91/subscriptions","organizations_url":"https://api.github.com/users/Priya91/orgs","repos_url":"https://api.github.com/users/Priya91/repos","events_url":"https://api.github.com/users/Priya91/events{/privacy}","received_events_url":"https://api.github.com/users/Priya91/received_events","type":"User","site_admin":false},"body":"The code doesn't write anything to the drive, only tries to set the volumelabel, for which we dont have access.","created_at":"2015-03-10T00:52:41Z","updated_at":"2015-03-10T00:52:41Z","html_url":"https://github.com/dotnet/corefx/pull/1109#discussion_r26091521","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/1109","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/26091521"},"html":{"href":"https://github.com/dotnet/corefx/pull/1109#discussion_r26091521"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/1109"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/1109","id":30808589,"html_url":"https://github.com/dotnet/corefx/pull/1109","diff_url":"https://github.com/dotnet/corefx/pull/1109.diff","patch_url":"https://github.com/dotnet/corefx/pull/1109.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/1109","number":1109,"state":"open","locked":false,"title":"Rewrite DriveInfo tests.","user":{"login":"Priya91","id":7853870,"avatar_url":"https://avatars.githubusercontent.com/u/7853870?v=3","gravatar_id":"","url":"https://api.github.com/users/Priya91","html_url":"https://github.com/Priya91","followers_url":"https://api.github.com/users/Priya91/followers","following_url":"https://api.github.com/users/Priya91/following{/other_user}","gists_url":"https://api.github.com/users/Priya91/gists{/gist_id}","starred_url":"https://api.github.com/users/Priya91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Priya91/subscriptions","organizations_url":"https://api.github.com/users/Priya91/orgs","repos_url":"https://api.github.com/users/Priya91/repos","events_url":"https://api.github.com/users/Priya91/events{/privacy}","received_events_url":"https://api.github.com/users/Priya91/received_events","type":"User","site_admin":false},"body":"Fixes issues, #592, #564, #528, #514","created_at":"2015-03-09T23:00:54Z","updated_at":"2015-03-10T00:52:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79ff166fd13dda045a4c16b64dcf5764e1e1e328","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/1109/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/1109/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/1109/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/605e99684f11d284c4c40bd23d6d7c8e3169b40c","head":{"label":"Priya91:fixdriveinfotests","ref":"fixdriveinfotests","sha":"605e99684f11d284c4c40bd23d6d7c8e3169b40c","user":{"login":"Priya91","id":7853870,"avatar_url":"https://avatars.githubusercontent.com/u/7853870?v=3","gravatar_id":"","url":"https://api.github.com/users/Priya91","html_url":"https://github.com/Priya91","followers_url":"https://api.github.com/users/Priya91/followers","following_url":"https://api.github.com/users/Priya91/following{/other_user}","gists_url":"https://api.github.com/users/Priya91/gists{/gist_id}","starred_url":"https://api.github.com/users/Priya91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Priya91/subscriptions","organizations_url":"https://api.github.com/users/Priya91/orgs","repos_url":"https://api.github.com/users/Priya91/repos","events_url":"https://api.github.com/users/Priya91/events{/privacy}","received_events_url":"https://api.github.com/users/Priya91/received_events","type":"User","site_admin":false},"repo":{"id":27062349,"name":"corefx-1","full_name":"Priya91/corefx-1","owner":{"login":"Priya91","id":7853870,"avatar_url":"https://avatars.githubusercontent.com/u/7853870?v=3","gravatar_id":"","url":"https://api.github.com/users/Priya91","html_url":"https://github.com/Priya91","followers_url":"https://api.github.com/users/Priya91/followers","following_url":"https://api.github.com/users/Priya91/following{/other_user}","gists_url":"https://api.github.com/users/Priya91/gists{/gist_id}","starred_url":"https://api.github.com/users/Priya91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Priya91/subscriptions","organizations_url":"https://api.github.com/users/Priya91/orgs","repos_url":"https://api.github.com/users/Priya91/repos","events_url":"https://api.github.com/users/Priya91/events{/privacy}","received_events_url":"https://api.github.com/users/Priya91/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Priya91/corefx-1","description":"This repository contains the foundational libraries that make up the .NET Core development stack.","fork":true,"url":"https://api.github.com/repos/Priya91/corefx-1","forks_url":"https://api.github.com/repos/Priya91/corefx-1/forks","keys_url":"https://api.github.com/repos/Priya91/corefx-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Priya91/corefx-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Priya91/corefx-1/teams","hooks_url":"https://api.github.com/repos/Priya91/corefx-1/hooks","issue_events_url":"https://api.github.com/repos/Priya91/corefx-1/issues/events{/number}","events_url":"https://api.github.com/repos/Priya91/corefx-1/events","assignees_url":"https://api.github.com/repos/Priya91/corefx-1/assignees{/user}","branches_url":"https://api.github.com/repos/Priya91/corefx-1/branches{/branch}","tags_url":"https://api.github.com/repos/Priya91/corefx-1/tags","blobs_url":"https://api.github.com/repos/Priya91/corefx-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Priya91/corefx-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Priya91/corefx-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/Priya91/corefx-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Priya91/corefx-1/statuses/{sha}","languages_url":"https://api.github.com/repos/Priya91/corefx-1/languages","stargazers_url":"https://api.github.com/repos/Priya91/corefx-1/stargazers","contributors_url":"https://api.github.com/repos/Priya91/corefx-1/contributors","subscribers_url":"https://api.github.com/repos/Priya91/corefx-1/subscribers","subscription_url":"https://api.github.com/repos/Priya91/corefx-1/subscription","commits_url":"https://api.github.com/repos/Priya91/corefx-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/Priya91/corefx-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/Priya91/corefx-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/Priya91/corefx-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/Priya91/corefx-1/contents/{+path}","compare_url":"https://api.github.com/repos/Priya91/corefx-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Priya91/corefx-1/merges","archive_url":"https://api.github.com/repos/Priya91/corefx-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Priya91/corefx-1/downloads","issues_url":"https://api.github.com/repos/Priya91/corefx-1/issues{/number}","pulls_url":"https://api.github.com/repos/Priya91/corefx-1/pulls{/number}","milestones_url":"https://api.github.com/repos/Priya91/corefx-1/milestones{/number}","notifications_url":"https://api.github.com/repos/Priya91/corefx-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Priya91/corefx-1/labels{/name}","releases_url":"https://api.github.com/repos/Priya91/corefx-1/releases{/id}","created_at":"2014-11-24T05:35:16Z","updated_at":"2015-01-07T23:48:56Z","pushed_at":"2015-03-09T22:59:39Z","git_url":"git://github.com/Priya91/corefx-1.git","ssh_url":"git@github.com:Priya91/corefx-1.git","clone_url":"https://github.com/Priya91/corefx-1.git","svn_url":"https://github.com/Priya91/corefx-1","homepage":"","size":7435,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"c585629a6372a6e113f752a8cfa437ec3379013d","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":26295345,"name":"corefx","full_name":"dotnet/corefx","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":false,"url":"https://api.github.com/repos/dotnet/corefx","forks_url":"https://api.github.com/repos/dotnet/corefx/forks","keys_url":"https://api.github.com/repos/dotnet/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corefx/teams","hooks_url":"https://api.github.com/repos/dotnet/corefx/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corefx/events","assignees_url":"https://api.github.com/repos/dotnet/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corefx/tags","blobs_url":"https://api.github.com/repos/dotnet/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corefx/languages","stargazers_url":"https://api.github.com/repos/dotnet/corefx/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corefx/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corefx/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corefx/subscription","commits_url":"https://api.github.com/repos/dotnet/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corefx/merges","archive_url":"https://api.github.com/repos/dotnet/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corefx/downloads","issues_url":"https://api.github.com/repos/dotnet/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corefx/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corefx/releases{/id}","created_at":"2014-11-06T23:42:48Z","updated_at":"2015-03-10T00:20:04Z","pushed_at":"2015-03-09T21:59:09Z","git_url":"git://github.com/dotnet/corefx.git","ssh_url":"git@github.com:dotnet/corefx.git","clone_url":"https://github.com/dotnet/corefx.git","svn_url":"https://github.com/dotnet/corefx","homepage":"","size":25343,"stargazers_count":7152,"watchers_count":7152,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1341,"mirror_url":null,"open_issues_count":292,"forks":1341,"open_issues":292,"watchers":7152,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/1109"},"html":{"href":"https://github.com/dotnet/corefx/pull/1109"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/1109"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/1109/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/1109/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/1109/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/605e99684f11d284c4c40bd23d6d7c8e3169b40c"}}}}