Beispiel #1
0
        public Tests.Request Transform(Tests.Request request)
        {
            if (string.IsNullOrEmpty(RandomString.LoadString))
            {
                lock (string_lock)
                {
                    if (string.IsNullOrEmpty(RandomString.LoadString))
                    {
                        Console.WriteLine("Building string...");
                        StringBuilder sb = new StringBuilder();
                        var part = Helpers.GetRandomString();
                        for (int i = 0; i < 20000 / part.Length; i++)
                        {
                            sb.Append(part);
                        }
                        RandomString.LoadString = sb.ToString();
                    }
                }
            }
            request.Url = request.Url.Replace("{random_string}", Helpers.GetRandomString());
            if (!string.IsNullOrEmpty(request.BodyBytes))
            {
                if (request.BodyBytes.Contains("{random_string}"))
                {
                    request.BodyBytes = request.BodyBytes.Replace("{random_string}", Helpers.GetRandomString() + RandomString.LoadString);
                }
            }

            return request;
        }
Beispiel #2
0
	public static int Main ()
	{
		var v = new Tests ();
		if (v.s != "long")
			return 1;
		
		return 0;
	}
Beispiel #3
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model object</param>
        /// <param name="view">The view used</param>
        /// <param name="explorerPresenter">The explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.view = view as ITestView;
            this.tests = model as Tests;
            this.explorerPresenter = explorerPresenter;

            this.dataStore = Apsim.Find(this.tests, typeof(DataStore)) as DataStore;
            this.view.Editor.IntelliSenseChars = " :";
            this.view.Editor.ContextItemsNeeded += this.OnContextItemsNeeded;
            this.view.TableNameChanged += this.OnTableNameChanged;

            this.PopulateView();
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;
        }
Beispiel #4
0
        public void Run()
        {
            var key = "RegistrationServer_ShowPresentcount_" + DateTime.Now.Date.ToString("yyyy-MM-dd");
            var xx1 = RedisServer.StringGetCache<long>(key);

            long xx = 0;
            RedisServer.StringSetCache("11", "asdfasdf");
            var ss = RedisServer.StringGetCache<string>("11");
            //RedisServer.Remove("11");
           // ss = RedisServer.StringGetCache<string>("11");
          var time = DateTime.Now;

            var s = RedisServer.ExistsKey("11");

           
            RedisServer.StringDaySetCache("21", time);
            time = RedisServer.StringGetCache<DateTime>("21");

            var ts = new Tests
            {
                id = 1,
                Tilte = "123"
            };
            RedisServer.StringSetCache("31", ts);
            var ts1 = RedisServer.StringGetCache<Tests>("31");
            ts1.id = 2;
            RedisServer.StringSetCache("31", ts1);
            var ts2 = RedisServer.StringGetCache<Tests>("31");
           
                        //long xx = 0;

                        // xx = RedisServer.StringIncrement("asdf1", 10);
                        xx = RedisServer.Increment("asdf11");
            xx = RedisServer.Increment("asdf11");
            xx = RedisServer.Increment("asdf11");
            xx = RedisServer.StringGetCache<long>("asdf11");
            xx = RedisServer.Increment("asdf11",100);
            xx = RedisServer.Increment("asdf11");
            xx = RedisServer.StringGetCache<long>("asdf11");
            xx = RedisServer.Increment("asdf11");
          

        }
Beispiel #5
0
 public void invoke_2()
 {
     Tests.invoke_in_domain_2();
 }
        public void Run(TestConfig config)
        {
            int    i;
            Record r     = null;
            int    count = config.Count;
            var    res   = new TestIndexNumericResult();

            config.Result = res;

            var       start = DateTime.Now;
            IDatabase db    = config.GetDatabase();

            Tests.Assert(null == db.Root);
            var idx = db.CreateIndex <Record, Record>(IndexType.NonUnique);

            db.Root = idx;
            long val = 1999;

            for (i = 0; i < count; i++)
            {
                r = new Record(val);
                r.MakePersistent(db);
                idx.Put(r, r);
                if (i % 100 == 0)
                {
                    db.Commit();
                }
                val = (3141592621L * val + 2718281829L) % 1000000007L;
            }

            Tests.Assert(idx.Count == count);
            db.Commit();
            res.InsertTime = DateTime.Now - start;
            Tests.Assert(idx.Count == count);
            Record[] recs = idx.ToArray();
            Array.Sort(recs, (r1, r2) => { return(r1.Oid - r2.Oid); });
            Tests.Assert(recs.Length == count);
            Record min = recs[0];
            Record max = recs[recs.Length - 1];
            Record mid = recs[recs.Length / 2];

            start = System.DateTime.Now;
            recs  = idx[min, mid];
            i     = 0;
            foreach (var r2 in recs)
            {
                Tests.Assert(r2.Oid >= min.Oid && r2.Oid <= mid.Oid);
                i++;
            }
            recs = idx[mid, max];
            i    = 0;
            foreach (var r2 in recs)
            {
                Tests.Assert(r2.Oid >= mid.Oid && r2.Oid <= max.Oid);
                i++;
            }
            long prev = min.Oid;

            i = 0;
            var e1 = idx.GetEnumerator();

            while (e1.MoveNext())
            {
                r = e1.Current;
                Tests.Assert(r.Oid >= prev);
                prev = r.Oid;
                i++;
            }
            Tests.VerifyEnumeratorDone(e1);

            prev = min.Oid;
            i    = 0;
            foreach (var r2 in idx)
            {
                Tests.Assert(r2.Oid >= prev);
                prev = r2.Oid;
                i++;
            }

            prev = min.Oid;
            i    = 0;
            foreach (var r2 in idx.Range(min, max, IterationOrder.AscentOrder))
            {
                Tests.Assert(r2.Oid >= prev);
                prev = r2.Oid;
                i++;
            }

            prev = max.Oid;
            i    = 0;
            foreach (var r2 in idx.Range(min, max, IterationOrder.DescentOrder))
            {
                Tests.Assert(prev >= r2.Oid);
                prev = r2.Oid;
                i++;
            }

            prev = max.Oid;
            i    = 0;
            foreach (var r2 in idx.Reverse())
            {
                Tests.Assert(prev >= r2.Oid);
                prev = r2.Oid;
                i++;
            }
            long usedBeforeDelete = db.UsedSize;

            recs = idx[min, max];
            i    = 0;
            foreach (var r2 in recs)
            {
                Tests.Assert(!r2.IsDeleted());
                idx.Remove(r2, r2);
                r2.Deallocate();
                i++;
            }
            Tests.Assert(idx.Count == 0);
            db.Commit();
            long usedAfterDelete = db.UsedSize;

            db.Gc();
            db.Commit();
            long usedAfterGc = db.UsedSize;

            db.Close();
        }
