/// <summary>
 ///A test for SaveActivityProfile
 ///</summary>
 //[TestMethod()]
 public void SaveActivityProfileTest()
 {
     TCAPI target = new TCAPI("http://cloud.scorm.com/ScormEngineInterface/TCAPI/public", new BasicHTTPAuth("test", "password"));
     ActivityProfile profile = new ActivityProfile();
     profile.ProfileId = "Bananas";
     profile.ActivityId = "example.com";
     profile.Body = "These are contents";
     bool overwrite = false;
     ActivityProfile previous = null;
     target.SaveActivityProfile(profile, overwrite, previous);
     Assert.Inconclusive(INCONCLUSIVE);
 }
        public void ActivityProfileTest()
        {
            TCAPI target = new TCAPI("https://cloud.scorm.com/ScormEngineInterface/TCAPI/CZSWMUZPSE", new BasicHTTPAuth("CZSWMUZPSE", "vwiuflgsY22FDXpHA4lwwe5hrnUXvcyJjW3fDrpH"));
            Actor actor = new Actor("Mufasa", "mailto:[email protected]");
            string[] profileIds = { "The Lion King", "The Fallen King", "The New King" };
            string[] profileContents = {
                "Mufasa rules his country as a proud and fair king of lions, celebrating his recently newborn son Simba.",
                "Scar kills Mufasa, simply muttering the words 'Long Live the King'",
                "Simba finally realizes he must follow in his fathers footsteps to save the kingdom from the evil Scar." };
            string activityId = "example.com/TheLionKing";
            string[] actual;
            actual = target.GetActivityProfileIds(activityId);

            //Assert.AreEqual(0, actual.Length);

            ActivityProfile profile = new ActivityProfile();
            profile.ActivityId = activityId;
            profile.ProfileId = profileIds[0];
            profile.Body = profileContents[0];
            ActivityProfile pp = new ActivityProfile();
            pp.ActivityId = activityId;
            pp.ProfileId = profileIds[0];
            pp.Body = profileContents[0];

            target.SaveActivityProfile(profile, true, pp);

            profile.ProfileId = profileIds[1];
            profile.Body = profileContents[1];

            target.SaveActivityProfile(profile);

            profile.ProfileId = profileIds[2];
            profile.Body = profileContents[2];

            target.SaveActivityProfile(profile);

            /*
            ActivityProfile previous = new ActivityProfile();
            previous.ProfileId = profileIds[2];
            previous.Body = profileContents[1];

            target.SaveActivityProfile(profile, false, previous);
            */

            actual = target.GetActivityProfileIds(activityId);
            Assert.AreEqual(3, actual.Length);

            ActivityProfile apResult = target.GetActivityProfile(activityId, profileIds[0]);
            Assert.AreEqual(profileContents[0], apResult.Body);

            apResult = target.GetActivityProfile(activityId, profileIds[1]);
            Assert.AreEqual(profileContents[1], apResult.Body);

            apResult = target.GetActivityProfile(activityId, profileIds[2]);
            Assert.AreEqual(profileContents[2], apResult.Body);

            target.DeleteActivityProfile(activityId, profileIds[0]);
            actual = target.GetActivityProfileIds(activityId);
            Assert.AreEqual(2, actual.Length);

            target.DeleteAllActivityProfile(activityId);
            actual = target.GetActivityProfileIds(activityId);
            Assert.AreEqual(0, actual.Length);
        }
 /// <summary>
 /// Saves the activity profile
 /// </summary>
 /// <param name="profile">The activity profile to save</param>
 /// <param name="overwrite">Optional parameter to force overwrite</param>
 /// <param name="previous">The last representation of the activity profile</param>
 public void SaveActivityProfile(ActivityProfile profile, bool overwrite, ActivityProfile previous)
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     string putData, previousSha1 = string.Empty;
     putData = profile.Body;
     nvc["overwrite"] = overwrite.ToString();
     nvc["activityId"] = profile.ActivityId;
     nvc["profileId"] = profile.ProfileId;
     if (previous != null)
         previousSha1 = BitConverter.ToString(Encryption.GetSha1Hash(Encoding.UTF8.GetBytes(previous.Body))).Replace("-", "");
     string contentType = profile.ContentType;
     HttpMethods.PutRequest(putData, nvc, endpoint + ACTIVITY_PROFILE, authentification, contentType, previousSha1, versionString);
 }
 /// <summary>
 /// Saves the activity profile
 /// </summary>
 /// <param name="profile">The activity profile to save</param>
 /// <param name="previous">The last representation of the activity profile</param>
 public void SaveActivityProfile(ActivityProfile profile, ActivityProfile previous)
 {
     SaveActivityProfile(profile, false, previous);
 }
 /// <summary>
 /// Saves the activity profile
 /// </summary>
 /// <param name="profile">The activity profile to save</param>
 public void SaveActivityProfile(ActivityProfile profile, bool overwrite)
 {
     SaveActivityProfile(profile, overwrite, null);
 }
 /// <summary>
 /// Saves the activity profile
 /// </summary>
 /// <param name="profile">The activity profile to save</param>
 /// <param name="overwrite">Optional parameter to force overwrite</param>
 public void SaveActivityProfile(ActivityProfile profile)
 {
     SaveActivityProfile(profile, false, null);
 }
 /// <summary>
 /// Retrieves the ActivityProfile
 /// </summary>
 /// <param name="activityId">The activity ID</param>
 /// <param name="profileId">The profile document key</param>
 /// <returns></returns>
 public ActivityProfile GetActivityProfile(string activityId, string profileId)
 {
     ActivityProfile result = new ActivityProfile();
     string getResult;
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     nvc["profileId"] = profileId;
     nvc["activityId"] = activityId;
     WebHeaderCollection whc;
     getResult = HttpMethods.GetRequest(nvc, endpoint + ACTIVITY_PROFILE, authentification, out whc, versionString);
     if (whc != null)
         result.ContentType = whc["Content-Type"];
     result.ProfileId = profileId;
     result.Body = getResult;
     result.ActivityId = activityId;
     return result;
 }