示例#1
0
        private SummaryStatisticsModel GetModel(IDataset dataset)
        {
            var model = new SummaryStatisticsModel(dataset)
            {
                ByCategoriesAndOverall = false,
                CoefficientOfVariation = false,
                ConfidenceInterval     = true,
                FirstCatFactor         = "Cat4",
                FourthCatFactor        = "Cat456",
                Mean = true,
                MedianAndQuartiles = false,
                MinAndMax          = false,
                N = true,
                NormalProbabilityPlot = false,
                Responses             = new System.Collections.Generic.List <string>
                {
                    "Resp 2",
                    "Resp8"
                },
                SecondCatFactor     = "Cat5",
                Significance        = 95,
                StandardDeviation   = true,
                StandardErrorOfMean = false,
                ThirdCatFactor      = "Cat6",
                Transformation      = "None",
                Variance            = false
            };

            return(model);
        }
示例#2
0
        public async Task SS19()
        {
            string testName = "SS19";

            //Arrange
            HttpClient client = _factory.CreateClient();

            SummaryStatisticsModel model = new SummaryStatisticsModel();

            model.DatasetID              = _factory.SheetNames.Single(x => x.Value == "Summary Statistics").Key;
            model.Responses              = new string[] { "Resp1" };
            model.Mean                   = false;
            model.N                      = false;
            model.StandardDeviation      = false;
            model.Variance               = false;
            model.StandardErrorOfMean    = false;
            model.MinAndMax              = false;
            model.MedianAndQuartiles     = false;
            model.CoefficientOfVariation = false;
            model.NormalProbabilityPlot  = false;
            model.CoefficientOfVariation = false;
            model.ByCategoriesAndOverall = false;
            model.ConfidenceInterval     = true;

            //Act
            HttpResponseMessage response = await client.PostAsync("Analyses/SummaryStatistics", new FormUrlEncodedContent(model.ToKeyValue()));

            IEnumerable <string> errors = await Helpers.ExtractErrors(response);

            //Assert
            Assert.Contains("You have not selected anything to output!", errors);
            Helpers.SaveOutput("SummaryStatistics", testName, errors);
        }
示例#3
0
        public async Task SS22()
        {
            string testName = "SS22";

            //Arrange
            HttpClient client = _factory.CreateClient();

            SummaryStatisticsModel model = new SummaryStatisticsModel();

            model.DatasetID      = _factory.SheetNames.Single(x => x.Value == "Summary Statistics").Key;
            model.Responses      = new string[] { "Resp 2", "Resp8", "Resp9" };
            model.Transformation = "Log10";
            model.Mean           = true;
            model.N = true;
            model.StandardDeviation      = true;
            model.Variance               = true;
            model.StandardErrorOfMean    = true;
            model.MinAndMax              = true;
            model.MedianAndQuartiles     = true;
            model.CoefficientOfVariation = true;
            model.NormalProbabilityPlot  = true;
            model.CoefficientOfVariation = true;
            model.ByCategoriesAndOverall = true;
            model.ConfidenceInterval     = true;

            //Act
            StatsOutput statsOutput = await Helpers.SubmitAnalysis(client, "SummaryStatistics", new FormUrlEncodedContent(model.ToKeyValue()));

            Helpers.SaveTestOutput("SummaryStatistics", model, testName, statsOutput);

            //Assert
            string expectedHtml = File.ReadAllText(Path.Combine("ExpectedResults", "SummaryStatistics", testName + ".html"));

            Assert.Equal(Helpers.RemoveAllImageNodes(expectedHtml), Helpers.RemoveAllImageNodes(statsOutput.HtmlResults));
        }
示例#4
0
        public void ScriptFileName_ReturnsCorrectString()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            SummaryStatisticsModel sut = new SummaryStatisticsModel();

            //Act
            string result = sut.ScriptFileName;

            //Assert
            Assert.Equal("SummaryStatistics", result);
        }