Beispiel #7
0
        /// <summary>
        /// Add an apsim file to the database.
        /// </summary>
        public static void InsertApsimFile(DbConnection connection, ApsimFile apsimfile, out string ErrMessageHelper, out int ApsimID)
        {
            ApsimID = 0;
            string strSQL;

            Utilities.WriteToLogFile(string.Format("Processing PullRequestId {0}, Apsim Filename {1}, dated {2}!", apsimfile.PullRequestId, apsimfile.FileName, apsimfile.RunDate.ToString("dd/MM/yyyy HH:mm")));

            //--------------------------------------------------------------------------------------
            //Need to check if this Pull Request Id has already been used,  if it has, then we need
            //to delete everything associated with it before we save the new set of data
            //--------------------------------------------------------------------------------------
            int pullRequestCount = 0;

            Utilities.WriteToLogFile("    Checking for existing Pull Requests Details.");

            try
            {
                strSQL = "SELECT COUNT(ID) FROM ApsimFiles WHERE PullRequestId = @PullRequestId AND RunDate != @RunDate";
                using (DbCommand commandES = connection.CreateCommand())
                {
                    commandES.CommandText = strSQL;
                    commandES.CommandType = CommandType.Text;
                    commandES.AddParamWithValue("@PullRequestId", apsimfile.PullRequestId);
                    commandES.AddParamWithValue("@RunDate", apsimfile.RunDate);

                    pullRequestCount = Convert.ToInt32(commandES.ExecuteScalar());
                }
            }
            catch (Exception ex)
            {
                Utilities.WriteToLogFile("    ERROR:  Checking for existing Pull Requests: " + ex.Message.ToString());
                throw;
            }

            if (pullRequestCount > 0)
            {
                try
                {
                    Utilities.WriteToLogFile("    Removing existing Pull Requests Details.");
                    using (DbCommand commandENQ = connection.CreateCommand())
                    {
                        // Configure the command and parameter.
                        commandENQ.CommandText    = ReflectionUtilities.GetResourceAsString("APSIM.PerformanceTests.Service.DeleteByPRIDNotByDate.sql");
                        commandENQ.CommandTimeout = 0;
                        commandENQ.AddParamWithValue("@PullRequestID", apsimfile.PullRequestId);
                        commandENQ.AddParamWithValue("@RunDate", apsimfile.RunDate);

                        commandENQ.ExecuteNonQuery(); // 86 seconds
                    }
                    Utilities.WriteToLogFile("    Removed original Pull Request Data.");
                }
                catch (Exception ex)
                {
                    Utilities.WriteToLogFile("    ERROR:  Error Removing original Pull Request Data: " + ex.Message.ToString());
                    throw;
                }
            }

            //--------------------------------------------------------------------------------------
            //Add the ApsimFile Record first, so that we can get back the IDENTITY (ID) value
            //--------------------------------------------------------------------------------------
            //using (SqlConnection con = new SqlConnection(connectStr))
            //{
            Utilities.WriteToLogFile("    Inserting ApsimFiles details.");

            try
            {
                strSQL = "INSERT INTO ApsimFiles (PullRequestId, FileName, FullFileName, RunDate, StatsAccepted, IsMerged, SubmitDetails, AcceptedPullRequestId, AcceptedRunDate) "
                         + "VALUES (@PullRequestId, @FileName, @FullFileName, @RunDate, @StatsAccepted, @IsMerged, @SubmitDetails, @AcceptedPullRequestId, @AcceptedRunDate); "
                         + Utilities.Limit(connection, "SELECT ID FROM ApsimFiles ORDER BY ID DESC", 1);
                using (DbCommand commandES = connection.CreateCommand())
                {
                    commandES.CommandText = strSQL;
                    commandES.CommandType = CommandType.Text;
                    commandES.AddParamWithValue("@PullRequestId", apsimfile.PullRequestId);
                    commandES.AddParamWithValue("@FileName", apsimfile.FileName);
                    commandES.AddParamWithValue("@FullFileName", Utilities.GetModifiedFileName(apsimfile.FullFileName));
                    commandES.AddParamWithValue("@RunDate", apsimfile.RunDate);
                    commandES.AddParamWithValue("@StatsAccepted", apsimfile.StatsAccepted);
                    commandES.AddParamWithValue("@IsMerged", apsimfile.IsMerged);
                    commandES.AddParamWithValue("@SubmitDetails", apsimfile.SubmitDetails);

                    // The accepted stats data will be set below, after we've inserted all data.
                    // In the long run, this behaviour should probably be changed.
                    commandES.AddParamWithValue("@AcceptedPullRequestId", -1);
                    commandES.AddParamWithValue("@AcceptedRunDate", "");

                    //this should return the IDENTITY value for this record (which is required for the next update)
                    ErrMessageHelper = "Filename: " + apsimfile.FileName;

                    ApsimID          = Convert.ToInt32(commandES.ExecuteScalar()); // fast
                    apsimfile.ID     = ApsimID;
                    ErrMessageHelper = "Filename: " + apsimfile.FileName + "- ApsimID: " + ApsimID;
                    Utilities.WriteToLogFile(string.Format("    Filename {0} inserted into ApsimFiles successfully!", apsimfile.FileName));
                }
            }
            catch (Exception ex)
            {
                Utilities.WriteToLogFile("    ERROR:  Inserting into ApsimFiles failed: " + ex.Message.ToString());
                throw;
            }

            //--------------------------------------------------------------------------------------
            //Add the Simulation Details to the database
            //--------------------------------------------------------------------------------------
            if (apsimfile.Simulations.Rows.Count > 0)
            {
                try
                {
                    Utilities.WriteToLogFile("    Inserting Simulation details for " + apsimfile.FileName);
                    using (DbCommand commandENQ = connection.CreateCommand("INSERT INTO Simulations (ApsimFilesID, Name, OriginalSimulationID) SELECT @ApsimID, Name, ID FROM @Simulations;"))
                    {
                        commandENQ.AddParamWithValue("@ApsimID", apsimfile.ID);
                        DbParameter simulations = commandENQ.CreateParameter();
                        if (simulations is SqlParameter)
                        {
                            (simulations as SqlParameter).TypeName = "SimulationDataTableType";
                        }
                        simulations.ParameterName = "@Simulations";
                        simulations.Value         = apsimfile.Simulations;
                        commandENQ.Parameters.Add(simulations);

                        commandENQ.ExecuteNonQuery(); // ~2s with table-value parameter. ~10m with individual inserts
                        ErrMessageHelper = "- Simualtion Data for " + apsimfile.FileName;

                        Utilities.WriteToLogFile(string.Format("    Filename {0} Simulation Data imported successfully!", apsimfile.FileName));
                    }
                }
                catch (Exception ex)
                {
                    Utilities.WriteToLogFile("    ERROR:  usp_SimulationsInsert failed: " + ex.Message.ToString());
                    throw;
                }
            }


            //--------------------------------------------------------------------------------------
            //Add the Predicted Observed Details (metadata) and then the data
            //--------------------------------------------------------------------------------------

            // Look at each individual set of data
            int predictedObservedID = 0;

            foreach (PredictedObservedDetails poDetail in apsimfile.PredictedObserved)
            {
                Utilities.WriteToLogFile(string.Format("    Inserting Filename {0} PredictedObserved Table Details {1}.", apsimfile.FileName, poDetail.DatabaseTableName));
                try
                {
                    strSQL = "INSERT INTO PredictedObservedDetails ("
                             + "ApsimFilesID, TableName, PredictedTableName, ObservedTableName, FieldNameUsedForMatch, FieldName2UsedForMatch, FieldName3UsedForMatch, HasTests) "
                             + "VALUES (@ApsimFilesID, @TableName, @PredictedTableName, @ObservedTableName, @FieldNameUsedForMatch, @FieldName2UsedForMatch, @FieldName3UsedForMatch, 1); "
                             + "SELECT ID FROM PredictedObservedDetails ORDER BY ID DESC";
                    strSQL = Utilities.Limit(connection, strSQL, 1);
                    using (DbCommand commandES = connection.CreateCommand())
                    {
                        commandES.CommandText = strSQL;
                        commandES.CommandType = CommandType.Text;
                        commandES.AddParamWithValue("@ApsimFilesID", ApsimID);
                        commandES.AddParamWithValue("@TableName", poDetail.DatabaseTableName);
                        commandES.AddParamWithValue("@PredictedTableName", poDetail.PredictedTableName);
                        commandES.AddParamWithValue("@ObservedTableName", poDetail.ObservedTableName);

                        commandES.AddParamWithValue("@FieldNameUsedForMatch", poDetail.FieldNameUsedForMatch);
                        commandES.AddParamWithValue("@FieldName2UsedForMatch", poDetail.FieldName2UsedForMatch);
                        commandES.AddParamWithValue("@FieldName3UsedForMatch", poDetail.FieldName3UsedForMatch);

                        //this should return the IDENTITY value for this record (which is required for the next update)
                        ErrMessageHelper = "PredictedObservedDetails for " + poDetail.DatabaseTableName;

                        predictedObservedID = Convert.ToInt32(commandES.ExecuteScalar());
                        ErrMessageHelper    = "PredictedObservedDetails for " + poDetail.DatabaseTableName + "(ID: " + predictedObservedID + ")";
                        Utilities.WriteToLogFile(string.Format("    Filename {0} PredictedObserved Table Details {1}, (Id: {2}) imported successfully!", apsimfile.FileName, poDetail.DatabaseTableName, predictedObservedID));
                    }
                }
                catch (Exception ex)
                {
                    Utilities.WriteToLogFile("    ERROR:  INSERT INTO PredictedObservedDetails failed: " + ex.Message.ToString());
                    throw;
                }


                //--------------------------------------------------------------------------------------
                //And finally this is where we will insert the actual Predicted Observed DATA
                //--------------------------------------------------------------------------------------
                Utilities.WriteToLogFile(string.Format("    PredictedObserved Data Values for {0}.{1} - import started!", apsimfile.FileName, poDetail.DatabaseTableName));

                for (int i = 0; i < poDetail.Data.Columns.Count; i++)
                {
                    string observedColumnName = poDetail.Data.Columns[i].ColumnName.Trim();
                    if (observedColumnName.StartsWith("Observed"))
                    {
                        //get the corresponding Predicted Column Name
                        int    dotPosn             = observedColumnName.IndexOf('.');
                        string valueName           = observedColumnName.Substring(dotPosn + 1);
                        string predictedColumnName = "Predicted." + valueName;

                        if (!poDetail.Data.Columns.Contains(predictedColumnName))
                        {
                            continue;
                        }

                        //need to find the first (and then each instance thereafter) of a field name being with Observed,
                        //the get the corresponding Predicted field name, and then create a new table definition based on this
                        //data,
                        using (DbCommand command = connection.CreateCommand())
                        {
                            command.CommandText = @"INSERT INTO [dbo].[PredictedObservedValues] ([PredictedObservedDetailsID], [SimulationsID], [MatchName], [MatchValue], [MatchName2], [MatchValue2], [MatchName3], [MatchValue3], [ValueName], [PredictedValue], [ObservedValue])
	                                        SELECT @PredictedObservedID, s.[ID], @MatchName, p.[MatchValue], @MatchName2, p.[MatchValue2], @MatchName3, p.[MatchValue3], @ValueName, p.[PredictedValue], p.[ObservedValue]
	                                        FROM @PredictedOabservedData p INNER JOIN [dbo].[Simulations] s 
	                                        ON s.[OriginalSimulationID] = p.[SimulationID]
	                                        WHERE s.[ApsimFilesID] = @ApsimFilesID
	                                        AND p.[PredictedValue] IS NOT NULL
	                                        AND p.[ObservedValue] IS NOT NULL;"    ;

                            command.AddParamWithValue("@PredictedObservedID", predictedObservedID);
                            command.AddParamWithValue("@MatchName", poDetail.FieldNameUsedForMatch);
                            command.AddParamWithValue("@MatchName2", (object)poDetail.FieldName2UsedForMatch ?? DBNull.Value);
                            command.AddParamWithValue("@MatchName3", (object)poDetail.FieldName3UsedForMatch ?? DBNull.Value);
                            command.AddParamWithValue("@ValueName", valueName);
                            command.AddParamWithValue("@ApsimFilesID", apsimfile.ID);

                            DataTable poData = new DataTable();
                            poData.Columns.Add("SimulationID", typeof(int));
                            poData.Columns.Add("MatchValue", typeof(string));
                            poData.Columns.Add("MatchValue2", typeof(string));
                            poData.Columns.Add("MatchValue3", typeof(string));
                            poData.Columns.Add("PredictedValue", poDetail.Data.Columns[predictedColumnName].DataType);
                            poData.Columns.Add("ObservedValue", poDetail.Data.Columns[observedColumnName].DataType);

                            poData = poDetail.Data.AsEnumerable().Select(r =>
                            {
                                var row = poData.NewRow();
                                foreach (DataColumn column in poData.Columns)
                                {
                                    if (column.ColumnName == "MatchValue")
                                    {
                                        row[column.ColumnName] = r[poDetail.FieldNameUsedForMatch];
                                    }
                                    else if (column.ColumnName == "MatchValue2")
                                    {
                                        if (!string.IsNullOrEmpty(poDetail.FieldName2UsedForMatch))
                                        {
                                            row[column.ColumnName] = r[poDetail.FieldName2UsedForMatch];
                                        }
                                    }
                                    else if (column.ColumnName == "MatchValue3")
                                    {
                                        if (!string.IsNullOrEmpty(poDetail.FieldName3UsedForMatch))
                                        {
                                            row[column.ColumnName] = r[poDetail.FieldName3UsedForMatch];
                                        }
                                    }
                                    else if (column.ColumnName == "PredictedValue")
                                    {
                                        row[column.ColumnName] = r[predictedColumnName];
                                    }
                                    else if (column.ColumnName == "ObservedValue")
                                    {
                                        row[column.ColumnName] = r[observedColumnName];
                                    }
                                    else
                                    {
                                        row[column.ColumnName] = r[column.ColumnName];
                                    }
                                }
                                return(row);
                            }).CopyToDataTable();

                            object[] simulationIDs = poData.AsEnumerable().Select(r => r["SimulationID"]).ToArray();

                            DbParameter tableParam = command.CreateParameter();
                            tableParam.ParameterName = "@PredictedOabservedData";
                            tableParam.Value         = poData;
                            if (tableParam is SqlParameter)
                            {
                                (tableParam as SqlParameter).TypeName = "PredictedObservedDataThreeTableType";
                            }
                            command.Parameters.Add(tableParam);

                            Type dataType    = poData.Columns["PredictedValue"].DataType;
                            bool validColumn = dataType != typeof(string) && dataType != typeof(bool) && dataType != typeof(DateTime); // so a char is a testable piece of data but string is not?

                            if (validColumn)
                            {
                                command.ExecuteNonQuery();
                            }
                        }
                    }
                }
                //Need to run the testing procecedure here, and then save the test data
                if (poDetail.Data.Rows.Count > 0)
                {
                    ErrMessageHelper = string.Empty;

                    Utilities.WriteToLogFile(string.Format("    Tests Data for {0}.{1} import started.", apsimfile.FileName, poDetail.DatabaseTableName));

                    //need to retrieve data for the "AcceptedStats" version, so that we can update the stats
                    int acceptedPredictedObservedDetailsID = 0;    //this should get updated in 'RetrieveAcceptedStatsData'
                    ErrMessageHelper = "Processing RetrieveAcceptedStatsData.";
                    DataTable acceptedStats = RetrieveAcceptedStatsData(connection, ApsimID, apsimfile, poDetail, predictedObservedID, ref acceptedPredictedObservedDetailsID);

                    ErrMessageHelper = "Processing Tests.DoValidationTest.";
                    DataTable dtTests = Tests.DoValidationTest(poDetail.DatabaseTableName, poDetail.Data, acceptedStats);

                    ErrMessageHelper = "Processing DBFunctions.AddPredictedObservedTestsData.";
                    DBFunctions.AddPredictedObservedTestsData(connection, apsimfile.FileName, predictedObservedID, poDetail.DatabaseTableName, dtTests);

                    //Update the accepted reference for Predicted Observed Values, so that it can be
                    ErrMessageHelper = "Processing DBFunctions.UpdatePredictedObservedDetails.";
                    DBFunctions.UpdatePredictedObservedDetails(connection, acceptedPredictedObservedDetailsID, predictedObservedID);
                }
            }
        }
