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); } } }
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)); }
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(); }
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); }
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"}); }