public void GetActorProfileIdsTest()
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     TCAPI target = new TCAPI(new Uri("http://cloud.scorm.com/tc/public"), new BasicHTTPAuth("test", "password"));
     Actor actor = new Actor("Example", "mailto:[email protected]");
     NullableDateTime since = null;
     string[] actual;
     actual = target.GetActorProfileIds(actor, since);
     Console.Write(converter.SerializeToJSON(actual));
     Assert.Inconclusive(INCONCLUSIVE_CONSOLE);
 }
 /// <summary>
 ///A test for GetActorProfile
 ///</summary>
 //[TestMethod()]
 public void GetActorProfileTest()
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     TCAPI target = new TCAPI("http://cloud.scorm.com/ScormEngineInterface/TCAPI/public", new BasicHTTPAuth("test", "password"));
     Actor actor = new Actor("Example", "mailto:[email protected]");
     string profileId = "Example";
     ActorProfile actual;
     actual = target.GetActorProfile(actor, profileId);
     Console.Write(converter.SerializeToJSON(actual));
     Assert.Inconclusive(INCONCLUSIVE_CONSOLE);
 }
 /// <summary>
 ///A test for GetStatements
 ///</summary>
 //[TestMethod()]
 public void GetStatementsTest()
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     TCAPI target = new TCAPI("http://cloud.scorm.com/ScormEngineInterface/TCAPI/public", new BasicHTTPAuth("test", "password"), TCAPIVersion.TinCan090);
     StatementQueryObject queryObject = new StatementQueryObject();
     queryObject.Actor = new Actor("Example", "mailto:[email protected]");
     StatementResult actual;
     actual = target.GetStatements(queryObject);
     Console.Write(converter.SerializeToJSON(actual));
     while (!String.IsNullOrEmpty(actual.More))
     {
         actual = target.GetStatements(actual.More);
         Console.Write(converter.SerializeToJSON(actual));
         //break;
     }
     Assert.Inconclusive(INCONCLUSIVE_CONSOLE);
 }
        /// <summary>
        /// Test to ensure ETag collisions are not ignored.
        /// </summary>
        //[TestMethod()]
        public void CollisionTest()
        {
            TinCanJsonConverter converter = new TinCanJsonConverter();
            TCAPI target = new TCAPI("https://cloud.scorm.com/ScormEngineInterface/TCAPI/CZSWMUZPSE", new BasicHTTPAuth("CZSWMUZPSE", "vwiuflgsY22FDXpHA4lwwe5hrnUXvcyJjW3fDrpH"));
            Actor actor = new Actor("Mufasa", "mailto:[email protected]");
            string[] stateIds = { "The Lion King", "The Fallen King", "The New King" };
            string[] stateContents = {
                "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[] results = target.GetActivityStateIds(activityId, actor);

            ActivityState state = new ActivityState(activityId, stateIds[0], actor, stateContents[1], "text/plain");
            ActivityState previous = new ActivityState(activityId, stateIds[0], actor, stateContents[0], "text/plain");
            target.SaveActivityState(state);
            state.Body = stateContents[2];
            target.SaveActivityState(state, false, previous);
        }
 /// <summary>
 ///A test for GetActivityState
 ///</summary>
 //[TestMethod()]
 public void GetActivityStateTest()
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     TCAPI target = new TCAPI("http://cloud.scorm.com/ScormEngineInterface/TCAPI/public", new BasicHTTPAuth("test", "password"));
     Actor actor = new Actor("Example", "mailto:[email protected]");
     string activityId = "example.com";
     string registrationId = null;
     string stateId = "Bananas";
     ActivityState actual;
     actual = target.GetActivityState(activityId, actor, stateId, registrationId);
     Console.Write(converter.SerializeToJSON(actual));
     Assert.Inconclusive(INCONCLUSIVE_CONSOLE);
 }
