Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Added missing web tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pkbullock committed Jul 2, 2020
1 parent 2a521c8 commit 20566e1
Show file tree
Hide file tree
Showing 19 changed files with 1,568 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Tests/SharePointPnP.PowerShell.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,24 @@
<Compile Include="PSTestScope.cs" />
<Compile Include="TestCommon.cs" />
<Compile Include="OriginalTests\BrandingTests.cs" />
<Compile Include="Webs\AddPnPIndexedPropertyTests.cs" />
<Compile Include="Webs\GetPnPAvailableLanguageTests.cs" />
<Compile Include="Webs\GetPnPIndexedPropertyKeysTests.cs" />
<Compile Include="Webs\GetPnPPropertyBagTests.cs" />
<Compile Include="Webs\GetPnPRequestAccessEmailsTests.cs" />
<Compile Include="Webs\GetPnPWebTemplatesTests.cs" />
<Compile Include="Webs\GetPnPWebTests.cs" />
<Compile Include="Webs\InvokePnPWebActionTests.cs" />
<Compile Include="Webs\NewPnPWebTests.cs" />
<Compile Include="Webs\RemovePnPIndexedPropertyTests.cs" />
<Compile Include="Webs\RemovePnPPropertyBagValueTests.cs" />
<Compile Include="Webs\RemovePnPWebTests.cs" />
<Compile Include="Webs\RequestPnPReIndexWebTests.cs" />
<Compile Include="Webs\SetPnPIndexedPropertiesTests.cs" />
<Compile Include="Webs\SetPnPPropertyBagValueTests.cs" />
<Compile Include="Webs\SetPnPRequestAccessEmailsTests.cs" />
<Compile Include="Webs\SetPnPWebPermissionTests.cs" />
<Compile Include="Webs\SetPnPWebTests.cs" />
<Compile Include="Workflows\AddPnPWorkflowDefinitionTests.cs" />
<Compile Include="Workflows\AddPnPWorkflowSubscriptionTests.cs" />
<Compile Include="Workflows\GetPnPWorkflowDefinitionTests.cs" />
Expand Down Expand Up @@ -765,9 +783,7 @@
<Name>SharePointPnP.PowerShell.Commands</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Web\" />
</ItemGroup>
<ItemGroup />
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
81 changes: 81 additions & 0 deletions Tests/Webs/AddPnPIndexedPropertyTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Management.Automation.Runspaces;

namespace SharePointPnP.PowerShell.Tests.Webs
{
[TestClass]
public class AddIndexedPropertyTests
{
#region Test Setup/CleanUp
[ClassInitialize]
public static void Initialize(TestContext testContext)
{
// This runs on class level once before all tests run
//using (var ctx = TestCommon.CreateClientContext())
//{
//}
}

[ClassCleanup]
public static void Cleanup(TestContext testContext)
{
// This runs on class level once
//using (var ctx = TestCommon.CreateClientContext())
//{
//}
}

[TestInitialize]
public void Initialize()
{
using (var scope = new PSTestScope())
{
// Example
// scope.ExecuteCommand("cmdlet", new CommandParameter("param1", prop));
}
}

[TestCleanup]
public void Cleanup()
{
using (var scope = new PSTestScope())
{
try
{
// Do Test Setup - Note, this runs PER test
}
catch (Exception)
{
// Describe Exception
}
}
}
#endregion

#region Scaffolded Cmdlet Tests
//TODO: This is a scaffold of the cmdlet - complete the unit test
//[TestMethod]
public void AddPnPIndexedPropertyTest()
{
using (var scope = new PSTestScope(true))
{
// Complete writing cmd parameters

// This is a mandatory parameter
// From Cmdlet Help: Key of the property bag value to be indexed
var key = "";
// From Cmdlet Help: The list object or name where to set the indexed property
var list = "";

var results = scope.ExecuteCommand("Add-PnPIndexedProperty",
new CommandParameter("Key", key),
new CommandParameter("List", list));

Assert.IsNotNull(results);
}
}
#endregion
}
}

77 changes: 77 additions & 0 deletions Tests/Webs/GetPnPAvailableLanguageTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Management.Automation.Runspaces;

