Skip to content

Commit

Permalink
TestCommunicationProvider: updated interface implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Stroganov committed Mar 6, 2019
1 parent 872d381 commit bc19946
Showing 1 changed file with 60 additions and 58 deletions.
118 changes: 60 additions & 58 deletions Source/SdkTests/Common/TestCommunicationProvider.cs
Original file line number Diff line number Diff line change
@@ -1,63 +1,65 @@
namespace SdkTests.Common
{
using System;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using AdobeConnectSDK.Interfaces;
using AdobeConnectSDK.Model;

internal class TestCommunicationProvider : ICommunicationProvider
{
public ISdkSettings Settings { get; set; }

public ApiStatus ProcessRequest(string pAction, string qParams)
using System;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using AdobeConnectSDK.Interfaces;
using AdobeConnectSDK.Model;

internal class TestCommunicationProvider : ICommunicationProvider
{
ApiStatus apiStatus = new ApiStatus();

switch (pAction)
{
case "login":
apiStatus = AdobeConnectSDK.Common.Helpers.ResolveOperationStatusFlags(new XmlTextReader(new StringReader(Helpers.GetAssemblyResource("login.xml"))));
apiStatus.SessionInfo = Guid.NewGuid().ToString();
break;
case "testAction.ResolveOperationStatusFlags":
var sourceXml= new XmlTextReader(new StringReader(Helpers.GetAssemblyResource("testAction.ResolveOperationStatusFlags.xml")));
var xDoc = XDocument.Load(sourceXml);

if (qParams == "invalid-missing")
{
var elementInvalid = new XElement("invalid", new XAttribute("subcode", AdobeConnectSDK.Common.Helpers.EnumToString(StatusSubCodes.Missing)), new XAttribute("field", "testField"));
var elementStatus = xDoc.XPathSelectElement("//status");
elementStatus.Attribute("code").SetValue(AdobeConnectSDK.Common.Helpers.EnumToString(StatusCodes.Invalid));
elementStatus.Add(elementInvalid);

apiStatus = AdobeConnectSDK.Common.Helpers.ResolveOperationStatusFlags(xDoc.CreateReader());
}

if (qParams == "no-access-Denied")
{
var elementInvalid = new XElement("invalid", new XAttribute("subcode", AdobeConnectSDK.Common.Helpers.EnumToString(StatusSubCodes.Denied)));
var elementStatus = xDoc.XPathSelectElement("//status");
elementStatus.Attribute("code").SetValue(AdobeConnectSDK.Common.Helpers.EnumToString(StatusCodes.NoAccess));
elementStatus.Add(elementInvalid);

apiStatus = AdobeConnectSDK.Common.Helpers.ResolveOperationStatusFlags(xDoc.CreateReader());
}

if (qParams == "no-results")
{
apiStatus = AdobeConnectSDK.Common.Helpers.ResolveOperationStatusFlags(xDoc.CreateReader());
}

break;
default:
apiStatus = AdobeConnectSDK.Common.Helpers.ResolveOperationStatusFlags(new XmlTextReader(new StringReader(Helpers.GetAssemblyResource(pAction + ".xml"))));
break;
}

return apiStatus;
public ISdkSettings Settings { get; set; }

public ApiStatus ProcessRequest(string pAction, string qParams, ISdkSettings settings)
{
ApiStatus apiStatus = new ApiStatus();

switch (pAction)
{
case "login":
apiStatus = AdobeConnectSDK.Common.Helpers.ResolveOperationStatusFlags(new XmlTextReader(new StringReader(Helpers.GetAssemblyResource("login.xml"))));
apiStatus.SessionInfo = Guid.NewGuid().ToString();
break;
case "testAction.ResolveOperationStatusFlags":
var sourceXml = new XmlTextReader(new StringReader(Helpers.GetAssemblyResource("testAction.ResolveOperationStatusFlags.xml")));
var xDoc = XDocument.Load(sourceXml);

if (qParams == "invalid-missing")
{
var elementInvalid = new XElement("invalid",
new XAttribute("subcode", AdobeConnectSDK.Common.Helpers.EnumToString(StatusSubCodes.Missing)),
new XAttribute("field", "testField"));
var elementStatus = xDoc.XPathSelectElement("//status");
elementStatus.Attribute("code").SetValue(AdobeConnectSDK.Common.Helpers.EnumToString(StatusCodes.Invalid));
elementStatus.Add(elementInvalid);

apiStatus = AdobeConnectSDK.Common.Helpers.ResolveOperationStatusFlags(xDoc.CreateReader());
}

if (qParams == "no-access-Denied")
{
var elementInvalid = new XElement("invalid", new XAttribute("subcode", AdobeConnectSDK.Common.Helpers.EnumToString(StatusSubCodes.Denied)));
var elementStatus = xDoc.XPathSelectElement("//status");
elementStatus.Attribute("code").SetValue(AdobeConnectSDK.Common.Helpers.EnumToString(StatusCodes.NoAccess));
elementStatus.Add(elementInvalid);

apiStatus = AdobeConnectSDK.Common.Helpers.ResolveOperationStatusFlags(xDoc.CreateReader());
}

if (qParams == "no-results")
{
apiStatus = AdobeConnectSDK.Common.Helpers.ResolveOperationStatusFlags(xDoc.CreateReader());
}

break;
default:
apiStatus = AdobeConnectSDK.Common.Helpers.ResolveOperationStatusFlags(new XmlTextReader(new StringReader(Helpers.GetAssemblyResource(pAction + ".xml"))));
break;
}

return apiStatus;
}
}
}
}

0 comments on commit bc19946

Please sign in to comment.