示例#5
0
        public void GetCommandLineArguments_ReturnsCorrectString()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            SummaryStatisticsModel sut = GetModel(GetDataset());

            //Act
            string result = sut.GetCommandLineArguments();

            //Assert
            Assert.Equal("Respivs_sp_ivs2,Resp8 None Cat4 Cat5 Cat6 Cat456 Y Y Y N N N N N Y 95 N N", result);
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            SummaryStatisticsModel model = (SummaryStatisticsModel)validationContext.ObjectInstance;

            if (model.Significance < 1 || model.Significance > 100)
            {
                return(new ValidationResult("You have selected a confidence limit that is less than 1. Note that this value should be entered as a percentage and not a fraction."));
            }
            else
            {
                return(ValidationResult.Success);
            }
        }
示例#7
0
        public async Task SS28()
        {
            string testName = "SS28";

            //Arrange
            HttpClient client = _factory.CreateClient();

            SummaryStatisticsModel model = new SummaryStatisticsModel();

            model.DatasetID      = _factory.SheetNames.Single(x => x.Value == "Summary Statistics").Key;
            model.Responses      = new string[] { "Resp 2", "Resp3", "Resp6" };
            model.FirstCatFactor = "Cat6";
            model.Transformation = "ArcSine";
            model.Mean           = true;
            model.N = true;
            model.StandardDeviation      = true;
            model.Variance               = true;
            model.StandardErrorOfMean    = true;
            model.MinAndMax              = true;
            model.MedianAndQuartiles     = true;
            model.CoefficientOfVariation = true;
            model.NormalProbabilityPlot  = true;
            model.CoefficientOfVariation = true;
            model.ByCategoriesAndOverall = true;
            model.ConfidenceInterval     = true;
            model.Significance           = 95;

            //Act
            HttpResponseMessage response = await client.PostAsync("Analyses/SummaryStatistics", new FormUrlEncodedContent(model.ToKeyValue()));

            IEnumerable <string> warnings = await Helpers.ExtractWarnings(response);

            //Assert
            Assert.Contains("You have ArcSine transformed the Resp3 variable. Unfortunately some of the Resp3 values are <0 or >1. These values have been ignored in the analysis as it is not possible to transform them.", warnings);
            Helpers.SaveOutput("SummaryStatistics", testName, warnings);

            //Act - ignore warnings
            var modelIgnoreWarnings = model.ToKeyValue();

            modelIgnoreWarnings.Add("ignoreWarnings", "true");
            StatsOutput statsOutput = await Helpers.SubmitAnalysis(client, "SummaryStatistics", new FormUrlEncodedContent(modelIgnoreWarnings));

            Helpers.SaveTestOutput("SummaryStatistics", model, testName, statsOutput);

            //Assert
            string expectedHtml = File.ReadAllText(Path.Combine("ExpectedResults", "SummaryStatistics", testName + ".html"));

            Assert.Equal(Helpers.RemoveAllImageNodes(expectedHtml), Helpers.RemoveAllImageNodes(statsOutput.HtmlResults));
        }
示例#8
0
        public void TransformationsList_ReturnsCorrectList()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            SummaryStatisticsModel sut = new SummaryStatisticsModel();

            //Act
            IEnumerable <string> result = sut.TransformationsList;

            //Assert
            Assert.IsAssignableFrom <IEnumerable <string> >(result);
            Assert.Equal(new List <string>()
            {
                "None", "Log10", "Loge", "Square Root", "ArcSine"
            }, result);
        }
示例#9
0
        public async Task SS10()
        {
            string testName = "SS10";

            //Arrange
            HttpClient client = _factory.CreateClient();

            SummaryStatisticsModel model = new SummaryStatisticsModel();

            model.DatasetID = _factory.SheetNames.Single(x => x.Value == "Summary Statistics").Key;
            model.Responses = new string[] { "Resp1", "Resp 2" };

            //Act
            HttpResponseMessage response = await client.PostAsync("Analyses/SummaryStatistics", new FormUrlEncodedContent(model.ToKeyValue()));

            IEnumerable <string> errors = await Helpers.ExtractErrors(response);

            //Assert
            Assert.Contains("The Response (Resp1) contains non-numeric data that cannot be processed. Please check the data and make sure it was entered correctly.", errors);
            Helpers.SaveOutput("SummaryStatistics", testName, errors);
        }