Ejemplo n.º 6
0
 /// <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);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Voids a series of statements using the administrator actor
 /// </summary>
 /// <param name="statementIdsToVoid">A list of statement IDs</param>
 /// <param name="synchronous"></param>
 public void VoidStatements(string[] statementIdsToVoid, bool synchronous)
 {
     if (synchronous)
     {
         VoidStatements(statementIdsToVoid);
         return;
     }
     TinCanJsonConverter converter = new TinCanJsonConverter();
     Statement[] statements = new Statement[statementIdsToVoid.Length];
     for (int i = 0; i < statementIdsToVoid.Length; i++)
     {
         Statement voided = new Statement();
         switch (version)
         {
             case TCAPIVersion.TinCan090:
                 voided.Object = new Model.TinCan090.TargetedStatement(statementIdsToVoid[i]);
                 break;
             default:
                 voided.Object = new StatementRef(statementIdsToVoid[i]);
                 break;
         }
         voided.Verb = new StatementVerb(PredefinedVerbs.Voided);
         voided.Actor = adminActor;
         statements[i] = voided;
     }
     offlineStorage.AddToStatementQueue(statements);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Gets an Activity
 /// </summary>
 /// <param name="activityId">The activity ID</param>
 /// <returns></returns>
 public Activity GetActivity(string activityId)
 {
     Activity result = new Activity();
     string getResult;
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     nvc["activityId"] = activityId;
     getResult = HttpMethods.GetRequest(nvc, endpoint + ACTIVITY, authentification, versionString);
     result = (Activity)converter.DeserializeJSON(getResult, typeof(Activity));
     return result;
 }
Ejemplo n.º 9
0
 /// <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;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Deletes all of the profiles associated with the activity
 /// </summary>
 /// <param name="activityId">The activity ID</param>
 public void DeleteAllActivityProfile(string activityId)
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     nvc["activityId"] = activityId;
     HttpMethods.DeleteRequest(nvc, endpoint + ACTIVITY_PROFILE, authentification, versionString);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Deletes all the actor profiles for a given actor
 /// </summary>
 /// <param name="actor">The actor to delete profiles from</param>
 public void DeleteAllActorProfile(Actor actor)
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     switch (version)
     {
         case TCAPIVersion.TinCan090:
             nvc["actor"] = converter.SerializeToJSON((Model.TinCan090.Actor)actor);
             break;
         default:
             nvc["actor"] = converter.SerializeToJSON(actor);
             break;
     }
     HttpMethods.DeleteRequest(nvc, endpoint + ACTOR_PROFILE, authentification, versionString);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Deletes the activity state
 /// </summary>
 /// <param name="activityId">The activity ID</param>
 /// <param name="actor">The associated actor</param>
 /// <param name="stateId">The state document key</param>
 /// <param name="registrationId">Optional registration ID</param>
 public void DeleteActivityState(string activityId, Actor actor, string stateId, string registrationId)
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     nvc["activityId"] = activityId;
     switch (version)
     {
         case TCAPIVersion.TinCan090:
             nvc["actor"] = converter.SerializeToJSON((Model.TinCan090.Actor)actor);
             break;
         default:
             nvc["actor"] = converter.SerializeToJSON(actor);
             break;
     }
     nvc["stateId"] = stateId;
     if (!string.IsNullOrEmpty(registrationId))
         nvc["registrationId"] = registrationId;
     HttpMethods.DeleteRequest(nvc, endpoint + ACTIVITY_STATE, authentification, versionString);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Stores statements synchronously, must be called from a separate thread
 /// </summary>
 /// <param name="statements">Statements to store</param>
 /// <param name="callback">Callback to signal upon completion</param>
 private void StoreStatements(Statement[] statements, AsyncPostCallback callback)
 {
     // Break the statement into a 2D array.  First index is the number of batches, second is the number of
     // statements in that batch, which is either maxBatchSize or statements.Length % maxBatchSize
     Statement[][] batches = new Statement[(statements.Length - 1) / maxBatchSize + 1][];
     for (int i = 0; i < batches.Length; i++)
     {
         batches[i] = new Statement[statements.Length - (maxBatchSize * (i + 1)) >= 0 ? maxBatchSize : statements.Length % maxBatchSize];
         Array.Copy(statements, i * maxBatchSize, batches[i], 0, batches[i].Length);
     }
     for (int round = 0; round < batches.Length; round++)
     {
         foreach (Statement s in batches[round])
         {
             var failures = new List<ValidationFailure>(s.Validate(earlyReturnOnFailure: true));
             if (failures.Count > 0)
             {
                 throw new ArgumentException(failures[0].Error, "statements");
             }
         }
         TinCanJsonConverter converter = new TinCanJsonConverter();
         string postData;
         switch (version)
         {
             case TCAPIVersion.TinCan090:
                 Model.TinCan090.Statement[] currentBatch = new RusticiSoftware.TinCanAPILibrary.Model.TinCan090.Statement[batches[round].Length];
                 for (int i = 0; i < currentBatch.Length; i++)
                     currentBatch[i] = (Model.TinCan090.Statement)batches[round][i];
                 postData = converter.SerializeToJSON(currentBatch);
                 break;
             default:
                 postData = converter.SerializeToJSON(batches[round]);
                 break;
         }
         HttpMethods.PostRequest(postData, endpoint + STATEMENTS, authentification, callback, versionString);
     }
 }
 public void GetStatementsTest()
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     TCAPI target = new TCAPI(new Uri("http://cloud.scorm.com/tc/public"), new BasicHTTPAuth("test", "password"), TCAPIVersion.TinCan095);
     StatementQueryObject queryObject = new StatementQueryObject();
     queryObject.Actor = new Actor("Example", "mailto:[email protected]");
     queryObject.Since = new DateTime(2013, 6, 1);
     queryObject.Limit = 50;
     int limit = 0;
     StatementResult actual;
     actual = target.GetStatements(queryObject);
     limit = actual.Statements.Length;
     Console.Write(converter.SerializeToJSON(actual));
     while (limit <= 50 && !string.IsNullOrEmpty(actual.More))
     {
         actual = target.GetStatements(actual.More);
         Console.Write(converter.SerializeToJSON(actual));
         limit += actual.Statements.Length;
         //break;
     }
     Assert.Inconclusive(INCONCLUSIVE_CONSOLE);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Retreives all statements based matched by the query
 /// </summary>
 /// <param name="queryObject">Object to create a statement query with</param>
 /// <returns>A StatementResult with all the statements</returns>
 public StatementResult GetStatements(StatementQueryObject queryObject)
 {
     NameValueCollection nvc = queryObject.ToNameValueCollection(version);
     string resultAsJSON = HttpMethods.GetRequest(nvc, endpoint + STATEMENTS, authentification, versionString);
     TinCanJsonConverter converter = new TinCanJsonConverter();
     StatementResult result = null;
     switch (version)
     {
         case TCAPIVersion.TinCan095:
             result = (StatementResult)converter.DeserializeJSON(resultAsJSON, typeof(StatementResult));
             break;
         case TCAPIVersion.TinCan090:
             result = (StatementResult)((Model.TinCan090.StatementResult)converter.DeserializeJSON(resultAsJSON, typeof(Model.TinCan090.StatementResult)));
             break;
     }
     return result;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Gets all of the profile document keys for an activity
 /// </summary>
 /// <param name="activityId">The activity ID</param>
 /// <param name="since">Optional start date parameter</param>
 /// <returns></returns>
 public string[] GetActivityProfileIds(string activityId, NullableDateTime since)
 {
     string[] profileIds;
     string getResult;
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     nvc["activityId"] = activityId;
     if (since != null)
         nvc["since"] = since.Value.ToString(Constants.ISO8601_DATE_FORMAT);
     getResult = HttpMethods.GetRequest(nvc, endpoint + ACTIVITY_PROFILE, authentification, versionString);
     profileIds = (string[])converter.DeserializeJSON(getResult, typeof(string[]));
     return profileIds;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Retreives the statements from a continue URL
 /// </summary>
 /// <param name="moreUrl"></param>
 /// <returns></returns>
 public StatementResult GetStatements(string moreUrl)
 {
     string getResult = HttpMethods.GetRequest(null, endpoint.GetLeftPart(UriPartial.Authority) + moreUrl, authentification, versionString);
     TinCanJsonConverter converter = new TinCanJsonConverter();
     StatementResult result = null;
     switch (version)
     {
         case TCAPIVersion.TinCan095:
             result = (StatementResult)converter.DeserializeJSON(getResult, typeof(StatementResult));
             break;
         case TCAPIVersion.TinCan090:
             result = (StatementResult)((Model.TinCan090.StatementResult)converter.DeserializeJSON(getResult, typeof(Model.TinCan090.StatementResult)));
             break;
     }
     return result;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Retrieves a specific activity state
 /// </summary>
 /// <param name="activityId">The activity ID</param>
 /// <param name="actor">The actor associated with the state</param>
 /// <param name="stateId">The state document id</param>
 /// <param name="registrationId">Optional registration ID</param>
 /// <returns>The activity state</returns>
 public ActivityState GetActivityState(string activityId, Actor actor, string stateId, string registrationId)
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     string getResult;
     ActivityState result = new ActivityState();
     nvc["activityId"] = activityId;
     switch (version)
     {
         case TCAPIVersion.TinCan090:
             nvc["actor"] = converter.SerializeToJSON((Model.TinCan090.Actor)actor);
             break;
         default:
             nvc["actor"] = converter.SerializeToJSON(actor);
             break;
     }
     nvc["stateId"] = stateId;
     if (!string.IsNullOrEmpty(registrationId))
         nvc["registrationId"] = registrationId;
     WebHeaderCollection whc;
     getResult = HttpMethods.GetRequest(nvc, endpoint + ACTIVITY_STATE, authentification, out whc, versionString);
     if (whc != null)
         result.ContentType = whc["Content-Type"];
     result.Body = getResult;
     result.ActivityId = activityId;
     result.Actor = actor;
     result.RegistrationId = registrationId;
     result.StateId = stateId;
     return result;
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Saves an actor profile
 /// </summary>
 /// <param name="actorProfile">The actor profile instance</param>
 /// <param name="previousProfile">The last instance of the actor profile</param>
 /// <param name="overwrite">Flag to force overwrite of the previous profile</param>
 public void SaveActorProfile(ActorProfile actorProfile, ActorProfile previousProfile, bool overwrite)
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     string putData = actorProfile.Body;
     nvc["profileId"] = actorProfile.ProfileId;
     switch (version)
     {
         case TCAPIVersion.TinCan090:
             nvc["actor"] = converter.SerializeToJSON((Model.TinCan090.Actor)previousProfile.Actor);
             break;
         default:
             nvc["actor"] = converter.SerializeToJSON(previousProfile.Actor);
             break;
     }
     nvc["overwrite"] = overwrite.ToString();
     string previousSha1 = string.Empty;
     if (previousProfile != null)
         previousSha1 = BitConverter.ToString(Encryption.GetSha1Hash(Encoding.UTF8.GetBytes(previousProfile.Body))).Replace("-", "");
     string contentType = actorProfile.ContentType;
     HttpMethods.PutRequest(putData, nvc, endpoint + ACTOR_PROFILE, authentification, contentType, previousSha1, versionString);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Gets all the activity states for an activity
 /// </summary>
 /// <param name="activityId">The activity ID</param>
 /// <param name="actor">The actor</param>
 /// <param name="registrationId">The registration ID</param>
 /// <param name="since">Exclusive start date</param>
 /// <returns>An array of activity state document keys</returns>
 public string[] GetActivityStateIds(string activityId, Actor actor, string registrationId, NullableDateTime since)
 {
     string[] stateIds;
     string getResult;
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     nvc["activityId"] = activityId;
     switch (version)
     {
         case TCAPIVersion.TinCan090:
             nvc["actor"] = converter.SerializeToJSON((Model.TinCan090.Actor)actor);
             break;
         default:
             nvc["actor"] = converter.SerializeToJSON(actor);
             break;
     }
     if (!string.IsNullOrEmpty(registrationId))
         nvc["registrationId"] = registrationId;
     if (since != null)
         nvc["since"] = since.Value.ToString(Constants.ISO8601_DATE_FORMAT);
     getResult = HttpMethods.GetRequest(nvc, endpoint + ACTIVITY_STATE, authentification, versionString);
     stateIds = (string[])converter.DeserializeJSON(getResult, typeof(string[]));
     return stateIds;
 }
        /// <summary>
        /// A test for pushing and storing Actor Profiles, then deleting them.
        /// </summary>
        /// <remarks>This test should use a dummy actor, not a real one!</remarks>
        //[TestMethod()]
        public void ActorProfileTest()
        {
            TinCanJsonConverter converter = new TinCanJsonConverter();
            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." };

            // Clear all existing profiles.
            target.DeleteAllActorProfile(actor);

            NullableDateTime since = null;
            string[] actual;
            actual = target.GetActorProfileIds(actor, since);

            Assert.AreEqual(0, actual.Length);

            /* Save a new actor profile */
            ActorProfile p1 = new ActorProfile();
            p1.Actor = actor;
            p1.ProfileId = profileIds[0];
            p1.Body = profileContents[0];
            ActorProfile pp = new ActorProfile();
            pp.ProfileId = profileIds[0];
            pp.Actor = actor;
            pp.Body = profileContents[0];
            target.SaveActorProfile(p1, pp, true);
            actual = target.GetActorProfileIds(actor, since);

            Assert.AreEqual(1, actual.Length);

            p1.ProfileId = profileIds[1];
            p1.Body = profileContents[1];
            pp.ProfileId = profileIds[1];
            target.SaveActorProfile(p1, pp, true);
            actual = target.GetActorProfileIds(actor, since);

            Assert.AreEqual(2, actual.Length);

            p1.ProfileId = profileIds[2];
            p1.Body = profileContents[2];
            pp.ProfileId = profileIds[2];
            target.SaveActorProfile(p1, pp, true);
            actual = target.GetActorProfileIds(actor);

            Assert.AreEqual(3, actual.Length);

            // Ensure all the posted data matches

            ActorProfile pResult = target.GetActorProfile(actor, profileIds[0]);
            Assert.AreEqual(profileContents[0], pResult.Body);

            pResult = target.GetActorProfile(actor, profileIds[1]);
            Assert.AreEqual(profileContents[1], pResult.Body);

            pResult = target.GetActorProfile(actor, profileIds[2]);
            Assert.AreEqual(profileContents[2], pResult.Body);

            target.DeleteActorProfile(actor, profileIds[0]);
            actual = target.GetActorProfileIds(actor);

            Assert.AreEqual(2, actual.Length);

            target.DeleteAllActorProfile(actor);
            actual = target.GetActorProfileIds(actor);

            Assert.AreEqual(0, actual.Length);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Retreives a complete actor given a partial actor
        /// </summary>
        /// <param name="partialActor">An actor containing at least one inverse functional property</param>
        /// <returns></returns>
        public Actor GetActor(Actor partialActor)
        {
            TinCanJsonConverter converter = new TinCanJsonConverter();
            NameValueCollection nvc = new NameValueCollection();
            string getResult;
            Actor result = null;

            switch (version)
            {
                case TCAPIVersion.TinCan090:
                    nvc["actor"] = converter.SerializeToJSON((Model.TinCan090.Actor)partialActor);
                    break;
                default:
                    nvc["actor"] = converter.SerializeToJSON(partialActor);
                    break;
            }
            getResult = HttpMethods.GetRequest(nvc, endpoint + ACTORS, authentification, versionString);
            switch (version)
            {
                case TCAPIVersion.TinCan095:
                    result = (Actor)converter.DeserializeJSON(getResult, typeof(Actor));
                    break;
                case TCAPIVersion.TinCan090:
                    result = (Actor)((Model.TinCan090.Actor)converter.DeserializeJSON(getResult, typeof(Model.TinCan090.Actor)));
                    break;
            }

            return result;
        }
 /// <summary>
 ///A test for GetActivityProfileIds
 ///</summary>
 //[TestMethod()]
 public void GetActivityProfileIdsTest()
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     TCAPI target = new TCAPI("http://cloud.scorm.com/ScormEngineInterface/TCAPI/public", new BasicHTTPAuth("test", "password"));
     string activityId = "example.com";
     NullableDateTime since = null;
     string[] actual;
     actual = target.GetActivityProfileIds(activityId, since);
     Console.Write(converter.SerializeToJSON(actual));
     Assert.Inconclusive(INCONCLUSIVE_CONSOLE);
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Retrieves an Actor profile
 /// </summary>
 /// <param name="actor">The actor that owns the profile</param>
 /// <param name="profileId">The profile document key</param>
 /// <returns></returns>
 public ActorProfile GetActorProfile(Actor actor, string profileId)
 {
     ActorProfile result = new ActorProfile();
     string getResult;
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     switch (version)
     {
         case TCAPIVersion.TinCan090:
             nvc["actor"] = converter.SerializeToJSON((Model.TinCan090.Actor)actor);
             break;
         default:
             nvc["actor"] = converter.SerializeToJSON(actor);
             break;
     }
     nvc["profileId"] = profileId;
     WebHeaderCollection whc;
     getResult = HttpMethods.GetRequest(nvc, endpoint + ACTOR_PROFILE, authentification, out whc, versionString);
     if (whc != null)
         result.ContentType = whc["Content-Type"];
     result.ProfileId = profileId;
     result.Actor = actor;
     result.Body = getResult;
     return result;
 }
 /// <summary>
 ///A test for GetActivity
 ///</summary>
 //[TestMethod()]
 public void GetActivityTest()
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     TCAPI target = new TCAPI("http://cloud.scorm.com/ScormEngineInterface/TCAPI/public", new BasicHTTPAuth("test", "password"));
     string activityId = "example.com"; // TODO: Initialize to an appropriate value
     Activity actual;
     actual = target.GetActivity(activityId);
     Console.Write(converter.SerializeToJSON(actual));
     Assert.Inconclusive(INCONCLUSIVE_CONSOLE);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Retrieves a list of all actor profile document keys
 /// </summary>
 /// <param name="actor">The actor that owns the document keys</param>
 /// <param name="since">Optional start date</param>
 /// <returns>An array of profile document keys</returns>
 public string[] GetActorProfileIds(Actor actor, NullableDateTime since)
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     string[] getResult;
     switch (version)
     {
         case TCAPIVersion.TinCan090:
             nvc["actor"] = converter.SerializeToJSON((Model.TinCan090.Actor)actor);
             break;
         default:
             nvc["actor"] = converter.SerializeToJSON(actor);
             break;
     }
     if (since != null)
         nvc["since"] = since.Value.ToString(Constants.ISO8601_DATE_FORMAT);
     getResult = (string[])converter.DeserializeJSON(HttpMethods.GetRequest(nvc, endpoint + ACTOR_PROFILE, authentification, versionString), typeof(string[]));
     return getResult;
 }
 /// <summary>
 ///A test for GetActor
 ///</summary>
 //[TestMethod()]
 public void GetActorTest()
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     TCAPI target = new TCAPI("http://cloud.scorm.com/ScormEngineInterface/TCAPI/public", new BasicHTTPAuth("test", "password"));
     Actor partialActor = new Actor();
     partialActor.Mbox = "mailto:[email protected]";
     Actor fullActor = target.GetActor(partialActor);
     Console.Write(converter.SerializeToJSON(fullActor));
     Assert.Inconclusive(INCONCLUSIVE_CONSOLE);
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Retreives a statement with a given ID
 /// </summary>
 /// <param name="statementId">Statement to retreive</param>
 /// <returns>The statement with this ID</returns>
 public Statement GetStatement(string statementId)
 {
     Statement statement = new Statement();
     statement.Id = statementId;
     TinCanJsonConverter converter = new TinCanJsonConverter();
     string statementToGet = converter.SerializeToJSON(statement);
     NameValueCollection nvc = new NameValueCollection();
     nvc["statementId"] = statementId;
     string result = HttpMethods.GetRequest(nvc, endpoint + STATEMENTS, authentification, versionString);
     Statement statementResult = null;
     switch (version)
     {
         case TCAPIVersion.TinCan090:
             statementResult = (Statement)((Model.TinCan090.Statement)converter.DeserializeJSON(result, typeof(Model.TinCan090.Statement)));
             break;
         case TCAPIVersion.TinCan095:
             statementResult = (Statement)converter.DeserializeJSON(result, typeof(Statement));
             break;
     }
     return statementResult;
 }
 /// <summary>
 ///A test for GetStatement
 ///</summary>
 //[TestMethod()]
 public void GetStatementTest()
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     TCAPI target = new TCAPI("http://cloud.scorm.com/ScormEngineInterface/TCAPI/public", new BasicHTTPAuth("test", "password"));
     Statement actual;
     actual = target.GetStatement("c17c9b10-95d4-4579-90d2-d2d4683fb88b");
     Console.Write(converter.SerializeToJSON(actual));
     Assert.Inconclusive(INCONCLUSIVE_CONSOLE);
 }
 public void GetActivityProfileTest()
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     TCAPI target = new TCAPI(new Uri("http://cloud.scorm.com/tc/public"), new BasicHTTPAuth("test", "password"));
     string activityId = "example.com";
     string profileId = "Bananas";
     ActivityProfile actual;
     actual = target.GetActivityProfile(activityId, profileId);
     Console.Write(converter.SerializeToJSON(actual));
     Assert.Inconclusive(INCONCLUSIVE_CONSOLE);
 }