Beispiel #8
0
    public void Update()
    {
        Tests.Screenshot(600, 400, "GuideUserInterface.jpg", new Vec3(-0.363f, 0.010f, 0.135f), new Vec3(-0.743f, -0.414f, -0.687f));
        Tests.Screenshot(400, 600, "GuideUserInterfaceCustom.jpg", new Vec3(0.225f, 0.0f, .175f), new Vec3(.4f, 0.0f, 0));

        /// :CodeDoc: Guides User Interface
        /// Then we'll move over to the application step where we'll do the rest of the UI code!
        ///
        /// We'll start with a window titled "Window" that's 20cm wide, and auto-resizes on the
        /// y-axis. The Units class is pretty helpful here, as it allows us to reason more visually
        /// about the units we're using! StereoKit uses meters as its base unit, which look a little
        /// awkward, especially in the millimeter range.
        ///
        /// We'll also use a toggle to turn the window's header on and off! The value from that toggle
        /// is passed in here via the showHeader field.
        ///
        UI.WindowBegin("Window", ref windowPose, new Vec2(20, 0) * U.cm, showHeader?UIWin.Normal:UIWin.Body);
        ///
        /// When you begin a window, all visual elements are now relative to that window! UI takes advantage
        /// of the Hierarchy class and pushes the window's pose onto the Hierarchy stack. Ending the window
        /// will pop the pose off the hierarchy stack, and return things to normal!
        ///
        /// Here's that toggle button! You'll also notice our use of 'ref' values in a lot of the UI
        /// code. UI functions typically follow the pattern of returning true/false to indicate they've
        /// been interacted with during the frame, so you can nicely wrap them in 'if' statements to
        /// react to change!
        ///
        /// Then with the 'ref' parameter, we let you pass in the current state of the UI element. The UI
        /// element will update that value for you based on user interaction, but you can also change it
        /// yourself whenever you want to!
        ///
        UI.Toggle("Show Header", ref showHeader);
        ///
        /// Here's an example slider! We start off with a label element, and tell the UI to
        /// keep the next item on the same line. The slider clamps to the range [0,1], and
        /// will step at intervals of 0.2. If you want it to slide continuously, you can just set
        /// the `step` value to 0!
        ///
        UI.Label("Slide");
        UI.SameLine();
        UI.HSlider("slider", ref slider, 0, 1, 0.2f, 72 * U.mm);
        ///
        /// Here's how you use a simple button! Just check it with an 'if'. Any UI method
        /// will return true on the frame when their value or state has changed.
        ///
        if (UI.ButtonRound("Exit", powerSprite))
        {
            StereoKitApp.Quit();
        }
        ///
        /// And for every begin, there must also be an end! StereoKit will log errors when this
        /// occurs, so keep your eyes peeled for that!
        ///
        UI.WindowEnd();
        ///
        /// ## Custom Windows
        ///
        /// ![Simple UI]({{site.url}}/img/screenshots/GuideUserInterfaceCustom.jpg)
        ///
        /// Mixed Reality also provides us with the opportunity to turn objects into interfaces!
        /// Instead of using the old 'window' paradigm, we can create 3D models and apply UI
        /// elements to their surface! StereoKit uses 'handles' to accomplish this, a grabbable
        /// area that behaves much like a window, but with a few more options for customizing
        /// layout and size.
        ///
        /// We'll load up a clipboard, so we can attach an interface to that!
        ///
        /// ```csharp
        /// Model clipboard = Model.FromFile("Clipboard.glb");
        /// ```
        ///
        /// And, similar to the window previously, here's how you would turn it into a grabbable
        /// interface! This behaves the same, except we're defining where the grabbable region is
        /// specifically, and then drawing our own model instead of a plain bar. You'll also notice
        /// we're drawing using an identity matrix. This takes advantage of how HandleBegin
        /// pushes the handle's pose onto the Hierarchy transform stack!
        ///
        UI.HandleBegin("Clip", ref clipboardPose, clipboard.Bounds);
        Renderer.Add(clipboard, Matrix.Identity);
        ///
        /// Once we've done that, we also need to define the layout area of the model, where UI
        /// elements will go. This is different for each model, so you'll need to plan this around
        /// the size of your object!
        ///
        UI.LayoutArea(new Vec3(12, 15, 0) * U.cm, new Vec2(24, 30) * U.cm);
        ///
        /// Then after that? We can just add UI elements like normal!
        ///
        UI.Image(logoSprite, new Vec2(22, 0) * U.cm);

        UI.Toggle("Toggle", ref clipToggle);
        UI.HSlider("Slide", ref clipSlider, 0, 1, 0, 22 * U.cm);
        ///
        /// And while we're at it, here's a quick example of doing a radio button group! Not much
        /// 'radio' actually happening, but it's still pretty simple. Pair it with an enum, or an
        /// integer, and have fun!
        ///
        if (UI.Radio("Radio1", clipOption == 1))
        {
            clipOption = 1;
        }
        UI.SameLine();
        if (UI.Radio("Radio2", clipOption == 2))
        {
            clipOption = 2;
        }
        UI.SameLine();
        if (UI.Radio("Radio3", clipOption == 3))
        {
            clipOption = 3;
        }
        ///
        /// As with windows, Handles need an End call.
        ///
        UI.HandleEnd();
        ///
        /// And there you go! That's how UI works in StereoKit, pretty simple, huh?
        /// For further reference, and more UI methods, check out the
        /// [UI class documentation]({{site.url}}/Pages/Reference/UI.html).
        ///
        /// If you'd like to see the complete code for this sample,
        /// [check it out on Github](https://github.com/maluoi/StereoKit/blob/master/Examples/StereoKitTest/DemoUI.cs)!
        /// :End:
    }
Beispiel #9
0
        private async Task <UniversityDbContext> PrepareCourseStudentsWithCertificates()
        {
            var student1 = new User {
                Id = Student1, Name = "Student 1", UserName = "******", Email = "*****@*****.**"
            };
            var student2 = new User {
                Id = Student2, Name = "Student 2", UserName = "******", Email = "*****@*****.**"
            };
            var student3 = new User {
                Id = Student3, Name = "Student 3", UserName = "******", Email = "*****@*****.**"
            };

            var course1 = new Course {
                Id = CourseValid
            };
            var course2 = new Course {
                Id = 2
            };

            var examSubmissionDate1 = new DateTime(2019, 8, 1);
            var examSubmissionDate2 = new DateTime(2019, 10, 22);

            course1.Students.Add(new StudentCourse {
                StudentId = student1.Id, CourseId = course1.Id, GradeBg = DataConstants.GradeBgMaxValue
            });
            course1.Students.Add(new StudentCourse {
                StudentId = student2.Id, CourseId = course1.Id, GradeBg = DataConstants.GradeBgCertificateMinValue
            });
            course1.Students.Add(new StudentCourse {
                StudentId = student3.Id, CourseId = course1.Id
            });

            course2.Students.Add(new StudentCourse {
                StudentId = student3.Id, CourseId = course2.Id, GradeBg = DataConstants.GradeBgMaxValue
            });

            student1.ExamSubmissions.Add(new ExamSubmission {
                Id = 1, CourseId = course1.Id, SubmissionDate = examSubmissionDate1
            });
            student1.ExamSubmissions.Add(new ExamSubmission {
                Id = 2, CourseId = course1.Id, SubmissionDate = examSubmissionDate2
            });
            student2.ExamSubmissions.Add(new ExamSubmission {
                Id = 3, CourseId = course1.Id, SubmissionDate = examSubmissionDate2
            });

            student1.Certificates.Add(new Certificate
            {
                Id        = Certificate1,
                CourseId  = course1.Id,
                StudentId = student1.Id,
                GradeBg   = DataConstants.GradeBgMinValue,
                IssueDate = examSubmissionDate1
            });
            student1.Certificates.Add(new Certificate
            {
                Id        = Certificate2,
                CourseId  = course1.Id,
                StudentId = student1.Id,
                GradeBg   = DataConstants.GradeBgMaxValue,
                IssueDate = examSubmissionDate2
            });
            student2.Certificates.Add(new Certificate
            {
                Id        = Certificate3,
                CourseId  = course1.Id,
                StudentId = student1.Id,
                GradeBg   = DataConstants.GradeBgCertificateMinValue,
                IssueDate = examSubmissionDate2
            });

            var db = Tests.InitializeDatabase();
            await db.Courses.AddRangeAsync(course1, course2);

            await db.Users.AddRangeAsync(student1, student2, student3);

            await db.SaveChangesAsync();

            return(db);
        }
Beispiel #10
0
 public AgencyCarServiceTest()
 {
     Tests.Initialize();
     db = Tests.GetDatabase();
 }
	public static int test_1_bit_index () {
		Tests t = new Tests ();
		t.setBit (0, true);
		t.setBit (3, true);
		if (t.getBit (1))
			return 4;
		if (!t.getBit (0))
			return 5;
		if (!t.getBit (3))
			return 6;
		return 1;
	}
Beispiel #12
0
	public static int test_2_instance_delegate () {
		Tests t = new Tests ();
		GetIntDel del = new GetIntDel (t.return5);
		int v = del ();
		if (v != 5)
			return 0;
		return 2;
	}
 /// Constructor
 /// </summary>
 /// <param name="step">The activated step</param>
 public SubStepActivated(Tests.SubStep subStep)
     : base(subStep.Name, subStep)
 {
     SubStep = subStep;
 }
Beispiel #14
0
 public AccessoryServiceTest()
 {
     Tests.Initialize();
     this.db = Tests.GetDatabase();
 }
Beispiel #15
0
        private void computarProbabilidadesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            tabControl1.SelectTab(0);
            try
            {
                if (CheckConsistency())
                {
                    //obtener la evidencia
                    if (flowChartViewer1.Charts.Count > 0 && Evidence.Count > 0)
                    {
                        GetEvidence();
                    }
                    //transformar el grafo del visor a un grafo de nodos bayesianos

                    var graph = new BayesianGraph();
                    //
                    var          dict = new Dictionary <BayesianNode, BayesianNodeChartElement>(flowChartViewer1.Charts.Count);
                    BayesianNode node;
                    var          dict2 = new Dictionary <BayesianNodeChartElement, BayesianNode>(flowChartViewer1.Charts.Count);

                    graph.Clear();

                    foreach (var item in flowChartViewer1.Charts.Cast <BayesianNodeChartElement>())
                    {
                        node = new BayesianNode(item.Parents.Count, item.Childs.Count(), item.States.Count,
                                                item.Parents.Select(x => x.States.Count).ToArray())
                        {
                            Probabilities = item.Condicional_Probabilities, Name = item.Name
                        };

                        dict.Add(node, item);
                        dict2.Add(item, node);
                        item.CreateConditionalProbabilities();


                        graph.AddVertex(node);
                    }
                    foreach (var bnodechart in flowChartViewer1.Charts.Cast <BayesianNodeChartElement>())
                    {
                        foreach (var child in bnodechart.Childs)
                        {
                            graph.AddEdge(dict2[bnodechart], dict2[child]);
                        }
                    }
                    //ejecutar el traspaso de mensajes en un poliarbol o en una red multiplemente conexa
                    progressBar1.Value = 5;
                    //if(MessageTransfer.ParalellStartNumber>graph.Count)
                    MessageTransfer.Increment += UpdateProgress;


                    if (graph.Arbol())
                    {
                        if (Evidence.Count > 0)
                        {
                            MessageTransfer.Message_Tranfer_Poliarbol(graph, Evidence[EvidenceIndex]);
                        }
                        else
                        {
                            MessageTransfer.Message_Tranfer_Poliarbol(graph);
                        }
                        foreach (var nodebayesian in graph)
                        {
                            dict[nodebayesian].SetConditionalProbabilities(nodebayesian.ConditionalProbability);
                        }
                    }
                    else
                    {
                        var markovnet = new MarkovNet(graph);
                        if (Evidence.Count > 0)
                        {
                            MessageTransfer.Message_Tranfer_Arbol_Union(markovnet, Evidence[EvidenceIndex]);
                        }
                        else
                        {
                            MessageTransfer.Message_Tranfer_Arbol_Union(markovnet);
                        }
                        foreach (var nodebayesian in markovnet.BayesianNet)
                        {
                            dict[nodebayesian].SetConditionalProbabilities(nodebayesian.ConditionalProbability);
                        }
                    }

                    timer1.Stop();
                    progressBar1.Value = 100;

                    Tests.Add(new BayesianTest()
                    {
                        Evidence      = Evidence[EvidenceIndex].Clone(),
                        Probabilities =
                            graph.Select(x => x.ConditionalProbability.Clone() as double[]).ToArray()
                    });
                    TestsIndex = Tests.Count - 1;
                    ShowConditionalProbabilities();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Hubo algun problema al calcular las probabilidades condicionales. " + ex.Message);
            }
        }
Beispiel #16
0
 public TestContainer(Tests.TestOrchestrator orchestrator, Sensors.SensorContainer sensorContainer)
 {
     this.Orchestrator = orchestrator;
     this.SensorContainer = sensorContainer;
 }
	public static int test_0_stelem_ref_null_opt () {
		object[] arr = new Tests [1];

		arr [0] = new Tests ();
		arr [0] = null;

		return arr [0] == null ? 0 : 1;
	}
Beispiel #18
0
 /// <summary>
 /// Adds Tests into the Database
 /// </summary>
 /// <param name="tests"></param>
 /// <returns>Flag as true if added successfully else false</returns>
 public bool AddTests(Tests tests)
 {
     return((new AmenitiesData()).AddTests(tests));
 }
Beispiel #19
0
        public InvoiceViewModel(int AppointmentId)
        {
            InvoiceDetails invoiceDetails = new InvoiceDetails();

            Diagnosis = invoiceDetails.GetDiagnosis(AppointmentId);
            Invoice   = invoiceDetails.GetInvoiceDetails(AppointmentId);
            if (Invoice == null)
            {
                invoiceDetails.GenerateInvoice(AppointmentId);
                Invoice = invoiceDetails.GetInvoiceDetails(AppointmentId);
            }
            Medicines = invoiceDetails.GetMedicineListForInvoice(Diagnosis.Id);
            Tests     = invoiceDetails.GetTestListForInvoice(Diagnosis.Id);

            this.DoctorFee = Invoice.TotalCost - (Medicines.Sum(t => t.Medicines.Cost * t.Quantity) + Tests.Sum(t => t.Tests.Cost));

            Age = invoiceDetails.GetAge(Invoice.Appointment.Patient.DateOfBirth);
        }
