public override string[] ExportData()
        {
            DataTable dtNew = DataTable.CopyForExport();

            //Get the response, treatment and covariate columns by removing all other columns from the new datatable
            foreach (string columnName in dtNew.GetVariableNames())
            {
                if (Response != columnName && !Treatments.Contains(columnName) && (OtherDesignFactors == null || !OtherDesignFactors.Contains(columnName)) && (Covariates == null || !Covariates.Contains(columnName)))
                {
                    dtNew.Columns.Remove(columnName);
                }
            }

            //if the response is blank then remove that row
            dtNew.RemoveBlankRow(Response);

            //Generate a "catfact" column from the CatFactors (used only in R)!
            DataColumn catFactor = new DataColumn("catfact");

            dtNew.Columns.Add(catFactor);

            //Need to create a new column for the scatterplot data as we have to combine any interaction effects into one column
            dtNew.CreateCombinedEffectColumn(Treatments, "scatterPlotColumn");

            //If an interaction effect is selected then we need to combine values into single column
            if (!String.IsNullOrEmpty(SelectedEffect))
            {
                //create a new column and add it to the table
                if (SelectedEffect.Contains(" * ")) //then it is an interaction effect so we need to combine values from different columns
                {
                    char[]   splitChar = { '*' };
                    string[] effects   = SelectedEffect.Split(splitChar, StringSplitOptions.RemoveEmptyEntries); //get the effect names that make up the interaction effect

                    dtNew.CreateCombinedEffectColumn(effects, "mainEffect");
                }
                else //just copy the column selected in the dropdown
                {
                    DataColumn mainEffect = new DataColumn("mainEffect");
                    dtNew.Columns.Add(mainEffect);
                    foreach (DataRow r in dtNew.Rows)
                    {
                        r["mainEffect"] = r[SelectedEffect].ToString();
                    }
                }
            }

            //Now do transformations...
            dtNew.TransformColumn(Response, ResponseTransformation);

            if (Covariates != null)
            {
                foreach (string covariate in Covariates)
                {
                    dtNew.TransformColumn(covariate, CovariateTransformation);
                }
            }

            //Finally, as numeric categorical variables get misinterpreted by r, we need to go through
            //each column and put them in quotes...
            foreach (string treat in Treatments)
            {
                if (dtNew.CheckIsNumeric(treat))
                {
                    foreach (DataRow row in dtNew.Rows)
                    {
                        row[treat] = "'" + row[treat] + "'";
                    }
                }
            }

            if (OtherDesignFactors != null)
            {
                foreach (string odf in OtherDesignFactors)
                {
                    if (dtNew.CheckIsNumeric(odf))
                    {
                        foreach (DataRow row in dtNew.Rows)
                        {
                            row[odf] = "'" + row[odf] + "'";
                        }
                    }
                }
            }

            string[] csvArray = dtNew.GetCSVArray();

            //fix any columns with illegal chars here (at the end)
            ArgumentFormatter argFormatter = new ArgumentFormatter();

            csvArray[0] = argFormatter.ConvertIllegalCharacters(csvArray[0]);

            return(csvArray);
        }
Ejemplo n.º 2
0
 public static void OnlyFirstFewValuesOfEnumerableAreRendered()
 {
     Assert.Equal("[0, 1, 2, 3, 4, ...]", ArgumentFormatter.Format(Enumerable.Range(0, int.MaxValue)));
 }
Ejemplo n.º 3
0
 public static void StringValueTruncated()
 {
     Assert.Equal("\"----|----1----|----2----|----3----|----4----|----5\"...", ArgumentFormatter.Format("----|----1----|----2----|----3----|----4----|----5-"));
 }
Ejemplo n.º 4
0
 public static void DecimalValue()
 {
     Assert.Equal(123.45M.ToString(), ArgumentFormatter.Format(123.45M));
 }
Ejemplo n.º 5
0
 public static void WithThrowingPropertyGetter()
 {
     Assert.Equal("ThrowingGetter { MyThrowingProperty = (throws NotImplementedException) }", ArgumentFormatter.Format(new ThrowingGetter()));
 }
Ejemplo n.º 6
0
 public static void StringValue()
 {
     Assert.Equal("\"Hello, world!\"", ArgumentFormatter.Format("Hello, world!"));
 }
Ejemplo n.º 7
0
 public static void StringValue(string value, string expected)
 {
     Assert.Equal(expected, ArgumentFormatter.Format(value));
 }
Ejemplo n.º 8
0
        public static void ComplexTypeInsideComplexType()
        {
            var expected = String.Format("MyComplexTypeWrapper {{ c = 'A', s = \"Hello, world!\", t = MyComplexType {{ MyPublicField = 42, MyPublicProperty = {0} }} }}", 21.12M);

            Assert.Equal(expected, ArgumentFormatter.Format(new MyComplexTypeWrapper()));
        }
        [InlineData(7, "7")]    // This is expected, not "Value1 | Value2 | 4"
        public static void Flags(FlagsEnum enumValue, string expected)
        {
            var actual = ArgumentFormatter.Format(enumValue);

            Assert.Equal(expected, actual);
        }
 public void ArgumentFormatterFormatTypeNames(Type type, string expectedResult)
 {
     Assert.Equal(ArgumentFormatter.Format(type), expectedResult);
 }