示例#10
0
        public async Task SS2()
        {
            string testName = "SS2";

            //Arrange
            HttpClient client = _factory.CreateClient();

            SummaryStatisticsModel model = new SummaryStatisticsModel();

            model.DatasetID      = _factory.SheetNames.Single(x => x.Value == "Summary Statistics").Key;
            model.Responses      = new string[] { "Resp 2" };
            model.FirstCatFactor = "Cat1";

            //Act
            HttpResponseMessage response = await client.PostAsync("Analyses/SummaryStatistics", new FormUrlEncodedContent(model.ToKeyValue()));

            IEnumerable <string> errors = await Helpers.ExtractErrors(response);

            //Assert
            Assert.Contains("The categorisation factor (Cat1) contains missing data where there are observations present in the Response. Please check the input data and make sure the data was entered correctly.", errors);
            Helpers.SaveOutput("SummaryStatistics", testName, errors);
        }
示例#11
0
        public async Task SS17()
        {
            string testName = "SS17";

            //Arrange
            HttpClient client = _factory.CreateClient();

            SummaryStatisticsModel model = new SummaryStatisticsModel();

            model.DatasetID      = _factory.SheetNames.Single(x => x.Value == "Summary Statistics").Key;
            model.Responses      = new string[] { "Resp4", "Resp 2" };
            model.Transformation = "Loge";

            //Act
            HttpResponseMessage response = await client.PostAsync("Analyses/SummaryStatistics", new FormUrlEncodedContent(model.ToKeyValue()));

            IEnumerable <string> warnings = await Helpers.ExtractWarnings(response);

            //Assert
            Assert.Contains("You have Loge transformed the Resp4 variable. Unfortunately some of the Resp4 values are zero and/or negative. These values have been ignored in the analysis as it is not possible to transform them.", warnings);
            Helpers.SaveOutput("SummaryStatistics", testName, warnings);
        }
示例#12
0
        public async Task SS14()
        {
            string testName = "SS14";

            //Arrange
            HttpClient client = _factory.CreateClient();

            SummaryStatisticsModel model = new SummaryStatisticsModel();

            model.DatasetID    = _factory.SheetNames.Single(x => x.Value == "Summary Statistics").Key;
            model.Responses    = new string[] { "Resp 2" };
            model.Significance = 0;

            //Act
            HttpResponseMessage response = await client.PostAsync("Analyses/SummaryStatistics", new FormUrlEncodedContent(model.ToKeyValue()));

            IEnumerable <string> errors = await Helpers.ExtractErrors(response);

            //Assert
            Assert.Contains("You have selected a confidence limit that is less than 1. Note that this value should be entered as a percentage and not a fraction.", errors);
            Helpers.SaveOutput("SummaryStatistics", testName, errors);
        }
示例#13
0
        public void ExportData_ReturnsCorrectStringArray()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Mock <IDataset> mockDataset = new Mock <IDataset>();

            mockDataset.Setup(x => x.DatasetID).Returns(It.IsAny <int>);
            mockDataset.Setup(x => x.DatasetToDataTable()).Returns(GetTestDataTable());

            SummaryStatisticsModel sut = GetModel(mockDataset.Object);

            //Act
            string[] result = sut.ExportData();

            //Assert
            Assert.Equal("Respivs_sp_ivs2,Resp8,Cat4,Cat5,Cat6,Cat456,catfact", result[0]);
            Assert.Equal(34, result.Count());
            Assert.StartsWith("0.939350659,0.90541248", result[33]);

            //catfactor check
            Assert.EndsWith("A 2 2 A_ 2_ 2", result[33]);
        }
示例#14
0
        public async Task SS4()
        {
            string testName = "SS4";

            //Arrange
            HttpClient client = _factory.CreateClient();

            SummaryStatisticsModel model = new SummaryStatisticsModel();

            model.DatasetID      = _factory.SheetNames.Single(x => x.Value == "Summary Statistics").Key;
            model.Responses      = new string[] { "Resp 2" };
            model.FirstCatFactor = "Cat3";

            //Act
            HttpResponseMessage response = await client.PostAsync("Analyses/SummaryStatistics", new FormUrlEncodedContent(model.ToKeyValue()));

            IEnumerable <string> errors = await Helpers.ExtractErrors(response);

            //Assert
            Assert.Contains("There are no observations recorded on the levels of the categorisation factor (Cat3). Please amend the dataset prior to running the analysis.", errors);
            Helpers.SaveOutput("SummaryStatistics", testName, errors);
        }