Beispiel #20
0
        public void Run(TestConfig config)
        {
            int    i;
            Record r     = null;
            int    count = config.Count;
            var    res   = new TestIndexNumericResult();

            config.Result = res;
            var start = DateTime.Now;

            IDatabase db = config.GetDatabase();

            Tests.Assert(null == db.Root);
            var idx = db.CreateIndex <byte, Record>(IndexType.NonUnique);

            db.Root = idx;
            long val = 1999;

            for (i = 0; i < count; i++)
            {
                byte idxVal = Clamp(val);
                r = new Record(idxVal);
                idx.Put(idxVal, r);
                if (i % 100 == 0)
                {
                    db.Commit();
                }
                val = (3141592621L * val + 2718281829L) % 1000000007L;
            }
            idx.Put(min, new Record(min));
            idx.Put(max, new Record(max));

            Tests.Assert(idx.Count == count + 2);
            db.Commit();
            res.InsertTime = DateTime.Now - start;
            Tests.Assert(idx.Count == count + 2);

            start = System.DateTime.Now;
            Record[] recs = idx[min, mid];
            foreach (var r2 in recs)
            {
                Tests.Assert(r2.lval >= min && r2.lval <= mid);
            }
            recs = idx[mid, max];
            foreach (var r2 in recs)
            {
                Tests.Assert(r2.lval >= mid && r2.lval <= max);
            }
            byte prev = min;
            var  e1   = idx.GetEnumerator();

            while (e1.MoveNext())
            {
                r = e1.Current;
                Tests.Assert(r.nval >= prev);
                prev = r.nval;
            }
            Tests.VerifyEnumeratorDone(e1);

            prev = min;
            foreach (var r2 in idx)
            {
                Tests.Assert(r2.nval >= prev);
                prev = r2.nval;
            }

            prev = min;
            foreach (var r2 in idx.Range(min, max, IterationOrder.AscentOrder))
            {
                Tests.Assert(r2.nval >= prev);
                prev = r2.nval;
            }

            prev = max;
            foreach (var r2 in idx.Range(min, max, IterationOrder.DescentOrder))
            {
                Tests.Assert(prev >= r2.nval);
                prev = r2.nval;
            }

            prev = max;
            foreach (var r2 in idx.Reverse())
            {
                Tests.Assert(prev >= r2.nval);
                prev = r2.nval;
            }
            long usedBeforeDelete = db.UsedSize;

            recs = idx[min, max];
            foreach (var r2 in recs)
            {
                Tests.Assert(!r2.IsDeleted());
                idx.Remove(r2.nval, r2);
                r2.Deallocate();
            }
            Tests.Assert(idx.Count == 0);
            db.Commit();
            long usedAfterDelete = db.UsedSize;

            db.Gc();
            db.Commit();
            long usedAfterGc = db.UsedSize;

            db.Close();
        }
Beispiel #21
0
    public static int test_34_marshal_instance_delegate()
    {
        Tests t = new Tests ();
        t.int_field = 32;
        SimpleDelegate d = new SimpleDelegate (t.delegate_test_instance);

        return mono_test_marshal_delegate (d);
    }
 private void Tests()
 {
     Tests t = new Tests();
     t.PerformTests(TaxIndicators.ToList());
 }
        public void Run(TestConfig config)
        {
            Stock stock;
            int   i;
            int   count = config.Count;
            var   res   = new TestTimeSeriesResult();

            config.Result = res;

            var       start = DateTime.Now;
            IDatabase db    = config.GetDatabase();

            IFieldIndex <string, Stock> stocks = (IFieldIndex <string, Stock>)db.Root;

            Tests.Assert(stocks == null);
            stocks       = db.CreateFieldIndex <string, Stock>("name", IndexType.Unique);
            stock        = new Stock();
            stock.name   = "BORL";
            stock.quotes = db.CreateTimeSeries <Quote>(N_ELEMS_PER_BLOCK, N_ELEMS_PER_BLOCK * TICKS_PER_SECOND * 2);
            stocks.Put(stock);
            db.Root = stocks;

            Tests.Assert(!stock.quotes.IsReadOnly);
            rand = new Random(2004);
            int startTimeInSecs = getSeconds(start);
            int currTime        = startTimeInSecs;

            for (i = 0; i < count; i++)
            {
                Quote quote = NewQuote(currTime++);
                stock.quotes.Add(quote);
            }
            Tests.Assert(stock.quotes.Count == count);
            db.Commit();
            Tests.Assert(stock.quotes.Count == count);
            res.InsertTime = DateTime.Now - start;

            start = DateTime.Now;
            rand  = new Random(2004);
            start = DateTime.Now;
            i     = 0;
            foreach (Quote quote in stock.quotes)
            {
                Tests.Assert(quote.timestamp == startTimeInSecs + i);
                float open = (float)rand.Next(10000) / 100;
                Tests.Assert(quote.open == open);
                float close = (float)rand.Next(10000) / 100;
                Tests.Assert(quote.close == close);
                Tests.Assert(quote.high == Math.Max(quote.open, quote.close));
                Tests.Assert(quote.low == Math.Min(quote.open, quote.close));
                Tests.Assert(quote.volume == rand.Next(1000));
                i += 1;
            }
            Tests.Assert(i == count);

            res.SearchTime1 = DateTime.Now - start;

            start = DateTime.Now;
            long from = getTicks(startTimeInSecs + count / 2);
            long till = getTicks(startTimeInSecs + count);

            i = 0;
            foreach (Quote quote in stock.quotes.Range(new DateTime(from), new DateTime(till), IterationOrder.DescentOrder))
            {
                int expectedtimestamp = startTimeInSecs + count - i - 1;
                Tests.Assert(quote.timestamp == expectedtimestamp);
                i += 1;
            }
            res.SearchTime2 = DateTime.Now - start;
            start           = DateTime.Now;

            // insert in the middle
            stock.quotes.Add(NewQuote(startTimeInSecs - count / 2));

            long n = stock.quotes.Remove(stock.quotes.FirstTime, stock.quotes.LastTime);

            Tests.Assert(n == count + 1);
            Tests.Assert(stock.quotes.Count == 0);
            res.RemoveTime = DateTime.Now - start;

            Quote q;
            Quote qFirst  = NewQuote(0);
            Quote qMiddle = NewQuote(0);
            Quote qEnd    = NewQuote(0);

            for (i = 0; i < 10; i++)
            {
                q = NewQuote(startTimeInSecs + i);
                stock.quotes.Add(q);
                if (i == 0)
                {
                    qFirst = q;
                }
                else if (i == 5)
                {
                    qMiddle = q;
                }
                else if (i == 9)
                {
                    qEnd = q;
                }
            }
            Tests.Assert(stock.quotes.Contains(qFirst));
            Tests.Assert(stock.quotes.Contains(qEnd));
            Tests.Assert(stock.quotes.Contains(qMiddle));
            Tests.Assert(stock.quotes.Remove(qFirst));
            Tests.Assert(!stock.quotes.Contains(qFirst));
            Tests.Assert(stock.quotes.Remove(qEnd));
            Tests.Assert(!stock.quotes.Contains(qEnd));
            Tests.Assert(stock.quotes.Remove(qMiddle));
            Tests.Assert(!stock.quotes.Contains(qMiddle));

            Quote[] quotes = new Quote[10];
            stock.quotes.CopyTo(quotes, 0);
            stock.quotes.Clear();

            Tests.AssertDatabaseException(
                () => { long tmp = stock.quotes.FirstTime.Ticks; }, DatabaseException.ErrorCode.KEY_NOT_FOUND);
            Tests.AssertDatabaseException(
                () => { long tmp = stock.quotes.LastTime.Ticks; }, DatabaseException.ErrorCode.KEY_NOT_FOUND);

            for (i = 0; i < 10; i++)
            {
                q = NewQuote(startTimeInSecs + i);
                stock.quotes.Add(q);
            }

            IEnumerator e = stock.quotes.GetEnumerator();

            i = 0;
            while (e.MoveNext())
            {
                i++;
            }
            Tests.Assert(i == 10);
            Tests.Assert(!e.MoveNext());
            Tests.AssertException <InvalidOperationException>(
                () => { object o = e.Current; });
            e.Reset();
            Tests.Assert(e.MoveNext());

            e = stock.quotes.Reverse().GetEnumerator();
            i = 0;
            while (e.MoveNext())
            {
                i++;
            }
            Tests.Assert(i == 10);
            Tests.Assert(!e.MoveNext());
            Tests.AssertException <InvalidOperationException>(
                () => { object o = e.Current; });
            e.Reset();
            Tests.Assert(e.MoveNext());
            DateTime tStart  = new DateTime(getTicks(startTimeInSecs));
            DateTime tMiddle = new DateTime(getTicks(startTimeInSecs + 5));
            DateTime tEnd    = new DateTime(getTicks(startTimeInSecs + 9));

            IEnumerator <Quote> e2 = stock.quotes.GetEnumerator(tStart, tMiddle);

            VerifyEnumerator(e2, tStart.Ticks, tMiddle.Ticks);
            e2 = stock.quotes.GetEnumerator(tStart, tMiddle, IterationOrder.DescentOrder);
            VerifyEnumerator(e2, tStart.Ticks, tMiddle.Ticks, IterationOrder.DescentOrder);

            e2 = stock.quotes.GetEnumerator(IterationOrder.DescentOrder);
            VerifyEnumerator(e2, tStart.Ticks, tEnd.Ticks, IterationOrder.DescentOrder);

            e2 = stock.quotes.Range(tMiddle, tEnd, IterationOrder.AscentOrder).GetEnumerator();
            VerifyEnumerator(e2, tMiddle.Ticks, tEnd.Ticks, IterationOrder.AscentOrder);

            e2 = stock.quotes.Range(IterationOrder.DescentOrder).GetEnumerator();
            VerifyEnumerator(e2, tStart.Ticks, tEnd.Ticks, IterationOrder.DescentOrder);

            e2 = stock.quotes.Till(tMiddle).GetEnumerator();
            VerifyEnumerator(e2, tStart.Ticks, tMiddle.Ticks, IterationOrder.DescentOrder);

            e2 = stock.quotes.From(tMiddle).GetEnumerator();
            VerifyEnumerator(e2, tMiddle.Ticks, tEnd.Ticks);

            e2 = stock.quotes.Reverse().GetEnumerator();
            VerifyEnumerator(e2, tStart.Ticks, tEnd.Ticks, IterationOrder.DescentOrder);

            Tests.Assert(stock.quotes.FirstTime.Ticks == tStart.Ticks);
            Tests.Assert(stock.quotes.LastTime.Ticks == tEnd.Ticks);
            for (i = 0; i < 10; i++)
            {
                long  ticks = getTicks(startTimeInSecs + i);
                Quote qTmp  = stock.quotes[new DateTime(ticks)];
                Tests.Assert(qTmp.Ticks == ticks);
                Tests.Assert(stock.quotes.Contains(new DateTime(ticks)));
            }
            Tests.Assert(!stock.quotes.Contains(new DateTime(0)));

            Tests.AssertDatabaseException(
                () => { Quote tmp = stock.quotes[new DateTime(0)]; }, DatabaseException.ErrorCode.KEY_NOT_FOUND);

            stock.quotes.RemoveFrom(new DateTime(getTicks(startTimeInSecs + 8)));
            stock.quotes.RemoveFrom(new DateTime(getTicks(startTimeInSecs + 2)));
            stock.quotes.RemoveAll();
            db.Commit();
            stock.quotes.Deallocate();
            db.Commit();
            db.Close();
        }
        /// <summary>
        /// Evaluates the rule and its sub rules
        /// </summary>
        /// <param name="runner"></param>
        /// <param name="priority">the priority level : a rule can be activated only if its priority level == priority</param>
        /// <param name="instance">The instance on which the rule must be evaluated</param>
        /// <param name="ruleConditions">the rule conditions to be activated</param>
        /// <returns>the number of actions that were activated during this evaluation</returns>
        public bool Evaluate(Tests.Runner.Runner runner, Generated.acceptor.RulePriority priority, Utils.IModelElement instance, List<RuleCondition> ruleConditions)
        {
            bool retVal = false;

            long start = System.Environment.TickCount;

            if (Disabled == false && ActivationPriorities.Contains(priority))
            {
                foreach (RuleCondition ruleCondition in RuleConditions)
                {
                    retVal = ruleCondition.Evaluate(runner, priority, instance, ruleConditions);
                    if (retVal)
                    {
                        break;
                    }
                }
            }

            // Guard evaluation execution time
            long stop = System.Environment.TickCount;
            long span = (stop - start);
            ExecutionTimeInMilli += span;

            return retVal;
        }
