/// <summary> ///A test for StoreStatements ///</summary> //[TestMethod()] public void StoreStatementsAsyncTest() { TCAPI target = new TCAPI("https://cloud.scorm.com/ScormEngineInterface/TCAPI/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 TinCanActivity("test activity")); break; case 1: statements[i] = new Statement(new Actor("Carl", "mailto:[email protected]"), new StatementVerb(PredefinedVerbs.Experienced), new TinCanActivity("TinCanClientLibrary")); break; case 2: statements[i] = new Statement(new Actor("DiBiase", "mailto:[email protected]"), new StatementVerb(PredefinedVerbs.Experienced), new TinCanActivity("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); }