示例#15
0
        public async Task SS20()
        {
            string testName = "SS20";

            //Arrange
            HttpClient client = _factory.CreateClient();

            SummaryStatisticsModel model = new SummaryStatisticsModel();

            model.DatasetID      = _factory.SheetNames.Single(x => x.Value == "Summary Statistics").Key;
            model.Responses      = new string[] { "Resp 2", "Resp10" };
            model.FirstCatFactor = "Cat4";

            //Act
            HttpResponseMessage response = await client.PostAsync("Analyses/SummaryStatistics", new FormUrlEncodedContent(model.ToKeyValue()));

            IEnumerable <string> warnings = await Helpers.ExtractWarnings(response);

            //Assert
            Assert.Contains("The Response (Resp10) contains missing data. Any rows of the dataset that contain missing responses will be excluded prior to the analysis.", warnings);
            Helpers.SaveOutput("SummaryStatistics", testName, warnings);
        }
示例#16
0
        public async Task SS12()
        {
            string testName = "SS12";

            //Arrange
            HttpClient client = _factory.CreateClient();

            SummaryStatisticsModel model = new SummaryStatisticsModel();

            model.DatasetID       = _factory.SheetNames.Single(x => x.Value == "Summary Statistics").Key;
            model.Responses       = new string[] { "Resp 2" };
            model.FirstCatFactor  = "Cat2";
            model.SecondCatFactor = "Cat4";

            //Act
            HttpResponseMessage response = await client.PostAsync("Analyses/SummaryStatistics", new FormUrlEncodedContent(model.ToKeyValue()));

            IEnumerable <string> errors = await Helpers.ExtractErrors(response);

            //Assert
            Assert.Contains("There is no replication in one or more of the levels of the categorisation factor (Cat2). Please select another factor.", errors);
            Helpers.SaveOutput("SummaryStatistics", testName, errors);
        }
 public SummaryStatisticsValidator(SummaryStatisticsModel ss)
     : base(ss.DataTable)
 {
     ssVariables = ss;
 }
示例#18
0
        public void GetArguments_ReturnsCorrectArguments()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            SummaryStatisticsModel sut = GetModel(GetDataset());

            //Act
            List <Argument> result = sut.GetArguments().ToList();

            //Assert
            var responses = result.Single(x => x.Name == "Responses");

            Assert.Equal("Resp 2,Resp8", responses.Value);

            var firstCatFactor = result.Single(x => x.Name == "FirstCatFactor");

            Assert.Equal("Cat4", firstCatFactor.Value);

            var secondCatFactor = result.Single(x => x.Name == "SecondCatFactor");

            Assert.Equal("Cat5", secondCatFactor.Value);

            var thirdCatFactor = result.Single(x => x.Name == "ThirdCatFactor");

            Assert.Equal("Cat6", thirdCatFactor.Value);

            var fourthCatFactor = result.Single(x => x.Name == "FourthCatFactor");

            Assert.Equal("Cat456", fourthCatFactor.Value);

            var mean = result.Single(x => x.Name == "Mean");

            Assert.Equal("True", mean.Value);

            var n = result.Single(x => x.Name == "N");

            Assert.Equal("True", n.Value);

            var medianAndQuartiles = result.Single(x => x.Name == "MedianAndQuartiles");

            Assert.Equal("False", medianAndQuartiles.Value);

            var minAndMax = result.Single(x => x.Name == "MinAndMax");

            Assert.Equal("False", minAndMax.Value);

            var normalProbabilityPlot = result.Single(x => x.Name == "NormalProbabilityPlot");

            Assert.Equal("False", normalProbabilityPlot.Value);

            var significance = result.Single(x => x.Name == "Significance");

            Assert.Equal("95", significance.Value);

            var standardDeviation = result.Single(x => x.Name == "StandardDeviation");

            Assert.Equal("True", standardDeviation.Value);

            var standardErrorOfMean = result.Single(x => x.Name == "StandardErrorOfMean");

            Assert.Equal("False", standardErrorOfMean.Value);

            var transformation = result.Single(x => x.Name == "Transformation");

            Assert.Equal("None", transformation.Value);

            var variance = result.Single(x => x.Name == "Variance");

            Assert.Equal("False", variance.Value);

            var coefficientOfVariation = result.Single(x => x.Name == "CoefficientOfVariation");

            Assert.Equal("False", coefficientOfVariation.Value);

            var confidenceInterval = result.Single(x => x.Name == "ConfidenceInterval");

            Assert.Equal("True", confidenceInterval.Value);

            var byCategoriesAndOverall = result.Single(x => x.Name == "ByCategoriesAndOverall");

            Assert.Equal("False", byCategoriesAndOverall.Value);
        }