Beispiel #25
0
        public async Task RunAsync(int iterations)
        {
            using (var connection = GetOpenConnection())
            {
#pragma warning disable IDE0017 // Simplify object initialization
#pragma warning disable RCS1121 // Use [] instead of calling 'First'.
                var tests = new Tests();

                // Linq2SQL
                Try(() =>
                {
                    var l2scontext1 = GetL2SContext(connection);
                    tests.Add(id => l2scontext1.Posts.First(p => p.Id == id), "Linq2Sql: Normal");

                    var l2scontext2     = GetL2SContext(connection);
                    var compiledGetPost = CompiledQuery.Compile((Linq2Sql.DataClassesDataContext ctx, int id) => ctx.Posts.First(p => p.Id == id));
                    tests.Add(id => compiledGetPost(l2scontext2, id), "Linq2Sql: Compiled");

                    var l2scontext3 = GetL2SContext(connection);
                    tests.Add(id => l2scontext3.ExecuteQuery <Post>("select * from Posts where Id = {0}", id).First(), "Linq2Sql: ExecuteQuery");
                }, "LINQ-to-SQL");

                // Entity Framework
                Try(() =>
                {
                    var entityContext = new EFContext(connection);
                    tests.Add(id => entityContext.Posts.First(p => p.Id == id), "Entity Framework");

                    var entityContext2 = new EFContext(connection);
                    tests.Add(id => entityContext2.Database.SqlQuery <Post>("select * from Posts where Id = {0}", id).First(), "Entity Framework: SqlQuery");

                    var entityContext3 = new EFContext(connection);
                    tests.Add(id => entityContext3.Posts.AsNoTracking().First(p => p.Id == id), "Entity Framework: No Tracking");
                }, "Entity Framework");

                // Entity Framework Core
                Try(() =>
                {
                    var entityContext = new EFCoreContext(ConnectionString);
                    tests.Add(id => entityContext.Posts.First(p => p.Id == id), "Entity Framework Core");

                    var entityContext2 = new EFCoreContext(ConnectionString);
                    tests.Add(id => entityContext2.Posts.FromSql("select * from Posts where Id = {0}", id).First(), "Entity Framework Core: FromSql");

                    var entityContext3 = new EFContext(connection);
                    tests.Add(id => entityContext3.Posts.AsNoTracking().First(p => p.Id == id), "Entity Framework Core: No Tracking");
                }, "Entity Framework Core");

                // Dapper
                Try(() =>
                {
                    var mapperConnection = GetOpenConnection();
                    tests.Add(id => mapperConnection.Query <Post>("select * from Posts where Id = @Id", new { Id = id }, buffered: true).First(), "Dapper: Query (buffered)");
                    tests.Add(id => mapperConnection.Query <Post>("select * from Posts where Id = @Id", new { Id = id }, buffered: false).First(), "Dapper: Query (non-buffered)");
                    tests.Add(id => mapperConnection.QueryFirstOrDefault <Post>("select * from Posts where Id = @Id", new { Id = id }), "Dapper: QueryFirstOrDefault");

                    var mapperConnection2 = GetOpenConnection();
                    tests.Add(id => mapperConnection2.Query("select * from Posts where Id = @Id", new { Id = id }, buffered: true).First(), "Dapper: Dynamic Query (buffered)");
                    tests.Add(id => mapperConnection2.Query("select * from Posts where Id = @Id", new { Id = id }, buffered: false).First(), "Dapper: Dynamic Query (non-buffered)");
                    tests.Add(id => mapperConnection2.QueryFirstOrDefault("select * from Posts where Id = @Id", new { Id = id }), "Dapper: Dynamic QueryFirstOrDefault");

                    // dapper.contrib
                    var mapperConnection3 = GetOpenConnection();
                    tests.Add(id => mapperConnection3.Get <Post>(id), "Dapper.Contrib");
                }, "Dapper");

                // Massive
                Try(() =>
                {
                    var massiveModel      = new DynamicModel(ConnectionString);
                    var massiveConnection = GetOpenConnection();
                    tests.Add(id => massiveModel.Query("select * from Posts where Id = @0", massiveConnection, id).First(), "Massive: Dynamic ORM Query");
                }, "Massive");

                // PetaPoco
                Try(() =>
                {
                    // PetaPoco test with all default options
                    var petapoco = new PetaPoco.Database(ConnectionString, "System.Data.SqlClient");
                    petapoco.OpenSharedConnection();
                    tests.Add(id => petapoco.Fetch <Post>("SELECT * from Posts where Id=@0", id).First(), "PetaPoco: Normal");

                    // PetaPoco with some "smart" functionality disabled
                    var petapocoFast = new PetaPoco.Database(ConnectionString, "System.Data.SqlClient");
                    petapocoFast.OpenSharedConnection();
                    petapocoFast.EnableAutoSelect    = false;
                    petapocoFast.EnableNamedParams   = false;
                    petapocoFast.ForceDateTimesToUtc = false;
                    tests.Add(id => petapocoFast.Fetch <Post>("SELECT * from Posts where Id=@0", id).First(), "PetaPoco: Fast");
                }, "PetaPoco");

                // NHibernate
                Try(() =>
                {
                    var nhSession1 = NHibernateHelper.OpenSession();
                    tests.Add(id => nhSession1.CreateSQLQuery(@"select * from Posts where Id = :id")
                              .SetInt32("id", id)
                              .List(), "NHibernate: SQL");

                    var nhSession2 = NHibernateHelper.OpenSession();
                    tests.Add(id => nhSession2.CreateQuery(@"from Post as p where p.Id = :id")
                              .SetInt32("id", id)
                              .List(), "NHibernate: HQL");

                    var nhSession3 = NHibernateHelper.OpenSession();
                    tests.Add(id => nhSession3.CreateCriteria <Post>()
                              .Add(Restrictions.IdEq(id))
                              .List(), "NHibernate: Criteria");

                    var nhSession4 = NHibernateHelper.OpenSession();
                    tests.Add(id => nhSession4
                              .Query <Post>()
                              .First(p => p.Id == id), "NHibernate: LINQ");

                    var nhSession5 = NHibernateHelper.OpenSession();
                    tests.Add(id => nhSession5.Get <Post>(id), "NHibernate: Session.Get");
                }, "NHibernate");

                // Simple.Data
                Try(() =>
                {
                    var sdb = Simple.Data.Database.OpenConnection(ConnectionString);
                    tests.Add(id => sdb.Posts.FindById(id).FirstOrDefault(), "Simple.Data");
                }, "Simple.Data");

                // Belgrade
                Try(() =>
                {
                    var query = new Belgrade.SqlClient.SqlDb.QueryMapper(ConnectionString);
                    tests.AsyncAdd(id => query.ExecuteReader("SELECT TOP 1 * FROM Posts WHERE Id = " + id,
                                                             reader =>
                    {
                        var post            = new Post();
                        post.Id             = reader.GetInt32(0);
                        post.Text           = reader.GetString(1);
                        post.CreationDate   = reader.GetDateTime(2);
                        post.LastChangeDate = reader.GetDateTime(3);

                        post.Counter1 = reader.IsDBNull(4) ? null : (int?)reader.GetInt32(4);
                        post.Counter2 = reader.IsDBNull(5) ? null : (int?)reader.GetInt32(5);
                        post.Counter3 = reader.IsDBNull(6) ? null : (int?)reader.GetInt32(6);
                        post.Counter4 = reader.IsDBNull(7) ? null : (int?)reader.GetInt32(7);
                        post.Counter5 = reader.IsDBNull(8) ? null : (int?)reader.GetInt32(8);
                        post.Counter6 = reader.IsDBNull(9) ? null : (int?)reader.GetInt32(9);
                        post.Counter7 = reader.IsDBNull(10) ? null : (int?)reader.GetInt32(10);
                        post.Counter8 = reader.IsDBNull(11) ? null : (int?)reader.GetInt32(11);
                        post.Counter9 = reader.IsDBNull(12) ? null : (int?)reader.GetInt32(12);
                    }), "Belgrade Sql Client");
                }, "Belgrade Sql Client");

                //Susanoo
                Try(() =>
                {
                    var susanooDb = new DatabaseManager(connection);

                    var susanooPreDefinedCommand =
                        CommandManager.Instance.DefineCommand("SELECT * FROM Posts WHERE Id = @Id", CommandType.Text)
                        .DefineResults <Post>()
                        .Realize();

                    var susanooDynamicPreDefinedCommand =
                        CommandManager.Instance.DefineCommand("SELECT * FROM Posts WHERE Id = @Id", CommandType.Text)
                        .DefineResults <dynamic>()
                        .Realize();

                    tests.Add(Id =>
                              CommandManager.Instance.DefineCommand("SELECT * FROM Posts WHERE Id = @Id", CommandType.Text)
                              .DefineResults <Post>()
                              .Realize()
                              .Execute(susanooDb, new { Id }).First(), "Susanoo: Mapping Cache Retrieval");

                    tests.Add(Id =>
                              CommandManager.Instance.DefineCommand("SELECT * FROM Posts WHERE Id = @Id", CommandType.Text)
                              .DefineResults <dynamic>()
                              .Realize()
                              .Execute(susanooDb, new { Id }).First(), "Susanoo: Dynamic Mapping Cache Retrieval");

                    tests.Add(Id => susanooDynamicPreDefinedCommand
                              .Execute(susanooDb, new { Id }).First(), "Susanoo: Dynamic Mapping Static");

                    tests.Add(Id => susanooPreDefinedCommand
                              .Execute(susanooDb, new { Id }).First(), "Susanoo: Mapping Static");
                }, "Susanoo");

                //ServiceStack's OrmLite:
                Try(() =>
                {
                    var dbFactory = new OrmLiteConnectionFactory(ConnectionString, SqlServerDialect.Provider);
                    var db        = dbFactory.Open();
                    tests.Add(id => db.SingleById <Post>(id), "ServiceStack.OrmLite: SingleById");
                }, "ServiceStack.OrmLite");

                // Hand Coded
                Try(() =>
                {
                    var postCommand = new SqlCommand()
                    {
                        Connection  = connection,
                        CommandText = @"select Id, [Text], [CreationDate], LastChangeDate, 
                Counter1,Counter2,Counter3,Counter4,Counter5,Counter6,Counter7,Counter8,Counter9 from Posts where Id = @Id"
                    };
                    var idParam = postCommand.Parameters.Add("@Id", SqlDbType.Int);

                    tests.Add(id =>
                    {
                        idParam.Value = id;

                        using (var reader = postCommand.ExecuteReader())
                        {
                            reader.Read();
                            var post            = new Post();
                            post.Id             = reader.GetInt32(0);
                            post.Text           = reader.GetNullableString(1);
                            post.CreationDate   = reader.GetDateTime(2);
                            post.LastChangeDate = reader.GetDateTime(3);

                            post.Counter1 = reader.GetNullableValue <int>(4);
                            post.Counter2 = reader.GetNullableValue <int>(5);
                            post.Counter3 = reader.GetNullableValue <int>(6);
                            post.Counter4 = reader.GetNullableValue <int>(7);
                            post.Counter5 = reader.GetNullableValue <int>(8);
                            post.Counter6 = reader.GetNullableValue <int>(9);
                            post.Counter7 = reader.GetNullableValue <int>(10);
                            post.Counter8 = reader.GetNullableValue <int>(11);
                            post.Counter9 = reader.GetNullableValue <int>(12);
                        }
                    }, "Hand Coded");

#if !NETSTANDARD1_3
                    var table = new DataTable
                    {
                        Columns =
                        {
                            { "Id",             typeof(int)      },
                            { "Text",           typeof(string)   },
                            { "CreationDate",   typeof(DateTime) },
                            { "LastChangeDate", typeof(DateTime) },
                            { "Counter1",       typeof(int)      },
                            { "Counter2",       typeof(int)      },
                            { "Counter3",       typeof(int)      },
                            { "Counter4",       typeof(int)      },
                            { "Counter5",       typeof(int)      },
                            { "Counter6",       typeof(int)      },
                            { "Counter7",       typeof(int)      },
                            { "Counter8",       typeof(int)      },
                            { "Counter9",       typeof(int)      },
                        }
                    };
                    tests.Add(id =>
                    {
                        idParam.Value   = id;
                        object[] values = new object[13];
                        using (var reader = postCommand.ExecuteReader())
                        {
                            reader.Read();
                            reader.GetValues(values);
                            table.Rows.Add(values);
                        }
                    }, "DataTable via IDataReader.GetValues");
#endif
                }, "Hand Coded");

                // Subsonic isn't maintained anymore - doesn't import correctly
                //Try(() =>
                //    {
                //    // Subsonic ActiveRecord
                //    tests.Add(id => 3SubSonic.Post.SingleOrDefault(x => x.Id == id), "SubSonic ActiveRecord.SingleOrDefault");

                //    // Subsonic coding horror
                //    SubSonic.tempdbDB db = new SubSonic.tempdbDB();
                //    tests.Add(id => new SubSonic.Query.CodingHorror(db.Provider, "select * from Posts where Id = @0", id).ExecuteTypedList<Post>(), "SubSonic Coding Horror");
                //}, "Subsonic");

                //// BLToolkit - doesn't import correctly in the new .csproj world
                //var db1 = new DbManager(GetOpenConnection());
                //tests.Add(id => db1.SetCommand("select * from Posts where Id = @id", db1.Parameter("id", id)).ExecuteList<Post>(), "BLToolkit");

                Console.WriteLine();
                Console.WriteLine("Running...");
                await tests.RunAsync(iterations).ConfigureAwait(false);

#pragma warning restore RCS1121 // Use [] instead of calling 'First'.
#pragma warning restore IDE0017 // Simplify object initialization
            }
        }
 private static IObjectStream <DocumentSample> CreateSampleStream()
 {
     return(new DocumentSampleStream(new PlainTextByLineStream(Tests.OpenFile("opennlp/tools/doccat/DoccatSample.txt"))));
 }
 public BasicVerticalMonoHeaderAndFooterTests(IExcelTestsManager testManager)
     : base(testManager, 1, "Tests on a basic template (without linked templates) with a one line header and a one line footer", "VerticalMonoHeaderAndFooter")
 {
     Tests.Add(new TestCompleteView(this));
     Tests.Add(new TestViewParts(this));
 }
