public async Task UPTT21() { string testName = "UPTT21"; //Arrange HttpClient client = _factory.CreateClient(); UnpairedTTestAnalysisModel model = new UnpairedTTestAnalysisModel(); model.DatasetID = _factory.SheetNames.Single(x => x.Value == "Unpaired t-test").Key; model.Response = "PVTestresponse2"; model.ResponseTransformation = "None"; model.Treatment = "PVTestgroup"; model.NormalProbabilityPlotSelected = true; model.ResidualsVsPredictedPlotSelected = true; //Act StatsOutput statsOutput = await Helpers.SubmitAnalysis(client, "UnpairedTTestAnalysis", new FormUrlEncodedContent(model.ToKeyValue())); Helpers.SaveTestOutput("UnpairedTTestAnalysis", model, testName, statsOutput); //Assert string expectedHtml = File.ReadAllText(Path.Combine("ExpectedResults", "UnpairedTTestAnalysis", testName + ".html")); Assert.Equal(Helpers.RemoveAllImageNodes(expectedHtml), Helpers.RemoveAllImageNodes(statsOutput.HtmlResults)); }
public async Task UPTT13() { string testName = "UPTT13"; //Arrange HttpClient client = _factory.CreateClient(); UnpairedTTestAnalysisModel model = new UnpairedTTestAnalysisModel(); model.DatasetID = _factory.SheetNames.Single(x => x.Value == "Unpaired t-test").Key; model.Response = "Resp 1"; model.ResponseTransformation = "None"; model.Treatment = "Treat(5"; model.NormalProbabilityPlotSelected = true; model.ResidualsVsPredictedPlotSelected = true; //Act HttpResponseMessage response = await client.PostAsync("Analyses/UnpairedTTestAnalysis", new FormUrlEncodedContent(model.ToKeyValue())); IEnumerable <string> errors = await Helpers.ExtractErrors(response); //Assert Assert.Contains("The treatment (Treat(5) has more than two levels, please analyse using Single Measure Parametric Analysis module.", errors); Helpers.SaveOutput("UnpairedTTestAnalysis", testName, errors); }
public async Task UPTT11() { string testName = "UPTT11"; //Arrange HttpClient client = _factory.CreateClient(); UnpairedTTestAnalysisModel model = new UnpairedTTestAnalysisModel(); model.DatasetID = _factory.SheetNames.Single(x => x.Value == "Unpaired t-test").Key; model.Response = "Resp 7"; model.ResponseTransformation = "ArcSine"; model.Treatment = "Treat1"; model.NormalProbabilityPlotSelected = true; model.ResidualsVsPredictedPlotSelected = true; //Act HttpResponseMessage response = await client.PostAsync("Analyses/UnpairedTTestAnalysis", new FormUrlEncodedContent(model.ToKeyValue())); IEnumerable <string> warnings = await Helpers.ExtractWarnings(response); //Assert Assert.Contains("You have ArcSine transformed the Resp 7 variable. Unfortunately some of the Resp 7 values are <0 or >1. These values have been ignored in the analysis as it is not possible to transform them.", warnings); Helpers.SaveOutput("UnpairedTTestAnalysis", testName, warnings); }
public void GetCommandLineArguments_ReturnsCorrectString() { //Arrange System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; UnpairedTTestAnalysisModel sut = GetModel(GetDataset()); //Act string result = sut.GetCommandLineArguments(); //Assert Assert.Equal("Respivs_sp_ivs1 None Treat1 Y Y N N B 0.05", result); }
public void ScriptFileName_ReturnsCorrectString() { //Arrange System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; UnpairedTTestAnalysisModel sut = new UnpairedTTestAnalysisModel(); //Act string result = sut.ScriptFileName; //Assert Assert.Equal("UnpairedTTestAnalysis", result); }
public void LoadArguments_ReturnsCorrectArguments() { //Arrange System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; UnpairedTTestAnalysisModel sut = new UnpairedTTestAnalysisModel(GetDataset()); List <Argument> arguments = new List <Argument>(); arguments.Add(new Argument { Name = "Response", Value = "Resp 1" }); arguments.Add(new Argument { Name = "Treatment", Value = "Treat1" }); arguments.Add(new Argument { Name = "ResponseTransformation", Value = "Log10" }); arguments.Add(new Argument { Name = "NormalProbabilityPlotSelected", Value = "False" }); arguments.Add(new Argument { Name = "ResidualsVsPredictedPlotSelected", Value = "True" }); arguments.Add(new Argument { Name = "UnequalVarianceCaseSelected", Value = "False" }); arguments.Add(new Argument { Name = "EqualVarianceCaseSelected", Value = "True" }); arguments.Add(new Argument { Name = "Significance", Value = "0.05" }); arguments.Add(new Argument { Name = "ControlGroup", Value = "B" }); //Act sut.LoadArguments(arguments); //Assert Assert.Equal("Resp 1", sut.Response); Assert.Equal("Treat1", sut.Treatment); Assert.Equal("Log10", sut.ResponseTransformation); Assert.False(sut.NormalProbabilityPlotSelected); Assert.True(sut.ResidualsVsPredictedPlotSelected); Assert.False(sut.UnequalVarianceCaseSelected); Assert.True(sut.EqualVarianceCaseSelected); Assert.Equal("0.05", sut.Significance); Assert.Equal("B", sut.ControlGroup); }
public void SignificancesList_ReturnsCorrectList() { //Arrange System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; UnpairedTTestAnalysisModel sut = new UnpairedTTestAnalysisModel(); //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); }
public void TransformationsList_ReturnsCorrectList() { //Arrange System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; UnpairedTTestAnalysisModel sut = new UnpairedTTestAnalysisModel(); //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); }
public void GetArguments_ReturnsCorrectArguments() { //Arrange System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; UnpairedTTestAnalysisModel sut = GetModel(GetDataset()); //Act List <Argument> result = sut.GetArguments().ToList(); //Assert var response = result.Single(x => x.Name == "Response"); Assert.Equal("Resp 1", response.Value); var treatment = result.Single(x => x.Name == "Treatment"); Assert.Equal("Treat1", treatment.Value); var responseTransformation = result.Single(x => x.Name == "ResponseTransformation"); Assert.Equal("None", responseTransformation.Value); var equalVarianceCaseSelected = result.Single(x => x.Name == "EqualVarianceCaseSelected"); Assert.Equal("True", equalVarianceCaseSelected.Value); var normalProbabilityPlotSelected = result.Single(x => x.Name == "NormalProbabilityPlotSelected"); Assert.Equal("False", normalProbabilityPlotSelected.Value); var residualsVsPredictedPlotSelected = result.Single(x => x.Name == "ResidualsVsPredictedPlotSelected"); Assert.Equal("False", residualsVsPredictedPlotSelected.Value); var unequalVarianceCaseSelected = result.Single(x => x.Name == "UnequalVarianceCaseSelected"); Assert.Equal("True", unequalVarianceCaseSelected.Value); var significance = result.Single(x => x.Name == "Significance"); Assert.Equal("0.05", significance.Value); var controlGroup = result.Single(x => x.Name == "ControlGroup"); Assert.Equal("B", controlGroup.Value); }
private UnpairedTTestAnalysisModel GetModel(IDataset dataset) { var model = new UnpairedTTestAnalysisModel(dataset) { ControlGroup = "B", EqualVarianceCaseSelected = true, NormalProbabilityPlotSelected = false, ResidualsVsPredictedPlotSelected = false, Response = "Resp 1", ResponseTransformation = "None", Significance = "0.05", Treatment = "Treat1", UnequalVarianceCaseSelected = true }; return(model); }
public void ExportData_ReturnsCorrectStringArray() { //Arrange System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Mock <IDataset> mockDataset = new Mock <IDataset>(); mockDataset.Setup(x => x.DatasetID).Returns(1); mockDataset.Setup(x => x.DatasetToDataTable()).Returns(GetTestDataTable()); UnpairedTTestAnalysisModel sut = GetModel(mockDataset.Object); //Act string[] result = sut.ExportData(); //Assert Assert.Equal("Respivs_sp_ivs1,Treat1", result[0]); Assert.Equal(13, result.Count()); //as blank reponses are removed Assert.StartsWith("234,B", result[12]); }
public async Task UPTT6() { string testName = "UPTT6"; //Arrange HttpClient client = _factory.CreateClient(); UnpairedTTestAnalysisModel model = new UnpairedTTestAnalysisModel(); model.DatasetID = _factory.SheetNames.Single(x => x.Value == "Unpaired t-test").Key; model.Response = "Resp 5"; model.Treatment = "Treat1"; model.NormalProbabilityPlotSelected = true; model.ResidualsVsPredictedPlotSelected = true; //Act HttpResponseMessage response = await client.PostAsync("Analyses/UnpairedTTestAnalysis", new FormUrlEncodedContent(model.ToKeyValue())); IEnumerable <string> warnings = await Helpers.ExtractWarnings(response); //Assert Assert.Contains("The Response (Resp 5) contains missing data. Any rows of the dataset that contain missing responses will be excluded prior to the analysis.", warnings); Helpers.SaveOutput("UnpairedTTestAnalysis", testName, warnings); }
public async Task UPTT3() { string testName = "UPTT3"; //Arrange HttpClient client = _factory.CreateClient(); UnpairedTTestAnalysisModel model = new UnpairedTTestAnalysisModel(); model.DatasetID = _factory.SheetNames.Single(x => x.Value == "Unpaired t-test").Key; model.Response = "Resp 3"; model.Treatment = "Treat1"; model.NormalProbabilityPlotSelected = true; model.ResidualsVsPredictedPlotSelected = true; //Act HttpResponseMessage response = await client.PostAsync("Analyses/UnpairedTTestAnalysis", new FormUrlEncodedContent(model.ToKeyValue())); IEnumerable <string> errors = await Helpers.ExtractErrors(response); //Assert Assert.Contains("There are no observations recorded on the levels of the Treatment factor (Treat1). Please amend the dataset prior to running the analysis.", errors); Helpers.SaveOutput("UnpairedTTestAnalysis", testName, errors); }
public async Task UPTT1() { string testName = "UPTT1"; //Arrange HttpClient client = _factory.CreateClient(); UnpairedTTestAnalysisModel model = new UnpairedTTestAnalysisModel(); model.DatasetID = _factory.SheetNames.Single(x => x.Value == "Unpaired t-test").Key; model.Response = "Resp 1"; model.Treatment = null; model.NormalProbabilityPlotSelected = true; model.ResidualsVsPredictedPlotSelected = true; //Act HttpResponseMessage response = await client.PostAsync("Analyses/UnpairedTTestAnalysis", new FormUrlEncodedContent(model.ToKeyValue())); IEnumerable <string> errors = await Helpers.ExtractErrors(response); //Assert Assert.Contains("The Treatment factor field is required.", errors); Helpers.SaveOutput("UnpairedTTestAnalysis", testName, errors); }
public async Task UPTT4() { string testName = "UPTT4"; //Arrange HttpClient client = _factory.CreateClient(); UnpairedTTestAnalysisModel model = new UnpairedTTestAnalysisModel(); model.DatasetID = _factory.SheetNames.Single(x => x.Value == "Unpaired t-test").Key; model.Response = "Resp 1"; model.Treatment = "Treat2"; model.NormalProbabilityPlotSelected = true; model.ResidualsVsPredictedPlotSelected = true; //Act HttpResponseMessage response = await client.PostAsync("Analyses/UnpairedTTestAnalysis", new FormUrlEncodedContent(model.ToKeyValue())); IEnumerable <string> errors = await Helpers.ExtractErrors(response); //Assert Assert.Contains("The Treatment factor (Treat2) 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("UnpairedTTestAnalysis", testName, errors); }
public async Task <IActionResult> UnpairedTTestAnalysis(UnpairedTTestAnalysisModel model, bool ignoreWarnings) { return(await RunAnalysis(model, ignoreWarnings)); }
public UnpairedTTestAnalysisValidator(UnpairedTTestAnalysisModel uptt) : base(uptt.DataTable) { upttVariables = uptt; }