예제 #1
0
        public void InitializeApi()
        {
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork             += delegate { TCAPI.CreateInstance(); };
            worker.RunWorkerCompleted += delegate {
                if (ApiInitializedEvent != null)
                {
                    ApiInitializedEvent();
                }
            };
            worker.RunWorkerAsync();
        }
예제 #2
0
        public void SaveActivityProfileTest()
        {
            TCAPI           target  = new TCAPI(new Uri("http://cloud.scorm.com/tc/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);
        }
예제 #3
0
        public void GetActivityStateTest()
        {
            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]");
            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);
        }
 public static void WriteSettingsToUserFile(String recordWebOrSap)
 {
     using (TCAPI tcapi = TCAPI.Instance is null ? TCAPI.CreateInstance() : TCAPI.Instance)
     {
         PropertyInfo APIVersionString = tcapi.GetType().GetProperty("APIVersionString");
         string[]     lines            = { API_PORT_KEY + "=" + Settings.Default.NeoLoadApiPort,
                                           API_KEY_KEY + "=" + Settings.Default.NeoLoadApiKey,
                                           API_HOSTNAME_KEY + "=" + Settings.Default.NeoLoadApiHostname,
                                           CREATE_TRANSACTION_BY_SAP_TCODE_KEY + "=" + Settings.Default.CreateTransactionBySapTCode,
                                           RECORD_WEB_OR_SAP + "=" + recordWebOrSap,
                                           TCAPI_VERSION + "=" + (APIVersionString == null ? tcapi.APIVersionAndBuild.ToString() : APIVersionString.GetValue(tcapi)), };
         System.IO.File.WriteAllLines(GetUserFilePath(), lines);
     }
 }
예제 #5
0
        public void StoreStatementTest()
        {
            TCAPI target = new TCAPI(new Uri("http://cloud.scorm.com/tc/public"), new BasicHTTPAuth("test", "password"));

            target.MaxBatchSize = 1;
            Statement[] statements = new Statement[1];
            Activity    activity   = new Activity("http://www.example.com");

            activity.Definition      = new ActivityDefinition();
            activity.Definition.Name = new LanguageMap();
            activity.Definition.Name.Add("en-US", "TCAPI C# 0.95 Library.");
            statements[0] = new Statement(new Actor("Example", "mailto:[email protected]"), new StatementVerb(PredefinedVerbs.Experienced), activity);
            target.StoreStatements(statements);
            Assert.Inconclusive(INCONCLUSIVE);
        }
예제 #6
0
        public void SaveActivityStateTest()
        {
            TCAPI         target        = new TCAPI(new Uri("http://cloud.scorm.com/tc/public"), new BasicHTTPAuth("test", "password"));
            ActivityState activityState = new ActivityState();

            activityState.ActivityId = "example.com";
            activityState.Actor      = new Actor("Example", "mailto:[email protected]");
            activityState.Body       = "This is a test input.";
            activityState.StateId    = "Bananas";
            bool          overwrite     = false;
            ActivityState previousState = null;

            target.SaveActivityState(activityState, overwrite, previousState);
            Assert.Inconclusive(INCONCLUSIVE);
        }
예제 #7
0
        private static TCWorkspace InitializeAPIAndOpenWorkSpace()
        {
            Console.WriteLine("Connecting to Tosca Workspace");
            TCAPI api = TCAPI.CreateInstance();

            //Path to the Workspace to open
            String workspacePath = ToscaReportGenerator.Default.workspacePath;

            //Credentials for the login
            String loginName     = ToscaReportGenerator.Default.loginName;
            String loginPassword = ToscaReportGenerator.Default.loginPassword;
            //Open Workspace and retrieve TCWorkspace Object
            TCWorkspace myWorkspace = TCAPI.Instance.OpenWorkspace(workspacePath, loginName, loginPassword);

            return(myWorkspace);
        }
예제 #8
0
        public void SaveActorProfileTest()
        {
            TCAPI        target       = new TCAPI(new Uri("http://cloud.scorm.com/tc/public"), new BasicHTTPAuth("test", "password"));
            ActorProfile actorProfile = new ActorProfile();

            actorProfile.Actor     = new Actor("Example", "mailto:[email protected]");
            actorProfile.ProfileId = "Example";
            actorProfile.Body      = "This is some test";
            ActorProfile previousProfile = new ActorProfile();

            previousProfile.Actor     = new Actor("Example", "mailto:[email protected]");
            previousProfile.ProfileId = "Example";
            previousProfile.Body      = "Hello";
            bool overwrite = true;

            target.SaveActorProfile(actorProfile, previousProfile, overwrite);
            Assert.Inconclusive(INCONCLUSIVE);
        }
