protected override void Save(IEnvironmentModel environmentModel, dynamic jsonObj)
 {
     // ReSharper disable once MaximumChainedReferences
     string resName = jsonObj.resourceName;
     string resCat = HelperUtils.SanitizePath((string)jsonObj.resourcePath, resName);
     var dropBoxSource = new OauthSource { Key = Token, Secret = Secret, ResourceName = resName, ResourcePath = resCat, IsNewResource = true, ResourceID = Guid.NewGuid() }.ToStringBuilder();
     environmentModel.ResourceRepository.SaveResource(environmentModel,dropBoxSource , GlobalConstants.ServerWorkspaceID);
 }
        public void OauthSource_Ctor_Construct_ExpectSource()
        {
            //------------Setup for test--------------------------
            var oauthSource = new OauthSource();
            
            //------------Execute Test---------------------------

            //------------Assert Results-------------------------
            Assert.AreEqual(oauthSource.Secret,"");
            Assert.AreEqual(oauthSource.Key,"");
        }
        public void OauthSource_ToXML_Construct_ExpectPropertiesSet()
        {
            //------------Setup for test--------------------------
            var oauthSource = new OauthSource(){Key = "key",Secret = "secret"};

            //------------Execute Test---------------------------
            var outxml = oauthSource.ToXml();
            //------------Assert Results-------------------------
            var readOauthSource = new OauthSource(outxml);
            readOauthSource.Key = "key";
            readOauthSource.Secret = "secret";
            
            var conStringAttr = outxml.Attribute("ConnectionString");
            Assert.IsNotNull(conStringAttr);
            Assert.IsTrue(conStringAttr.Value.IsBase64());            
        }
        public void OauthSource_ToXML_Construct_ExpectPropertiesSet()
        {
            //------------Setup for test--------------------------
            var oauthSource = new OauthSource(){Key = "key",Secret = "secret"};

            //------------Execute Test---------------------------
            var outxml = oauthSource.ToXml();
            //------------Assert Results-------------------------
            Assert.AreEqual(outxml.ToString(), @"<Source ID=""00000000-0000-0000-0000-000000000000"" Name="""" ResourceType=""OauthSource"" IsValid=""false"" ConnectionString=""Secret=secret;Key=key"" Type=""OauthSource"">
  <DisplayName></DisplayName>
  <Category></Category>
  <AuthorRoles></AuthorRoles>
  <ErrorMessages />
  <TypeOf>OauthSource</TypeOf>
</Source>");
        }
        public void OauthSource_Ctor_FromXML_Construct_ExpectSource()
        {
            //------------Setup for test--------------------------
            var oauthSource = new OauthSource(XElement.Parse(@"<Source ID=""00000000-0000-0000-0000-000000000000"" Name="""" ResourceType=""OauthSource"" IsValid=""false"" ConnectionString=""Secret=secret;Key=key"" Type=""OauthSource"">
  <DisplayName></DisplayName>
  <Category></Category>
  <AuthorRoles></AuthorRoles>
  <ErrorMessages />
  <TypeOf>OauthSource</TypeOf>
</Source>"));

            //------------Execute Test---------------------------

            //------------Assert Results-------------------------
            Assert.AreEqual(oauthSource.Secret, "secret");
            Assert.AreEqual(oauthSource.Key, "key");
        }
 void SetSelectedOAuthSource(OauthSource oAuthSource)
 {
     var selectOAuthSource = oAuthSource == null ? null : Sources.FirstOrDefault(d => d.ResourceID == oAuthSource.ResourceID);
     if (selectOAuthSource == null)
     {
         if (Sources.FirstOrDefault(d => d.Equals(SelectOAuthSource)) == null)
         {
             Sources.Insert(0, SelectOAuthSource);
         }
         selectOAuthSource = SelectOAuthSource;
     }
     SelectedSource = selectOAuthSource;
 }
 // ReSharper restore InconsistentNaming
 static OauthSource CreateOAuthSource()
 {
     var resourceID = Guid.NewGuid();
     var oauthSource = new OauthSource { ResourcePath = "OAuth Tests\\" + resourceID, ResourceName = resourceID.ToString(), ResourceID = resourceID };
     ResourceCatalog.Instance.SaveResource(Guid.Empty, oauthSource);
     return oauthSource;
 }