Beispiel #28
0
        private async Task <UniversityDbContext> PrepareCoursesWithTrainers()
        {
            var trainer1 = new User {
                Id = TrainerValid
            };
            var trainer2 = new User {
                Id = TrainerInvalid
            };

            var student1 = new User {
                Id = Student1, Name = "Student 1", UserName = "******", Email = "*****@*****.**"
            };
            var student2 = new User {
                Id = Student2, Name = "Student 2", UserName = "******", Email = "*****@*****.**"
            };
            var student3 = new User {
                Id = Student3, Name = "Student 3", UserName = "******", Email = "*****@*****.**"
            };

            var course1 = new Course {
                Id = CourseValid, TrainerId = TrainerValid
            };
            var course2 = new Course {
                Id = CourseInvalid
            };
            var course3 = new Course {
                Id = CourseEnded, EndDate = DateTime.UtcNow.AddDays(-1)
            };                                                                                    // past
            var course4 = new Course {
                Id = CourseNotEnded, EndDate = DateTime.UtcNow.AddDays(1)
            };                                                                                      // future

            course1.Students.Add(new StudentCourse {
                StudentId = student1.Id, CourseId = CourseValid, GradeBg = DataConstants.GradeBgMaxValue
            });
            course1.Students.Add(new StudentCourse {
                StudentId = student2.Id, CourseId = CourseValid, GradeBg = DataConstants.GradeBgCertificateMinValue
            });
            course1.Students.Add(new StudentCourse {
                StudentId = student3.Id, CourseId = CourseValid
            });

            student1.ExamSubmissions.Add(new ExamSubmission {
                Id = 1, CourseId = CourseValid, SubmissionDate = new DateTime(2019, 8, 1)
            });
            student1.ExamSubmissions.Add(new ExamSubmission {
                Id = 2, CourseId = CourseValid, SubmissionDate = new DateTime(2019, 8, 10)
            });
            student2.ExamSubmissions.Add(new ExamSubmission {
                Id = 3, CourseId = CourseValid, SubmissionDate = new DateTime(2019, 8, 10)
            });

            var db = Tests.InitializeDatabase();
            await db.Courses.AddRangeAsync(course1, course2, course3, course4);

            await db.Users.AddRangeAsync(trainer1, trainer2, student1, student2, student3);

            await db.SaveChangesAsync();

            return(db);
        }
Beispiel #29
0
 private static IObjectStream <SentenceSample> CreateSampleStream()
 {
     return(new SentenceSampleStream(new PlainTextByLineStream(Tests.OpenFile("opennlp/tools/sentdetect/Sentences.txt"))));
 }
        /// <summary>
        /// Evaluates the rule and its sub rules
        /// </summary>
        /// <param name="runner"></param>
        /// <param name="priority">the priority level : a rule can be activated only if its priority level == priority</param>
        /// <param name="instance">The instance on which the rule must be evaluated</param>
        /// <param name="ruleConditions">the rule conditions to be activated</param>
        /// <returns>the number of actions that were activated during this evaluation</returns>
        public bool Evaluate(Tests.Runner.Runner runner, Generated.acceptor.RulePriority priority, Utils.IModelElement instance, List<RuleCondition> ruleConditions)
        {
            bool retVal = false;

            Interpreter.InterpretationContext context = new Interpreter.InterpretationContext(instance);
            retVal = EvaluatePreConditions(context);

            if (retVal)
            {
                foreach (Rule subRule in SubRules)
                {
                    subRule.Evaluate(runner, priority, instance, ruleConditions);
                }

                if (EnclosingRule.getPriority() == priority)
                {
                    ruleConditions.Add(this);
                }
            }

            return retVal;
        }