예제 #9
0
        public void StoreStatementsAsyncTest()
        {
            TCAPI target = new TCAPI(new Uri("https://cloud.scorm.com/tc/CZSWMUZPSE"), new BasicHTTPAuth("CZSWMUZPSE", "vwiuflgsY22FDXpHA4lwwe5hrnUXvcyJjW3fDrpH"), new TCAPICallback(), new OfflineStorage(), 750, 2);

            Statement[] statements = new Statement[6];
            for (int i = 0; i < statements.Length; i++)
            {
                int j = i % 3;
                switch (j)
                {
                case 0:
                    statements[i] = new Statement(new Actor("Mufasa", "mailto:[email protected]"), new StatementVerb(PredefinedVerbs.Experienced), new Activity("test activity"));
                    break;

                case 1:
                    statements[i] = new Statement(new Actor("Carl", "mailto:[email protected]"), new StatementVerb(PredefinedVerbs.Experienced), new Activity("TinCanClientLibrary"));
                    break;

                case 2:
                    statements[i] = new Statement(new Actor("DiBiase", "mailto:[email protected]"), new StatementVerb(PredefinedVerbs.Experienced), new Activity("test activity"));
                    break;
                }
            }
            target.StoreStatements(statements, false);
            //target.Flush();
            Statement[] statementSize;
            while ((statementSize = target.OfflineStorage.GetQueuedStatements(1)) != null &&
                   (statementSize.Length > 0))
            {
                Thread.Sleep(500);
                Console.WriteLine("Waiting");
            }
            target.Dispose(); // Releases the thread timer handle
            // If all statements successfully flush out of the buffer AND no exceptions are thrown (which should repopulate the buffer)
            // then the test was successful and the final statementSize should be null, indicating an empty queue.
            // The default implementation returns a null object.  However you may also return a size-0 array, all checks ensure both.
            Assert.IsTrue(statementSize == null || statementSize.Length == 0);
        }
예제 #10
0
        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);
        }
예제 #11
0
        public void ActivityProfileTest()
        {
            TCAPI target = new TCAPI(new Uri("http://cloud.scorm.com/tc/public"), 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);
        }
예제 #12
0
        public void ActivityStateTest()
        {
            TinCanJsonConverter converter = new TinCanJsonConverter();
            TCAPI target = new TCAPI(new Uri("http://cloud.scorm.com/tc/public"), 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);

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

            ActivityState state = new ActivityState();

            state.ActivityId = activityId;
            state.Actor      = actor;
            state.StateId    = stateIds[0];
            state.Body       = stateContents[0];

            ActivityState previous = new ActivityState();

            previous.ActivityId = activityId;
            previous.Actor      = actor;
            previous.StateId    = stateIds[0];
            previous.Body       = stateContents[0];

            target.SaveActivityState(state, false, previous);

            //target.SaveActivityState(state);

            state.StateId = stateIds[1];
            state.Body    = stateContents[1];
            target.SaveActivityState(state);

            state.StateId = stateIds[2];
            state.Body    = stateContents[2];
            target.SaveActivityState(state);

            results = target.GetActivityStateIds(activityId, actor);

            Assert.AreEqual(3, results.Length);

            ActivityState asResult = target.GetActivityState(activityId, actor, stateIds[0]);

            Assert.AreEqual(stateContents[0], asResult.Body);
            asResult = target.GetActivityState(activityId, actor, stateIds[0]);

            asResult = target.GetActivityState(activityId, actor, stateIds[1]);
            Assert.AreEqual(stateContents[1], asResult.Body);

            asResult = target.GetActivityState(activityId, actor, stateIds[2]);
            Assert.AreEqual(stateContents[2], asResult.Body);

            /*
             * target.DeleteActivityState(activityId, actor, stateIds[0]);
             * results = target.GetActivityStateIds(activityId, actor);
             *
             * Assert.AreEqual(2, results.Length);
             * target.DeleteActivityState(activityId, actor, stateIds[1]);
             * target.DeleteActivityState(activityId, actor, stateIds[2]);
             */
            results = target.GetActivityStateIds(activityId, actor);
        }
예제 #13
0
        public void ActorProfileTest()
        {
            TinCanJsonConverter converter = new TinCanJsonConverter();
            TCAPI target = new TCAPI(new Uri("http://cloud.scorm.com/tc/public"), 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);
        }