namespace SharePointPnP.PowerShell.Tests.Webs
{
[TestClass]
public class GetAvailableLanguageTests
{
#region Test Setup/CleanUp
[ClassInitialize]
public static void Initialize(TestContext testContext)
{
// This runs on class level once before all tests run
//using (var ctx = TestCommon.CreateClientContext())
//{
//}
}

[ClassCleanup]
public static void Cleanup(TestContext testContext)
{
// This runs on class level once
//using (var ctx = TestCommon.CreateClientContext())
//{
//}
}

[TestInitialize]
public void Initialize()
{
using (var scope = new PSTestScope())
{
// Example
// scope.ExecuteCommand("cmdlet", new CommandParameter("param1", prop));
}
}

[TestCleanup]
public void Cleanup()
{
using (var scope = new PSTestScope())
{
try
{
// Do Test Setup - Note, this runs PER test
}
catch (Exception)
{
// Describe Exception
}
}
}
#endregion

#region Scaffolded Cmdlet Tests
//TODO: This is a scaffold of the cmdlet - complete the unit test
//[TestMethod]
public void GetPnPAvailableLanguageTest()
{
using (var scope = new PSTestScope(true))
{
// Complete writing cmd parameters

// From Cmdlet Help: The guid of the web or web object
var identity = "";

var results = scope.ExecuteCommand("Get-PnPAvailableLanguage",
new CommandParameter("Identity", identity));

Assert.IsNotNull(results);
}
}
#endregion
}
}

77 changes: 77 additions & 0 deletions Tests/Webs/GetPnPIndexedPropertyKeysTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Management.Automation.Runspaces;

namespace SharePointPnP.PowerShell.Tests.Webs
{
[TestClass]
public class GetIndexedPropertiesTests
{
#region Test Setup/CleanUp
[ClassInitialize]
public static void Initialize(TestContext testContext)
{
// This runs on class level once before all tests run
//using (var ctx = TestCommon.CreateClientContext())
//{
//}
}

[ClassCleanup]
public static void Cleanup(TestContext testContext)
{
// This runs on class level once
//using (var ctx = TestCommon.CreateClientContext())
//{
//}
}

[TestInitialize]
public void Initialize()
{
using (var scope = new PSTestScope())
{
// Example
// scope.ExecuteCommand("cmdlet", new CommandParameter("param1", prop));
}
}

[TestCleanup]
public void Cleanup()
{
using (var scope = new PSTestScope())
{
try
{
// Do Test Setup - Note, this runs PER test
}
catch (Exception)
{
// Describe Exception
}
}
}
#endregion

#region Scaffolded Cmdlet Tests
//TODO: This is a scaffold of the cmdlet - complete the unit test
//[TestMethod]
public void GetPnPIndexedPropertyKeysTest()
{
using (var scope = new PSTestScope(true))
{
// Complete writing cmd parameters

// From Cmdlet Help: The list object or name from where to get the indexed properties
var list = "";

var results = scope.ExecuteCommand("Get-PnPIndexedPropertyKeys",
new CommandParameter("List", list));

Assert.IsNotNull(results);
}
}
#endregion
}
}

80 changes: 80 additions & 0 deletions Tests/Webs/GetPnPPropertyBagTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Management.Automation.Runspaces;

namespace SharePointPnP.PowerShell.Tests.Webs
{
[TestClass]
public class GetPropertyBagTests
{
#region Test Setup/CleanUp
[ClassInitialize]
public static void Initialize(TestContext testContext)
{
// This runs on class level once before all tests run
//using (var ctx = TestCommon.CreateClientContext())
//{
//}
}

[ClassCleanup]
public static void Cleanup(TestContext testContext)
{
// This runs on class level once
//using (var ctx = TestCommon.CreateClientContext())
//{
//}
}

[TestInitialize]
public void Initialize()
{
using (var scope = new PSTestScope())
{
// Example
// scope.ExecuteCommand("cmdlet", new CommandParameter("param1", prop));
}
}

[TestCleanup]
public void Cleanup()
{
using (var scope = new PSTestScope())
{
try
{
// Do Test Setup - Note, this runs PER test
}
catch (Exception)
{
// Describe Exception
}
}
}
#endregion

#region Scaffolded Cmdlet Tests
//TODO: This is a scaffold of the cmdlet - complete the unit test
//[TestMethod]
public void GetPnPPropertyBagTest()
{
using (var scope = new PSTestScope(true))
{
// Complete writing cmd parameters

// From Cmdlet Help: Key that should be looked up
var key = "";
// From Cmdlet Help: Site relative url of the folder. See examples for use.
var folder = "";

var results = scope.ExecuteCommand("Get-PnPPropertyBag",
new CommandParameter("Key", key),
new CommandParameter("Folder", folder));

Assert.IsNotNull(results);
}
}
#endregion
}
}

Loading

0 comments on commit 20566e1

Please sign in to comment.