Ejemplo n.º 11
0
        public override string[] ExportData()
        {
            DataTable dtNew = DataTable.CopyForExport();

            //Get the response, treatment and covariate columns by removing all other columns from the new datatable
            foreach (string columnName in dtNew.GetVariableNames())
            {
                if (Response != columnName && (Treatments == null || !Treatments.Contains(columnName)) && (ContinuousFactors == null || !ContinuousFactors.Contains(columnName)) && (OtherDesignFactors == null || !OtherDesignFactors.Contains(columnName)) && (Covariates == null || !Covariates.Contains(columnName)))
                {
                    dtNew.Columns.Remove(columnName);
                }
            }

            //if the response is blank then remove that row
            dtNew.RemoveBlankRow(Response);

            //Need to create a new column for the scatterplot data as we have to combine any interaction effects into one column
            if (Treatments != null)
            {
                dtNew.CreateCombinedEffectColumn(Treatments, "scatterPlotColumn");
            }

            //Now do transformations...
            if (ContinuousFactors != null)
            {
                foreach (string continuousFactor in ContinuousFactors)
                {
                    dtNew.TransformColumn(continuousFactor, ContinuousFactorsTransformation);
                }
            }

            if (Covariates != null)
            {
                foreach (string covariate in Covariates)
                {
                    dtNew.TransformColumn(covariate, CovariateTransformation);
                }
            }

            //Finally, as numeric categorical variables get misinterpreted by r, we need to go through
            //each column and put them in quotes...
            if (Treatments != null)
            {
                foreach (string treat in Treatments)
                {
                    if (dtNew.CheckIsNumeric(treat))
                    {
                        foreach (DataRow row in dtNew.Rows)
                        {
                            row[treat] = "'" + row[treat] + "'";
                        }
                    }
                }
            }

            if (OtherDesignFactors != null)
            {
                foreach (string odf in OtherDesignFactors)
                {
                    if (dtNew.CheckIsNumeric(odf))
                    {
                        foreach (DataRow row in dtNew.Rows)
                        {
                            row[odf] = "'" + row[odf] + "'";
                        }
                    }
                }
            }

            string[] csvArray = dtNew.GetCSVArray();

            //fix any columns with illegal chars here (at the end)
            ArgumentFormatter argFormatter = new ArgumentFormatter();

            csvArray[0] = argFormatter.ConvertIllegalCharacters(csvArray[0]);

            return(csvArray);
        }
Ejemplo n.º 12
0
 public override string ToString() => ArgumentFormatter.Format(this.Value);
Ejemplo n.º 13
0
 public static void TypeValue()
 {
     Assert.Equal("typeof(System.String)", ArgumentFormatter.Format(typeof(string)));
 }
Ejemplo n.º 14
0
 public override string ToString()
 {
     return(ArgumentFormatter.Format(this.value));
 }
Ejemplo n.º 15
0
        public static void ReturnsValuesInAlphabeticalOrder()
        {
            var expected = $"MyComplexType {{ MyPublicField = 42, MyPublicProperty = {21.12M} }}";

            Assert.Equal(expected, ArgumentFormatter.Format(new MyComplexType()));
        }
Ejemplo n.º 16
0
 public static void NullValue()
 {
     Assert.Equal("null", ArgumentFormatter.Format(null));
 }
Ejemplo n.º 17
0
 public static void WhenCustomTypeImplementsToString_UsesToString()
 {
     Assert.Equal("This is what you should show", ArgumentFormatter.Format(new TypeWithToString()));
 }
Ejemplo n.º 18
0
 public static void Empty()
 {
     Assert.Equal("Object { }", ArgumentFormatter.Format(new object()));
 }
Ejemplo n.º 19
0
 public static void CharacterValue(char value, string expected)
 {
     Assert.Equal(expected, ArgumentFormatter.Format(value));
 }
Ejemplo n.º 20
0
        public static void LimitsOutputToFirstFewValues()
        {
            var expected = String.Format(@"Big {{ MyField1 = 42, MyField2 = ""Hello, world!"", MyProp1 = {0}, MyProp2 = typeof(ArgumentFormatterTests+ComplexTypes+Big), MyProp3 = 2014-04-17T07:45:23.0000000+00:00, ... }}", 21.12);

            Assert.Equal(expected, ArgumentFormatter.Format(new Big()));
        }
Ejemplo n.º 21
0
        public static void DateTimeOffsetValue()
        {
            var now = DateTimeOffset.UtcNow;

            Assert.Equal(now.ToString("o"), ArgumentFormatter.Format(now));
        }
Ejemplo n.º 22
0
 public static void TypesAreRenderedWithMaximumDepthToPreventInfiniteRecursion()
 {
     Assert.Equal("Looping { Me = Looping { Me = Looping { ... } } }", ArgumentFormatter.Format(new Looping()));
 }
Ejemplo n.º 23
0
 public static void TypeValue(Type type, string expected)
 {
     Assert.Equal(expected, ArgumentFormatter.Format(type));
 }
Ejemplo n.º 24
0
 public static void CharacterValue()
 {
     Assert.Equal("'a'", ArgumentFormatter.Format('a'));
 }
Ejemplo n.º 25
0
        public static void EnumerableValue()
        {
            var expected = $"[1, {2.3M}, \"Hello, world!\"]";

            Assert.Equal(expected, ArgumentFormatter.Format(new object[] { 1, 2.3M, "Hello, world!" }));
        }
 public SequenceInOrderAssertion()
 {
     _callFormatter = new CallFormatter();
     _argumentFormatter = new ArgumentFormatter();
 }
Ejemplo n.º 27
0
 public SequenceInOrderAssertion()
 {
     _callFormatter     = new CallFormatter();
     _argumentFormatter = new ArgumentFormatter();
 }