public async Task OSTT17()
        {
            string testName = "OSTT17";

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

            OneSampleTTestAnalysisModel model = new OneSampleTTestAnalysisModel();

            model.DatasetID = _factory.SheetNames.Single(x => x.Value == "One Sample t-test").Key;
            model.Responses = new string[] { "Resp 1", "Resp2", "Resp 3", "Resp4" };
            model.ResponseTransformation = "None";
            model.Significance           = "0.05";
            model.TargetValue            = 1m;

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

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

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

            Assert.Equal(Helpers.FixForUnixOSs(expectedHtml), Helpers.FixForUnixOSs(statsOutput.HtmlResults));
        }
Beispiel #2
0
        public void GetArguments_ReturnsCorrectArguments()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            OneSampleTTestAnalysisModel sut = GetModel(GetDataset());

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

            //Assert
            var normalPlot = result.Single(x => x.Name == "NormalPlot");

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

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

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

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

            Assert.Equal("Resp 1,Resp2", responses.Value);

            var responseTransformation = result.Single(x => x.Name == "ResponseTransformation");

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

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

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

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

            Assert.Equal("3.142", TargetValue.Value);
        }
Beispiel #3
0
        public void GetCommandLineArguments_ReturnsCorrectString()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            OneSampleTTestAnalysisModel sut = GetModel(GetDataset());

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

            //Assert
            Assert.Equal("Respivs_sp_ivs1,Resp2 None 3.142 Y N 0.05", result);
        }
Beispiel #4
0
        public void ScriptFileName_ReturnsCorrectString()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            OneSampleTTestAnalysisModel sut = new OneSampleTTestAnalysisModel();

            //Act
            string result = sut.ScriptFileName;

            //Assert
            Assert.Equal("OneSampleTTestAnalysis", result);
        }
Beispiel #5
0
        public void SignificancesList_ReturnsCorrectList()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            OneSampleTTestAnalysisModel sut = new OneSampleTTestAnalysisModel();

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

            //Assert
            Assert.IsAssignableFrom <IEnumerable <string> >(result);
            Assert.Equal(new List <string>()
            {
                "0.1", "0.05", "0.025", "0.01", "0.001"
            }, result);
        }
Beispiel #6
0
        public void TransformationsList_ReturnsCorrectList()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            OneSampleTTestAnalysisModel sut = new OneSampleTTestAnalysisModel();

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

            //Assert
            Assert.IsAssignableFrom <IEnumerable <string> >(result);
            Assert.Equal(new List <string>()
            {
                "None", "Log10", "Loge", "Square Root", "ArcSine", "Rank"
            }, result);
        }
Beispiel #7
0
        private OneSampleTTestAnalysisModel GetModel(IDataset dataset)
        {
            var model = new OneSampleTTestAnalysisModel(dataset)
            {
                NormalPlot         = false,
                ConfidenceInterval = true,
                Responses          = new List <string> {
                    "Resp 1", "Resp2"
                },
                ResponseTransformation = "None",
                Significance           = "0.05",
                TargetValue            = 3.142m
            };

            return(model);
        }
Beispiel #8
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());

            OneSampleTTestAnalysisModel sut = GetModel(mockDataset.Object);

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

            //Assert
            Assert.Equal("Respivs_sp_ivs1,Resp2", result[0]);
            Assert.Equal(13, result.Count()); //as blank reponses are removed
            Assert.Equal("543,", result[3]);
        }
Beispiel #9
0
        public void LoadArguments_ReturnsCorrectArguments()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            OneSampleTTestAnalysisModel sut = new OneSampleTTestAnalysisModel(GetDataset());

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

            arguments.Add(new Argument {
                Name = "NormalPlot", Value = "False"
            });
            arguments.Add(new Argument {
                Name = "ConfidenceInterval", Value = "True"
            });
            arguments.Add(new Argument {
                Name = "Responses", Value = "Resp 1,Resp2"
            });
            arguments.Add(new Argument {
                Name = "ResponseTransformation", Value = "None"
            });
            arguments.Add(new Argument {
                Name = "Significance", Value = "0.05"
            });
            arguments.Add(new Argument {
                Name = "TargetValue", Value = "3.142"
            });

            Assert.Equal(6, arguments.Count);

            //Act
            sut.LoadArguments(arguments);

            //Assert
            Assert.False(sut.NormalPlot);
            Assert.True(sut.ConfidenceInterval);
            Assert.Equal(new List <string> {
                "Resp 1", "Resp2"
            }, sut.Responses);
            Assert.Equal("None", sut.ResponseTransformation);
            Assert.Equal("0.05", sut.Significance);
            Assert.Equal(3.142m, sut.TargetValue);
        }
        public async Task OSTT2()
        {
            string testName = "OSTT2";

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

            OneSampleTTestAnalysisModel model = new OneSampleTTestAnalysisModel();

            model.DatasetID   = _factory.SheetNames.Single(x => x.Value == "One Sample t-test").Key;
            model.Responses   = new string[] { "Resp 6" };
            model.TargetValue = 0.1m;

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

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

            //Assert
            Assert.Contains("The Response (Resp 6) contains non-numeric data that cannot be processed. Please check the data and make sure it was entered correctly.", errors);
            Helpers.SaveOutput("OneSampleTTestAnalysis", testName, errors);
        }
        public async Task OSTT1()
        {
            string testName = "OSTT1";

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

            OneSampleTTestAnalysisModel model = new OneSampleTTestAnalysisModel();

            model.DatasetID   = _factory.SheetNames.Single(x => x.Value == "One Sample t-test").Key;
            model.Responses   = new string[] { "Resp 5" };
            model.TargetValue = 0.1m;

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

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

            //Assert
            Assert.Contains("There is no replication in the response variable (Resp 5). Please select another factor.", errors);
            Helpers.SaveOutput("OneSampleTTestAnalysis", testName, errors);
        }
        public async Task OSTT4()
        {
            string testName = "OSTT4";

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

            OneSampleTTestAnalysisModel model = new OneSampleTTestAnalysisModel();

            model.DatasetID = _factory.SheetNames.Single(x => x.Value == "One Sample t-test").Key;
            model.Responses = new string[] { "Resp 9" };
            model.ResponseTransformation = "Log10";
            model.TargetValue            = 0.1m;

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

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

            //Assert
            Assert.Contains("You have Log10 transformed the Resp 9 variable. Unfortunately some of the Resp 9 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("OneSampleTTestAnalysis", testName, warnings);
        }
 public async Task <IActionResult> OneSampleTTestAnalysis(OneSampleTTestAnalysisModel model, bool ignoreWarnings)
 {
     return(await RunAnalysis(model, ignoreWarnings));
 }
 public OneSampleTTestAnalysisValidator(OneSampleTTestAnalysisModel ostt)
     : base(ostt.DataTable)
 {
     osttVariables = ostt;
 }