Esempio n. 1
0
        public void TestGetProperty()
        {
			FileSystemProvider fileSystemProvider = new FileSystemProvider();
			ProviderInfo providerInfoToSet = GetProvider();
			fileSystemProvider.SetProviderInformation(providerInfoToSet);
			fileSystemProvider.Context = new CmdletProviderContext(GetExecutionContext());
			PSObject pso=new PSObject();
			pso.AddOrSetProperty("IsReadOnly",false);
			fileSystemProvider.SetProperty(testPath, pso);
			fileSystemProvider.GetProperty(testPath, new Collection<string>(){"IsReadOnly"});
			FileInfo fileSystemObject1 = new FileInfo(testPath);
			PSObject psobject1=PSObject.AsPSObject(fileSystemObject1);
			foreach(PSPropertyInfo property in psobject1.Properties)
			{
				if(property.Name == "IsReadOnly")
				{
					Assert.Equal(property.Value,false);
				}
			}
        }
Esempio n. 2
0
        public void TestClearContent()
        {
			FileSystemProvider fileSystemProvider = new FileSystemProvider();
			ProviderInfo providerInfoToSet = GetProvider();
			fileSystemProvider.SetProviderInformation(providerInfoToSet);
			fileSystemProvider.Context = new CmdletProviderContext(GetExecutionContext());
			fileSystemProvider.ClearContent(testPath);
			Assert.Empty(File.ReadAllText(testPath));
        }
Esempio n. 3
0
        public void TestGetContentReader()
        {
			FileSystemProvider fileSystemProvider = new FileSystemProvider();
			ProviderInfo providerInfoToSet = GetProvider();
			fileSystemProvider.SetProviderInformation(providerInfoToSet);
			fileSystemProvider.Context = new CmdletProviderContext(GetExecutionContext());
			
			IContentReader contentReader = fileSystemProvider.GetContentReader(testPath);
			Assert.Equal(contentReader.Read(1)[0],testContent);
			contentReader.Close();
        }
Esempio n. 4
0
        public void TestGetContentWriter()
        {
			FileSystemProvider fileSystemProvider = new FileSystemProvider();
			ProviderInfo providerInfoToSet = GetProvider();
			fileSystemProvider.SetProviderInformation(providerInfoToSet);
			fileSystemProvider.Context = new CmdletProviderContext(GetExecutionContext());
			
			IContentWriter contentWriter = fileSystemProvider.GetContentWriter(testPath);
			contentWriter.Write(new List<string>(){"contentWriterTestContent"});
			contentWriter.Close();
			Assert.Equal(File.ReadAllText(testPath), testContent+@"contentWriterTestContent"+ System.Environment.NewLine);
        }
Esempio n. 5
0
        public void TestClearProperty()
        {
			FileSystemProvider fileSystemProvider = new FileSystemProvider();
			ProviderInfo providerInfoToSet = GetProvider();
			fileSystemProvider.SetProviderInformation(providerInfoToSet);
			fileSystemProvider.Context = new CmdletProviderContext(GetExecutionContext());
			fileSystemProvider.ClearProperty(testPath, new Collection<string>(){"Attributes"});
        }