示例#19
0
        public void LoadArguments_ReturnsCorrectArguments()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            SummaryStatisticsModel sut = new SummaryStatisticsModel(GetDataset());

            List <Argument> arguments = new List <Argument>();

            arguments.Add(new Argument {
                Name = "Responses", Value = "Resp1,Resp 2"
            });
            arguments.Add(new Argument {
                Name = "FirstCatFactor", Value = "Cat1"
            });
            arguments.Add(new Argument {
                Name = "SecondCatFactor", Value = "Cat2"
            });
            arguments.Add(new Argument {
                Name = "ThirdCatFactor", Value = "Cat3"
            });
            arguments.Add(new Argument {
                Name = "FourthCatFactor", Value = "Cat4"
            });
            arguments.Add(new Argument {
                Name = "Transformation", Value = "Log10"
            });
            arguments.Add(new Argument {
                Name = "ByCategoriesAndOverall", Value = "True"
            });
            arguments.Add(new Argument {
                Name = "CoefficientOfVariation", Value = "False"
            });
            arguments.Add(new Argument {
                Name = "ConfidenceInterval", Value = "True"
            });
            arguments.Add(new Argument {
                Name = "Mean", Value = "False"
            });
            arguments.Add(new Argument {
                Name = "MedianAndQuartiles", Value = "True"
            });
            arguments.Add(new Argument {
                Name = "MinAndMax", Value = "False"
            });
            arguments.Add(new Argument {
                Name = "N", Value = "True"
            });
            arguments.Add(new Argument {
                Name = "NormalProbabilityPlot", Value = "False"
            });
            arguments.Add(new Argument {
                Name = "Significance", Value = "90"
            });
            arguments.Add(new Argument {
                Name = "StandardDeviation", Value = "True"
            });
            arguments.Add(new Argument {
                Name = "StandardErrorOfMean", Value = "False"
            });
            arguments.Add(new Argument {
                Name = "Variance", Value = "True"
            });

            Assert.Equal(18, arguments.Count);

            //Act
            sut.LoadArguments(arguments);

            //Assert
            Assert.Equal(new List <string>()
            {
                "Resp1", "Resp 2"
            }, sut.Responses);
            Assert.Equal("Cat1", sut.FirstCatFactor);
            Assert.Equal("Cat2", sut.SecondCatFactor);
            Assert.Equal("Cat3", sut.ThirdCatFactor);
            Assert.Equal("Cat4", sut.FourthCatFactor);
            Assert.Equal("Log10", sut.Transformation);
            Assert.True(sut.ByCategoriesAndOverall);
            Assert.False(sut.CoefficientOfVariation);
            Assert.True(sut.ConfidenceInterval);
            Assert.False(sut.Mean);
            Assert.True(sut.MedianAndQuartiles);
            Assert.False(sut.MinAndMax);
            Assert.True(sut.N);
            Assert.False(sut.NormalProbabilityPlot);
            Assert.Equal(90, sut.Significance);
            Assert.True(sut.StandardDeviation);
            Assert.False(sut.StandardErrorOfMean);
            Assert.True(sut.Variance);
        }
 public async Task <IActionResult> SummaryStatistics(SummaryStatisticsModel model, bool ignoreWarnings)
 {
     return(await RunAnalysis(model, ignoreWarnings));
 }