Update Fact Skip for not work tests for FileSystemProvider xunit test

This commit is contained in:
JumpingYang001 committed 2016-03-22 20:23:37 -07:00
1 parent 5c35053350
commit 31ec32896f
1 file changed
+55 -20
+55 -20
View File
@@ -1,16 +1,42 @@
using Xunit; using Xunit;
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq;
using System.Management.Automation; using System.Management.Automation;
using System.Management.Automation.Host;
using System.Management.Automation.Internal;
using System.Management.Automation.Internal.Host;
using System.Management.Automation.Provider; using System.Management.Automation.Provider;
using System.Management.Automation.Runspaces;
using Microsoft.PowerShell;
using Microsoft.PowerShell.Commands; using Microsoft.PowerShell.Commands;
using Microsoft.PowerShell.Linux.Host;
namespace PSTests namespace PSTests
{ {
[Collection("AssemblyLoadContext")] [Collection("AssemblyLoadContext")]
public static class FileSystemProviderTests public static class FileSystemProviderTests
{ {
private static ProviderInfo GetProvider()
{
CultureInfo currentCulture = CultureInfo.CurrentCulture;
PSHost hostInterface = new DefaultHost(currentCulture,currentCulture);
RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
InitialSessionState iss = InitialSessionState.CreateDefault2();
AutomationEngine engine = new AutomationEngine(hostInterface, runspaceConfiguration, iss);
ExecutionContext executionContext = new ExecutionContext(engine, hostInterface, iss);
SessionStateInternal sessionState = new SessionStateInternal(executionContext);
SessionStateProviderEntry providerEntry = new SessionStateProviderEntry("FileSystem",typeof(FileSystemProvider), null);
sessionState.AddSessionStateEntry(providerEntry);
ProviderInfo matchingProvider = sessionState.ProviderList.ToList()[0];
return matchingProvider;
}
[Fact] [Fact]
public static void TestCreateJunctionFails() public static void TestCreateJunctionFails()
{ {
@@ -34,48 +60,57 @@ namespace PSTests
Assert.NotEqual(FileSystemProvider.Mode(PSObject.AsPSObject(fileSystemObject)),String.Empty); Assert.NotEqual(FileSystemProvider.Mode(PSObject.AsPSObject(fileSystemObject)),String.Empty);
} }
[Fact] [Fact(Skip = "Need mock")]
public static void TestGetProperty() public static void TestGetProperty()
{ {
//FileSystemProvider fileSystemProvider = new FileSystemProvider(); string path = @"/filesystemobject1";
//fileSystemProvider.GetProperty(@"/", new Collection<string>(){"Attributes"}); FileSystemProvider fileSystemProvider = new FileSystemProvider();
ProviderInfo providerInfoToSet = GetProvider();
fileSystemProvider.SetProviderInformation(providerInfoToSet);
FileInfo fileSystemObject1 = new FileInfo(path);
fileSystemProvider.SetProperty(path, PSObject.AsPSObject(fileSystemObject1));
fileSystemProvider.GetProperty(path, new Collection<string>(){"Attributes"});
} }
[Fact] [Fact(Skip = "Need mock")]
public static void TestSetProperty() public static void TestSetProperty()
{ {
//FileSystemProvider fileSystemProvider = new FileSystemProvider(); string path = @"/filesystemobject1";
//fileSystemProvider.SetProperty(@"/root", PSObject.AsPSObject(propertyToSet)); FileSystemProvider fileSystemProvider = new FileSystemProvider();
ProviderInfo providerInfoToSet = GetProvider();
fileSystemProvider.SetProviderInformation(providerInfoToSet);
FileInfo fileSystemObject1 = new FileInfo(path);
fileSystemProvider.SetProperty(@"/root", PSObject.AsPSObject(fileSystemObject1));
} }
[Fact] [Fact(Skip = "Need mock")]
public static void TestClearProperty() public static void TestClearProperty()
{ {
// FileSystemProvider fileSystemProvider = new FileSystemProvider(); FileSystemProvider fileSystemProvider = new FileSystemProvider();
// fileSystemProvider.ClearProperty(@"/test", new Collection<string>(){"Attributes"}); fileSystemProvider.ClearProperty(@"/test", new Collection<string>(){"Attributes"});
} }
[Fact] [Fact(Skip = "Need mock")]
public static void TestGetContentReader() public static void TestGetContentReader()
{ {
// FileSystemProvider fileSystemProvider = new FileSystemProvider(); FileSystemProvider fileSystemProvider = new FileSystemProvider();
// IContentReader contentReader = fileSystemProvider.GetContentReader(@"/test"); IContentReader contentReader = fileSystemProvider.GetContentReader(@"/test");
// Assert.NotNull(contentReader); Assert.NotNull(contentReader);
} }
[Fact] [Fact(Skip = "Need mock")]
public static void TestGetContentWriter() public static void TestGetContentWriter()
{ {
// FileSystemProvider fileSystemProvider = new FileSystemProvider(); FileSystemProvider fileSystemProvider = new FileSystemProvider();
// IContentWriter contentWriter = fileSystemProvider.GetContentWriter(@"/test"); IContentWriter contentWriter = fileSystemProvider.GetContentWriter(@"/test");
// Assert.NotNull(contentWriter); Assert.NotNull(contentWriter);
} }
[Fact] [Fact(Skip = "Need mock")]
public static void TestClearContent() public static void TestClearContent()
{ {
//FileSystemProvider fileSystemProvider = new FileSystemProvider(); FileSystemProvider fileSystemProvider = new FileSystemProvider();
//fileSystemProvider.ClearContent(@"/test"); fileSystemProvider.ClearContent(@"/test");
} }
} }
} }