Beispiel #31
0
 private static Dic LoadAbbDictionary()
 {
     return(new Dic(Tests.OpenFile("opennlp/tools/sentdetect/abb.xml")));
 }
        private void backgroundWorkerLoading_DoWork(object sender, DoWorkEventArgs e)
        {
            FormMain parent = (FormMain)this.Owner;

            DataTable dataTable;
            dataTable = sqliteDatabase.GetDataTable("SELECT * FROM characterHistory WHERE id = " + e.Argument.ToString() + ";");
            DataRow row = dataTable.Rows[0];

            if (Convert.ToInt32(row["duplicate_last"]) == 0) // if this history set contains data
            {
                List<ListViewItem> lvisGeneral = new List<ListViewItem>();
                List<ListViewItem> lvisItems = new List<ListViewItem>();
                List<ListViewItem> lvisEnchants = new List<ListViewItem>();
                List<ListViewItem> lvisGems = new List<ListViewItem>();
                List<ListViewItem> lvisReforge = new List<ListViewItem>();
                List<ListViewItem> lvisGlyphs = new List<ListViewItem>();
                List<ListViewItem> lvisTests = new List<ListViewItem>();
                List<ListViewItem> lvisTalents = new List<ListViewItem>();

                Dictionary<int, int> gemQualities = new Dictionary<int, int>();

                Character character = (Character)parentForm.UnserializeObject(row["serializedCharacter"].ToString(), typeof(Character));

                if (character != null)
                {

                    #region General and Stats

                    int currentGroupIndex = 0;
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Updated on", Value = row["date"].ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Level", Value = character.Level.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Class", Value = ReformatString(character.Class.ToString()), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));

                    foreach (CharacterTalent talents in character.Talents)
                    {
                        if (talents.Selected) { lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Selected Spec", Value = talents.Spec.Name + " (" + talents.Spec.Role + ")", Group = listViewDetailsGeneral.Groups[currentGroupIndex] })); }
                        else { lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Available Spec", Value = talents.Spec.Name + " (" + talents.Spec.Role + ")", Group = listViewDetailsGeneral.Groups[currentGroupIndex] })); }
                    }

                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Guild", Value = character.Guild.Name + " (Level " + character.Guild.Level + ", " + character.Guild.Members + " Members)", Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));

                    currentGroupIndex = 1;
                    foreach (CharacterProfession currentProfession in character.Professions.Primary)
                    {
                        lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Primary", Value = currentProfession.Name + " (" + currentProfession.Rank.ToString() + ")", Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    }
                    foreach (CharacterProfession currentProfession in character.Professions.Secondary)
                    {
                        lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Secondary", Value = currentProfession.Name + " (" + currentProfession.Rank.ToString() + ")", Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    }
                    currentGroupIndex = 2;
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Health", Value = (character.Stats.Health / 1000).ToString() + "k", Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Power", Value = (character.Stats.Power < 1000) ? character.Stats.Power.ToString() : (character.Stats.Power / 1000).ToString() + "k", Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Power Type", Value = ReformatString(character.Stats.PowerType.ToString()), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));

                    currentGroupIndex = 3;
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Strength", Value = character.Stats.Str.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Agility", Value = character.Stats.Agi.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Stamina", Value = character.Stats.Sta.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Intellect", Value = character.Stats.Int.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Spirit", Value = character.Stats.Spr.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Mastery", Value = character.Stats.Mastery.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Mastery Rating", Value = character.Stats.MasteryRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));

                    currentGroupIndex = 4;
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Main Hand DPS", Value = character.Stats.MainHandDps.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Off Hand DPS", Value = character.Stats.OffHandDps.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Main Hand Damage Max", Value = character.Stats.MainHandDmgMax.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Off Hand Damage Max", Value = character.Stats.OffHandDmgMax.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Main Hand Damage Min", Value = character.Stats.MainHandDmgMin.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Off Hand Damage Min", Value = character.Stats.OffHandDmgMin.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Main Hand Expertise", Value = character.Stats.MainHandExpertise.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Off Hand Expertise", Value = character.Stats.OffHandExpertise.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Main Hand Speed", Value = character.Stats.MainHandSpeed.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Off Hand Speed", Value = character.Stats.OffHandSpeed.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Attack Power", Value = character.Stats.AttackPower.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Haste Rating", Value = character.Stats.HasteRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Hit Percent", Value = character.Stats.HitPercent.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Hit Rating", Value = character.Stats.HitRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Crit Percent", Value = character.Stats.Crit.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Crit Rating", Value = character.Stats.CritRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Expertise Rating", Value = character.Stats.ExpertiseRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));

                    currentGroupIndex = 5;
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Ranged DPS", Value = character.Stats.RangedDps.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Ranged Damage Max", Value = character.Stats.RangedDmgMax.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Ranged Damage Min", Value = character.Stats.RangedDmgMin.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Ranged Speed", Value = character.Stats.RangedSpeed.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Ranged Attack Power", Value = character.Stats.RangedAttackPower.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Ranged Hit Percent", Value = character.Stats.RangedHitPercent.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Ranged Hit Rating", Value = character.Stats.RangedHitRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Ranged Crit Percent", Value = character.Stats.RangedCrit.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Ranged Crit Rating", Value = character.Stats.RangedCritRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));

                    currentGroupIndex = 6;
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Spell Power", Value = character.Stats.SpellPower.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Spell Hit Percent", Value = character.Stats.SpellHitPercent.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Spell Hit Rating", Value = character.Stats.SpellHitRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Spell Crit Percent", Value = character.Stats.SpellCrit.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Spell Crit Rating", Value = character.Stats.SpellCritRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Mana Regen", Value = character.Stats.Mana5.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Combat Mana Regen", Value = character.Stats.Mana5Combat.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));

                    currentGroupIndex = 7;
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Armor", Value = character.Stats.Armor.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Dodge Percent", Value = character.Stats.Dodge.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Dodge Rating", Value = character.Stats.DodgeRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Parry Percent", Value = character.Stats.Parry.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Parry Rating", Value = character.Stats.ParryRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Block Percent", Value = character.Stats.Block.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "Block Rating", Value = character.Stats.BlockRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));

                    currentGroupIndex = 8;
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "PVP Resilience", Value = character.Stats.PvpResilience.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "PVP Resilience Rating", Value = character.Stats.PvpResilienceRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "PVP Power", Value = character.Stats.PvpPower.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));
                    lvisGeneral.Add(new SetListViewItem(new SetDataSimple() { Title = "PVP Power Rating", Value = character.Stats.PvpPowerRating.ToString(), Group = listViewDetailsGeneral.Groups[currentGroupIndex] }));

                    #endregion

                    #region Items

                    lvisItems.Add(new SetListViewItem(new SetDataSimple() { Title = "Average Itemlevel", Value = character.Items.AverageItemLevel.ToString(), Group = listViewDetailsItems.Groups[0] }));
                    lvisItems.Add(new SetListViewItem(new SetDataSimple() { Title = "Average Equipped Itemlevel", Value = character.Items.AverageItemLevelEquipped.ToString(), Group = listViewDetailsItems.Groups[0] }));

                    CharacterEquipment thisEquipment = character.Items;
                    PropertyInfo[] equipmentProperties = thisEquipment.GetType().GetProperties();

                    foreach (PropertyInfo property in equipmentProperties)
                    {
                        if (property.GetValue(thisEquipment, null) != null && property.GetValue(thisEquipment, null).GetType() == typeof(CharacterItem))
                        {
                            CharacterItem currentItem = (CharacterItem)property.GetValue(thisEquipment, null);
                            lvisItems.Add(new SetListViewItem(new SetDataDirect()
                            {
                                Title = property.Name,
                                subItemsInfo = new List<SetDataDirectInfo>()
                                {
                                    new SetDataDirectInfo() { Text = currentItem.Name, ForeColor = parent.ItemQualityColorTranslation[currentItem.Quality], Font = new Font(this.Font, FontStyle.Bold) },
                                    new SetDataDirectInfo() { Text = currentItem.Id.ToString() },
                                },
                                Group = listViewDetailsItems.Groups[1]
                            }));
                        }
                    }

                    #endregion

                    #region Enchants

                    foreach (PropertyInfo property in equipmentProperties)
                    {
                        if (property.GetValue(thisEquipment, null) != null && property.GetValue(thisEquipment, null).GetType() == typeof(CharacterItem))
                        {
                            CharacterItem currentItem = (CharacterItem)property.GetValue(thisEquipment, null);
                            if (currentItem.TooltipParams.Enchant != 0)
                            {
                                lvisEnchants.Add(new SetListViewItem(new SetDataSimple()
                                {
                                    Title = property.Name,
                                    Value = currentItem.TooltipParams.Enchant.ToString(),
                                    SecondValue = parentForm.GetItemOrSpellName(getEnchantTranslation(currentItem.TooltipParams.Enchant).Value, getEnchantTranslation(currentItem.TooltipParams.Enchant).Key),
                                    Group = listViewDetailsItems.Groups[1]
                                }));
                            }
                        }
                    }

                    #endregion

                    #region Gems

                    Dictionary<string, int> slotGroupTranslation = new Dictionary<string, int>()
                {
                    {"Back", 18},
                    {"Chest", 3},
                    {"Feet", 9},
                    {"Finger1", 10},
                    {"Finger2", 11},
                    {"Hands", 6},
                    {"Head", 17},
                    {"Legs", 8},
                    {"MainHand", 14},
                    {"Neck", 2},
                    {"OffHand", 15},
                    {"Ranged", 16},
                    {"Shirt", 4},
                    {"Shoulder", 1},
                    {"Trinket1", 12},
                    {"Trinket2", 13},
                    {"Waist", 7},
                    {"Wrist", 5},

                };

                    foreach (PropertyInfo property in equipmentProperties)
                    {
                        if (property.GetValue(thisEquipment, null) != null && property.GetValue(thisEquipment, null).GetType() == typeof(CharacterItem))
                        {
                            CharacterItem currentItem = (CharacterItem)property.GetValue(thisEquipment, null);
                            if (currentItem.TooltipParams.Gem0 != 0)
                            {
                                lvisGems.Add(new SetListViewItem(new SetDataDirect()
                                {
                                    Title = "Gem 1",
                                    subItemsInfo = new List<SetDataDirectInfo>()
                                    {
                                        new SetDataDirectInfo() { Text = currentItem.TooltipParams.Gem0.ToString() },
                                        new SetDataDirectInfo() { Text = parent.GetItem(currentItem.TooltipParams.Gem0).GemInfo.Bonus.Name },
                                        new SetDataDirectInfo() { Text = parent.GetItem(currentItem.TooltipParams.Gem0).Name, ForeColor = parent.ItemQualityColorTranslation[parent.GetItem(currentItem.TooltipParams.Gem0).Quality], Font = new Font(this.Font, FontStyle.Bold) },
                                    },
                                    Group = listViewDetailsGems.Groups[slotGroupTranslation[property.Name]]
                                }));
                                IncrementGemStatisticsCounter(ref gemQualities, parent.GetItem(currentItem.TooltipParams.Gem0).Quality);
                            }

                            if (currentItem.TooltipParams.Gem1 != 0)
                            {
                                lvisGems.Add(new SetListViewItem(new SetDataDirect()
                                {
                                    Title = "Gem 2",
                                    subItemsInfo = new List<SetDataDirectInfo>()
                                    {
                                        new SetDataDirectInfo() { Text = currentItem.TooltipParams.Gem0.ToString() },
                                        new SetDataDirectInfo() { Text = parent.GetItem(currentItem.TooltipParams.Gem1).GemInfo.Bonus.Name },
                                        new SetDataDirectInfo() { Text = parent.GetItem(currentItem.TooltipParams.Gem1).Name, ForeColor = parent.ItemQualityColorTranslation[parent.GetItem(currentItem.TooltipParams.Gem1).Quality], Font = new Font(this.Font, FontStyle.Bold) },
                                    },
                                    Group = listViewDetailsGems.Groups[slotGroupTranslation[property.Name]]
                                }));
                                IncrementGemStatisticsCounter(ref gemQualities, parent.GetItem(currentItem.TooltipParams.Gem1).Quality);
                            }

                            if (currentItem.TooltipParams.Gem2 != 0)
                            {
                                lvisGems.Add(new SetListViewItem(new SetDataDirect()
                                {
                                    Title = "Gem 3",
                                    subItemsInfo = new List<SetDataDirectInfo>()
                                    {
                                        new SetDataDirectInfo() { Text = currentItem.TooltipParams.Gem0.ToString() },
                                        new SetDataDirectInfo() { Text = parent.GetItem(currentItem.TooltipParams.Gem2).GemInfo.Bonus.Name },
                                        new SetDataDirectInfo() { Text = parent.GetItem(currentItem.TooltipParams.Gem2).Name, ForeColor = parent.ItemQualityColorTranslation[parent.GetItem(currentItem.TooltipParams.Gem2).Quality], Font = new Font(this.Font, FontStyle.Bold) },
                                    },
                                    Group = listViewDetailsGems.Groups[slotGroupTranslation[property.Name]]
                                }));
                                IncrementGemStatisticsCounter(ref gemQualities, parent.GetItem(currentItem.TooltipParams.Gem2).Quality);
                            }
                        }
                    }

                    #endregion

                    #region Reforge

                    Dictionary<int, int> reforgeSummary = new Dictionary<int, int>();
                    foreach (PropertyInfo property in equipmentProperties)
                    {
                        if (property.GetValue(thisEquipment, null) != null && property.GetValue(thisEquipment, null).GetType() == typeof(CharacterItem))
                        {
                            CharacterItem currentItem = (CharacterItem)property.GetValue(thisEquipment, null);
                            if (currentItem.TooltipParams.Reforge != 0)
                            {
                                lvisReforge.Add(new SetListViewItem(new SetDataSimple()
                                {
                                    Title = property.Name,
                                    Value = currentItem.TooltipParams.Reforge.ToString(),
                                    SecondValue = getReforgeTranslation(currentItem.TooltipParams.Reforge),
                                    Group = listViewDetailsReforge.Groups[0]
                                }));
                                if (reforgeSummary.ContainsKey(currentItem.TooltipParams.Reforge)) { reforgeSummary[currentItem.TooltipParams.Reforge]++; }
                                else { reforgeSummary.Add(currentItem.TooltipParams.Reforge, 1); }
                            }
                        }
                    }

                    foreach (KeyValuePair<int, int> kvp in reforgeSummary)
                    {
                        lvisReforge.Add(new SetListViewItem(new SetDataSimple()
                        {
                            Title = getReforgeTranslation(kvp.Key),
                            Value = kvp.Value.ToString(),
                            Group = listViewDetailsReforge.Groups[1]
                        }));
                    }

                    #endregion;

                    #region Glyphs

                    int specCounter = 0;
                    foreach (CharacterTalent currentTalentSpec in character.Talents)
                    {
                        CharacterTalentGlyphs currentGlyphs = currentTalentSpec.Glyphs;
                        foreach (CharacterTalentGlyph currentMajorGlyph in currentGlyphs.Major)
                        {
                            lvisGlyphs.Add(new SetListViewItem(new SetDataSimple()
                            {
                                Title = "Major",
                                Value = currentMajorGlyph.Item.ToString(),
                                SecondValue = currentMajorGlyph.Name,
                                Group = listViewDetailsGlyphs.Groups[specCounter]
                            }));
                        }

                        foreach (CharacterTalentGlyph currentMinorGlyph in currentGlyphs.Minor)
                        {
                            lvisGlyphs.Add(new SetListViewItem(new SetDataSimple()
                            {
                                Title = "Minor",
                                Value = currentMinorGlyph.Item.ToString(),
                                SecondValue = currentMinorGlyph.Name,
                                Group = listViewDetailsGlyphs.Groups[specCounter]
                            }));
                        }

                        specCounter++;
                    }

                    #endregion;

                    #region Talents

                    foreach (CharacterTalentInfo currentTalent in character.Talents.ToArray()[0].Talents)
                    {
                        lvisTalents.Add(new SetListViewItem(new SetDataDirect()
                        {
                            Title = character.Talents.ToArray()[0].Spec.Name,
                            subItemsInfo = new List<SetDataDirectInfo>()
                                {
                                    new SetDataDirectInfo() { Text = currentTalent.Tier.ToString() },
                                    new SetDataDirectInfo() { Text = currentTalent.Spell.Name },
                                    new SetDataDirectInfo() { Text = currentTalent.Spell.Description },
                                },
                            Group = listViewDetailsTalents.Groups[0]
                        }));
                    }

                    foreach (CharacterTalentInfo currentTalent in character.Talents.ToArray()[1].Talents)
                    {
                        lvisTalents.Add(new SetListViewItem(new SetDataDirect()
                        {
                            Title = character.Talents.ToArray()[1].Spec.Name,
                            subItemsInfo = new List<SetDataDirectInfo>()
                                {
                                    new SetDataDirectInfo() { Text = currentTalent.Tier.ToString() },
                                    new SetDataDirectInfo() { Text = currentTalent.Spell.Name },
                                    new SetDataDirectInfo() { Text = currentTalent.Spell.Description },
                                },
                            Group = listViewDetailsTalents.Groups[1]
                        }));
                    }

                    #endregion

                    #region Tests

                    Tests tests = new Tests(ref listViewDetailsTests);

                    // Hit Caps
                    if (!Warcraft.IsHealer(character))
                    {
                        if (Warcraft.NeedsMeleeHit(character.Class.ToString()))
                        {
                            lvisTests.Add(tests.InRange(7.5, Convert.ToDouble(character.Stats.HitPercent), 1, "Melee Hit Cap", false, 0));
                            lvisTests.Add(tests.InRange(7.5, Convert.ToDouble(character.Stats.MainHandDmgMax), 1, "Expertise Cap", false, 0));
                        }
                        if (Warcraft.NeedsSpellHit(character.Class.ToString())) { lvisTests.Add(tests.InRange(17, Convert.ToDouble(character.Stats.HitPercent), 2, "Spell Hit Cap", false, 0)); }
                    }
                    else
                    {
                        lvisTests.Add(tests.AreEqual(Convert.ToDouble(0), Convert.ToDouble(character.Stats.HitPercent), "No Hit", false, 0));
                    }

                    // Gems
                    lvisTests.Add(tests.AreEqual(1, gemQualities.ContainsKey(3) ? gemQualities[3] : 0, "Only 1 Rare Gem (Meta)", false, 1));
                    lvisTests.Add(tests.AreEqual(0, gemQualities.ContainsKey(2) ? gemQualities[2] : 0, "Uncommon (Green) Gems", true, 1));
                    lvisTests.Add(tests.AreEqual(0, gemQualities.ContainsKey(1) ? gemQualities[1] : 0, "Common (White) Gems", true, 1));

                    // Sockets
                    foreach (PropertyInfo property in equipmentProperties)
                    {
                        if (property.GetValue(thisEquipment, null) != null && property.GetValue(thisEquipment, null).GetType() == typeof(CharacterItem))
                        {
                            CharacterItem currentItem = (CharacterItem)property.GetValue(thisEquipment, null);
                            lvisTests.Add(tests.AreEqual(true, parent.ItemAllSocketsFilled(currentItem), property.Name + ": No empty socket", false, 5));
                        }
                    }

                    // Glyphs
                    specCounter = 0;
                    foreach (CharacterTalent currentTalent in character.Talents)
                    {
                        lvisTests.Add(tests.AreEqual(3, currentTalent.Glyphs.Major.Count(), "Spec " + specCounter.ToString() + " Major Glyphs", true, 3));
                        lvisTests.Add(tests.AreEqual(3, currentTalent.Glyphs.Minor.Count(), "Spec " + specCounter.ToString() + " Minor Glyphs", false, 3));
                        specCounter++;
                    }

                    // Enchants
                    if (character.Items.Back.Id != 0) { lvisTests.Add(tests.AreEqual(true, (character.Items.Back.TooltipParams.Enchant != 0), "Back enchanted", false, 4)); }
                    if (character.Items.Chest != null) { lvisTests.Add(tests.AreEqual(true, (character.Items.Chest.TooltipParams.Enchant != 0), "Chest enchanted", false, 4)); }
                    if (character.Items.Feet != null) { lvisTests.Add(tests.AreEqual(true, (character.Items.Feet.TooltipParams.Enchant != 0), "Feet enchanted", false, 4)); }
                    if (parent.ProfessionHasEnchanting(character))
                    {
                        if (character.Items.Finger1 != null) { lvisTests.Add(tests.AreEqual(true, (character.Items.Finger1.TooltipParams.Enchant != 0), "Finger 1 enchanted", true, 4)); }
                        if (character.Items.Finger2 != null) { lvisTests.Add(tests.AreEqual(true, (character.Items.Finger2.TooltipParams.Enchant != 0), "Finger 2 enchanted", true, 4)); }
                    }
                    if (character.Items.Hands != null) { lvisTests.Add(tests.AreEqual(true, (character.Items.Hands.TooltipParams.Enchant != 0), "Hands enchanted", false, 4)); }
                    if (character.Items.Head != null) { lvisTests.Add(tests.AreEqual(true, (character.Items.Head.TooltipParams.Enchant != 0), "Head enchanted", false, 4)); }
                    if (character.Items.Legs != null) { lvisTests.Add(tests.AreEqual(true, (character.Items.Legs.TooltipParams.Enchant != 0), "Legs enchanted", false, 4)); }
                    if (character.Items.MainHand != null) { lvisTests.Add(tests.AreEqual(true, (character.Items.MainHand.TooltipParams.Enchant != 0), "Main Hand enchanted", false, 4)); }
                    if (character.Items.OffHand != null) { lvisTests.Add(tests.AreEqual(true, (character.Items.OffHand.TooltipParams.Enchant != 0), "Off Hand enchanted", false, 4)); }
                    if (character.Items.Shoulder != null) { lvisTests.Add(tests.AreEqual(true, (character.Items.Shoulder.TooltipParams.Enchant != 0), "Shoulder enchanted", false, 4)); }
                    if (character.Items.Wrist != null) { lvisTests.Add(tests.AreEqual(true, (character.Items.Wrist.TooltipParams.Enchant != 0), "Wrist enchanted", false, 4)); }

                    // Professions
                    lvisTests.Add(tests.AreEqual(2, character.Professions.Primary.Count(), "Primary Professions Count", true, 6));
                    if (character.Professions.Primary.ToArray()[0] != null) {
                        lvisTests.Add(tests.EqualOrGreater(525, character.Professions.Primary.ToArray()[0].Rank, "Primary Profession 1 Cataclysm", false, 6));
                        if (character.Level >= 90) { lvisTests.Add(tests.EqualOrGreater(600, character.Professions.Primary.ToArray()[0].Rank, "Primary Profession 1 Pandaria", false, 6)); }
                    }
                    if (character.Professions.Primary.ToArray()[1] != null) {
                        lvisTests.Add(tests.EqualOrGreater(525, character.Professions.Primary.ToArray()[1].Rank, "Primary Profession 2 Cataclysm", false, 6));
                        if (character.Level >= 90) { lvisTests.Add(tests.EqualOrGreater(600, character.Professions.Primary.ToArray()[1].Rank, "Primary Profession 2 Pandaria", false, 6)); }
                    }

                    if (Warcraft.NeedsInt(character))
                    {
                        lvisTests.Add(tests.LessOrEqual(80, character.Stats.Str, "No strength", true, 7));
                    }
                    else
                    {
                        lvisTests.Add(tests.LessOrEqual(80, character.Stats.Int, "No intellect", true, 7));
                    }

                    #endregion

                    Dictionary<string, List<ListViewItem>> resultLists = new Dictionary<string, List<ListViewItem>>();
                    resultLists.Add("general", lvisGeneral);
                    resultLists.Add("items", lvisItems);
                    resultLists.Add("enchants", lvisEnchants);
                    resultLists.Add("reforge", lvisReforge);
                    resultLists.Add("gems", lvisGems);
                    resultLists.Add("glyphs", lvisGlyphs);
                    resultLists.Add("talents", lvisTalents);
                    resultLists.Add("tests", lvisTests);
                    e.Result = resultLists;
                }
                else
                {
                    if (MessageBox.Show("Unable to display the selected history set because it contains invalid character data. Would you like to delete this set?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.Yes)
                    {
                        parentForm.HistoryDeleteSet(Convert.ToInt32(e.Argument));
                    }
                }
            }
        }
Beispiel #33
0
 public override void Create()
 {
     Tests.Add(new Sessional("Sessional - 1"));
     Tests.Add(new Sessional("Sessional - 2"));
 }
Beispiel #34
0
 public UserAdminServiceTests()
 {
     Tests.Initialize();
 }
Beispiel #35
0
 public override void Create()
 {
     Tests.Add(new Final("Final Term"));
 }
Beispiel #36
0
 public static unsafe string ti2(string[] s2, int[] s3, int[,] s4, ref int ri, int *ptr, int i, AStruct s, Tests t, Tests2 t2, GClass <int> g, AnEnum ae, TypedReference typedref)
 {
     return(s2 [0] + s3 [0] + s4 [0, 0]);
 }
Beispiel #37
0
 public void Initialize()
 {
     Tests.Test(MakeTexture);
 }
Beispiel #38
0
 public static void set_child(Tests t)
 {
     t.child = new Tests();
 }
Beispiel #39
0
 public void Update()
 {
     Default.MeshCube.Draw(singleChannelTex, Matrix.TS(new Vec3(0, 0, 0.75f), 0.5f));
     Tests.Screenshot("Tests/SingleChannelTextureR8.jpg", 600, 600, Vec3.Zero, -Vec3.Forward);
 }
 public TestCaseMetadataSource()
 {
     Tests    = DiscoverTests();
     Metadata = Tests.OfType <IMetadataElement>()
                .ToDictionary(x => x.Identity.Id);
 }
        public static IEnumerable <object[]> GetData(Tests test)
        {
            var testData = new List <object[]>();

            // Create test data based on test name
            switch (test)
            {
            case Tests.CustomSanitizeFieldNameSettingWithHeaders:
                testData.Add(new object[] { "*mySecurityHeader", new[] { "abcmySecurityHeader", "amySecurityHeader", "mySecurityHeader" } });
                testData.Add(new object[] { "mySecurityHeader*", new[] { "mySecurityHeaderAbc", "mySecurityHeaderAbc1", "mySecurityHeader" } });
                testData.Add(new object[] { "*mySecurityHeader*", new[] { "AbcmySecurityHeaderAbc", "amySecurityHeaderA", "mySecurityHeader" } });
                testData.Add(new object[] { "mySecurityHeader", new[] { "mySECURITYHeader" } });
                break;

            case Tests.CustomSanitizeFieldNameSettingWithCaseSensitivityWithHeaders:
                testData.Add(new object[] { "mysecurityheader", "mySECURITYHeader", true });
                testData.Add(new object[] { "(?-i)mysecurityheader", "mySECURITYHeader", false });
                testData.Add(new object[] { "(?-i)mySECURITYheader", "mySECURITYheader", true });
                testData.Add(new object[] { "(?-i)*mySECURITYheader", "TestmySECURITYheader", true });
                testData.Add(new object[] { "(?-i)*mySECURITYheader", "TestmysecURITYheader", false });
                testData.Add(new object[] { "(?-i)mySECURITYheader*", "mySECURITYheaderTest", true });
                testData.Add(new object[] { "(?-i)mySECURITYheader*", "mysecURITYheaderTest", false });
                testData.Add(new object[] { "(?-i)*mySECURITYheader*", "TestmySECURITYheaderTest", true });
                testData.Add(new object[] { "(?-i)*mySECURITYheader*", "TestmysecURITYheaderTest", false });
                break;

            case Tests.DefaultsWithHeaders:
                testData.Add(new object[] { "password" });
                testData.Add(new object[] { "pwd" });
                testData.Add(new object[] { "passwd" });
                testData.Add(new object[] { "secret" });
                testData.Add(new object[] { "secretkey" });                         //*key
                testData.Add(new object[] { "usertokensecret" });                   //*token*
                testData.Add(new object[] { "usersessionid" });                     //*session
                testData.Add(new object[] { "secretcreditcard" });                  //*credit*
                testData.Add(new object[] { "creditcardnumber" });                  //*card
                break;

            case Tests.DefaultsWithKnownHeaders:
                testData.Add(new object[] { "authorization", "Authorization" });
                testData.Add(new object[] { "set-cookie", "Set-Cookie" });
                break;

            case Tests.DefaultWithRequestBodyNoError:
                testData.Add(new object[] { "password" });
                testData.Add(new object[] { "pwd" });
                testData.Add(new object[] { "passwd" });
                testData.Add(new object[] { "secret" });
                testData.Add(new object[] { "secretkey" });                         //*key
                testData.Add(new object[] { "usertokensecret" });                   //*token*
                testData.Add(new object[] { "usersessionid" });                     //*session
                testData.Add(new object[] { "secretcreditcard" });                  //*credit*
                testData.Add(new object[] { "creditcardnumber" });                  //*card
                break;

            case Tests.DefaultWithRequestBodySingleValueNoError:
                testData.Add(new object[] { "password", true });
                testData.Add(new object[] { "pwd", true });
                testData.Add(new object[] { "Input", false });
                break;

            case Tests.DefaultWithRequestBodyWithError:
                testData.Add(new object[] { "password" });
                testData.Add(new object[] { "pwd" });
                testData.Add(new object[] { "secret" });
                testData.Add(new object[] { "secretkey" });                         //*key
                testData.Add(new object[] { "usertokensecret" });                   //*token*
                testData.Add(new object[] { "usersessionid" });                     //*session
                testData.Add(new object[] { "secretcreditcard" });                  //*credit*
                testData.Add(new object[] { "creditcardnumber" });                  //*card
                break;

            case Tests.CustomWithRequestBodyNoError:
                testData.Add(new object[] { "mysecurityheader", "mySECURITYHeader", true });
                testData.Add(new object[] { "(?-i)mysecurityheader", "mySECURITYHeader", false });
                testData.Add(new object[] { "(?-i)mySECURITYheader", "mySECURITYheader", true });
                testData.Add(new object[] { "(?-i)*mySECURITYheader", "TestmySECURITYheader", true });
                testData.Add(new object[] { "(?-i)*mySECURITYheader", "TestmysecURITYheader", false });
                testData.Add(new object[] { "(?-i)mySECURITYheader*", "mySECURITYheaderTest", true });
                testData.Add(new object[] { "(?-i)mySECURITYheader*", "mysecURITYheaderTest", false });
                testData.Add(new object[] { "(?-i)*mySECURITYheader*", "TestmySECURITYheaderTest", true });
                testData.Add(new object[] { "(?-i)*mySECURITYheader*", "TestmysecURITYheaderTest", false });
                break;
            }

            var retVal = new List <object[]>();

            // Add true and false to the end of each test data, so we test it both with middleware and with diagnosticsource
            foreach (var testDataItem in testData)
            {
                var newItem = new List <object>();
                foreach (var item in testDataItem)
                {
                    newItem.Add(item);
                }
                newItem.Add(true);

                retVal.Add(newItem.ToArray());

                newItem = new List <object>();
                foreach (var item in testDataItem)
                {
                    newItem.Add(item);
                }
                newItem.Add(false);

                retVal.Add(newItem.ToArray());
            }

            return(retVal);
        }
 public override EventStore.ClientAPI.IEventStoreConnection SetupConnection(Tests.Helpers.MiniNode node)
 {
     return EmbeddedTestConnection.To(node, DefaultData.AdminCredentials);
 }
Beispiel #43
0
 public virtual bool IsTest(string file)
 {
     return(Tests.Any(s => s.FullName == file));
 }
Beispiel #44
0
    // Liveness for spill slots holding managed pointers
    public static int test_0_liveness_11()
    {
        Tests[] arr = new Tests[10];
        // This uses an ldelema internally
        // FIXME: This doesn't crash if mp-s are not correctly tracked, just writes to
        // an old object.
        arr[0] >>= 1;

        return 0;
    }
Beispiel #45
0
    /// :End:

    public void Initialize()
    {
        Tests.Screenshot(600, 600, "RayMeshIntersect.jpg", new Vec3(0.2f, 0.16f, -0.192f), new Vec3(-0.036f, -0.021f, -1.163f));
    }
Beispiel #46
0
	public static int test_2_return_struct_virtual () {
		Tests t = new Tests ();
		Simple v = t.v_get_simple (2);

		if (v.a != 2)
			return 0;
		if (v.b != 3)
			return 0;
		if (v.c != 4)
			return 0;
		if (v.d != 5)
			return 0;
		return 2;
	}
Beispiel #47
0
 public void assembly_load()
 {
     Tests.assembly_load_in_domain();
 }
Beispiel #48
0
	public static int test_0_marshal_array_delegate_no_marshal_directive_instance () {
		try {
			Tests t = new Tests ();
			mono_test_marshal_array_delegate4_3 (null, 0, new ArrayDelegate4_3 (t.array_delegate4_3));
			return 1;
		}
		catch (MarshalDirectiveException) {
			return 0;
		}
	}
Beispiel #49
0
	static public int Main (String[] args) {
		Tests b = new Tests ();
		int res, err;

		Console.WriteLine ("Test1...");
		b.test ();
		if (is_synchronized (b))
			return 1;

		Console.WriteLine ("Test2...");
		test_static ();
		if (is_synchronized (typeof (Tests)))
			return 1;

		Console.WriteLine ("Test3...");
		try {
			b.test_exception ();
		}
		catch (SynchronizationLockException ex) {
			return 1;
		}
		catch (Exception ex) {
			// OK
		}
		if (is_synchronized (b))
			return 1;

		Console.WriteLine ("Test4...");
		b.test_virtual ();
		if (is_synchronized (b))
			return 1;

		Console.WriteLine ("Test5...");
		Delegate1 d = new Delegate1 (b.test);
		res = d ();
		if (is_synchronized (b))
			return 1;

		Console.WriteLine ("Test6...");
		d = new Delegate1 (test_static);
		res = d ();
		if (is_synchronized (typeof (Tests)))
			return 1;

		Console.WriteLine ("Test7...");
		d = new Delegate1 (b.test_virtual);
		res = d ();
		if (is_synchronized (b))
			return 1;

		Console.WriteLine ("Test8...");
		d = new Delegate1 (b.test_exception);
		try {
			d ();
		}
		catch (SynchronizationLockException ex) {
			return 2;
		}
		catch (Exception ex) {
			// OK
		}
		if (is_synchronized (b))
			return 1;

		return 0;
	}