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

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

            SurvivalAnalysisModel model = new SurvivalAnalysisModel();

            model.DatasetID             = _factory.SheetNames.Single(x => x.Value == "Survival").Key;
            model.Response              = "Resp4";
            model.Treatment             = "Group 8";
            model.Censorship            = "Censor9";
            model.CompareSurvivalCurves = true;

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

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

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

            Assert.Equal(Helpers.RemoveAllImageNodes(expectedHtml), Helpers.RemoveAllImageNodes(statsOutput.HtmlResults));
        }
예제 #2
0
        public void GetCommandLineArguments_ReturnsCorrectString()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            SurvivalAnalysisModel sut = GetModel(GetDataset());

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

            //Assert
            Assert.Equal("Resp2 Groupivs_sp_ivs1 Censor1 Y Y N 0.05", result);
        }
예제 #3
0
        public void ScriptFileName_ReturnsCorrectString()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            SurvivalAnalysisModel sut = new SurvivalAnalysisModel();

            //Act
            string result = sut.ScriptFileName;

            //Assert
            Assert.Equal("SurvivalAnalysis", result);
        }
예제 #4
0
        private SurvivalAnalysisModel GetModel(IDataset dataset)
        {
            var model = new SurvivalAnalysisModel(dataset)
            {
                Censorship            = "Censor1",
                CompareSurvivalCurves = false,
                Response       = "Resp2",
                Significance   = "0.05",
                SummaryResults = true,
                SurvivalPlot   = true,
                Treatment      = "Group 1"
            };

            return(model);
        }
예제 #5
0
        public void SignificancesList_ReturnsCorrectList()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            SurvivalAnalysisModel sut = new SurvivalAnalysisModel();

            //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);
        }
예제 #6
0
        public void LoadArguments_ReturnsCorrectArguments()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            SurvivalAnalysisModel sut = new SurvivalAnalysisModel(GetDataset());

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

            arguments.Add(new Argument {
                Name = "Censorship", Value = "Censor1"
            });
            arguments.Add(new Argument {
                Name = "CompareSurvivalCurves", Value = "False"
            });
            arguments.Add(new Argument {
                Name = "Response", Value = "Resp2"
            });
            arguments.Add(new Argument {
                Name = "Significance", Value = "0.05"
            });
            arguments.Add(new Argument {
                Name = "SummaryResults", Value = "True"
            });
            arguments.Add(new Argument {
                Name = "SurvivalPlot", Value = "True"
            });
            arguments.Add(new Argument {
                Name = "Treatment", Value = "Group 1"
            });

            Assert.Equal(7, arguments.Count);

            //Act
            sut.LoadArguments(arguments);

            //Assert
            Assert.Equal("Censor1", sut.Censorship);
            Assert.False(sut.CompareSurvivalCurves);
            Assert.Equal("Resp2", sut.Response);
            Assert.Equal("0.05", sut.Significance);
            Assert.True(sut.SummaryResults);
            Assert.True(sut.SurvivalPlot);
            Assert.Equal("Group 1", sut.Treatment);
        }
예제 #7
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());

            SurvivalAnalysisModel sut = GetModel(mockDataset.Object);

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

            //Assert
            Assert.Equal("Resp2,Censor1,Groupivs_sp_ivs1", result[0]);
            Assert.Equal(12, result.Count()); //as blank reponses are removed
            Assert.Equal("5,0,A", result[3]);
        }
예제 #8
0
        public void GetArguments_ReturnsCorrectArguments()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            SurvivalAnalysisModel sut = GetModel(GetDataset());

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

            //Assert
            var censorship = result.Single(x => x.Name == "Censorship");

            Assert.Equal("Censor1", censorship.Value);

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

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

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

            Assert.Equal("Resp2", response.Value);

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

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

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

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

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

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

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

            Assert.Equal("Group 1", treatment.Value);
        }
        public async Task SURV4()
        {
            string testName = "SURV4";

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

            SurvivalAnalysisModel model = new SurvivalAnalysisModel();

            model.DatasetID  = _factory.SheetNames.Single(x => x.Value == "Survival").Key;
            model.Response   = "Resp2";
            model.Treatment  = "Group 3";
            model.Censorship = "Censor1";

            //Act
            HttpResponseMessage response = await client.PostAsync("Analyses/SurvivalAnalysis", 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 Treatment factor (Group 3). Please select another factor.", errors);
            Helpers.SaveOutput("SurvivalAnalysis", testName, errors);
        }
        public async Task SURV2()
        {
            string testName = "SURV2";

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

            SurvivalAnalysisModel model = new SurvivalAnalysisModel();

            model.DatasetID  = _factory.SheetNames.Single(x => x.Value == "Survival").Key;
            model.Response   = "Resp2";
            model.Treatment  = "Group 1";
            model.Censorship = "Censor2";

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

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

            //Assert
            Assert.Contains("The Censorship variable contains values other than 0 and 1. Please amend the dataset prior to running the analysis.", errors);
            Helpers.SaveOutput("SurvivalAnalysis", testName, errors);
        }
        public async Task SURV10()
        {
            string testName = "SURV10";

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

            SurvivalAnalysisModel model = new SurvivalAnalysisModel();

            model.DatasetID             = _factory.SheetNames.Single(x => x.Value == "Survival").Key;
            model.Treatment             = "Group 1";
            model.Censorship            = "Censor1";
            model.CompareSurvivalCurves = true;

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

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

            //Assert
            Assert.Contains("The Response field is required.", errors);
            Helpers.SaveOutput("SurvivalAnalysis", testName, errors);
        }
        public async Task SURV1()
        {
            string testName = "SURV1";

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

            SurvivalAnalysisModel model = new SurvivalAnalysisModel();

            model.DatasetID  = _factory.SheetNames.Single(x => x.Value == "Survival").Key;
            model.Response   = "Resp 1";
            model.Treatment  = "Group 1";
            model.Censorship = "Censor1";

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

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

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

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

            SurvivalAnalysisModel model = new SurvivalAnalysisModel();

            model.DatasetID             = _factory.SheetNames.Single(x => x.Value == "Survival").Key;
            model.Response              = "Resp3";
            model.Treatment             = "Group 1";
            model.Censorship            = "Censor1";
            model.CompareSurvivalCurves = true;

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

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

            //Assert
            Assert.Contains("The Response (Resp3) contains missing data. Any rows of the dataset that contain missing responses will be excluded prior to the analysis.", warnings);
            Helpers.SaveOutput("SurvivalAnalysis", testName, warnings);

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

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

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

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

            Assert.Equal(Helpers.RemoveAllImageNodes(expectedHtml), Helpers.RemoveAllImageNodes(statsOutput.HtmlResults));
        }
 public async Task <IActionResult> SurvivalAnalysis(SurvivalAnalysisModel model, bool ignoreWarnings)
 {
     return(await RunAnalysis(model, ignoreWarnings));
 }
예제 #15
0
 public SurvivalAnalysisValidator(SurvivalAnalysisModel sam)
     : base(sam.DataTable)
 {
     samVariables = sam;
 }