Exemplo n.º 1
0
        public void GetArguments_ReturnsCorrectArguments()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            NonParametricAnalysisModel 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("Treat 1", treatment.Value);

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

            Assert.Equal("Block1", otherDesignFactor.Value);

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

            Assert.Equal("y", control.Value);

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

            Assert.Equal("MannWhitney", analysisType.Value);

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

            Assert.Equal("0.05", significance.Value);
        }
Exemplo n.º 2
0
        public void ScriptFileName_ReturnsCorrectString()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            NonParametricAnalysisModel sut = new NonParametricAnalysisModel();

            //Act
            string result = sut.ScriptFileName;

            //Assert
            Assert.Equal("NonParametricAnalysis", result);
        }
Exemplo n.º 3
0
        public void GetCommandLineArguments_ReturnsCorrectString()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            NonParametricAnalysisModel sut = GetModel(GetDataset());

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

            //Assert
            Assert.Equal("Respivs_sp_ivs1 Treativs_sp_ivs1 Block1 0.05 MannWhitney y", result);
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            NonParametricAnalysisModel model = (NonParametricAnalysisModel)validationContext.ObjectInstance;

            if (model.AnalysisType == NonParametricAnalysisModel.AnalysisOption.CompareToControl && String.IsNullOrEmpty(model.Control))
            {
                return(new ValidationResult("Control level is a required variable when comparing to control."));
            }
            else
            {
                return(ValidationResult.Success);
            }
        }
Exemplo n.º 5
0
        private NonParametricAnalysisModel GetModel(IDataset dataset)
        {
            var model = new NonParametricAnalysisModel(dataset)
            {
                AnalysisType      = NonParametricAnalysisModel.AnalysisOption.MannWhitney,
                Control           = "y",
                DatasetID         = 2,
                OtherDesignFactor = "Block1",
                Response          = "Resp 1",
                Significance      = "0.05",
                Treatment         = "Treat 1"
            };

            return(model);
        }
Exemplo n.º 6
0
        public void SignificancesList_ReturnsCorrectList()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            NonParametricAnalysisModel sut = new NonParametricAnalysisModel();

            //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);
        }
Exemplo n.º 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());

            NonParametricAnalysisModel sut = GetModel(mockDataset.Object);

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

            //Assert
            Assert.Equal("Respivs_sp_ivs1,Treativs_sp_ivs1,Block1", result[0]);
            Assert.Equal(19, result.Count()); //as blank reponses are removed
            Assert.StartsWith("0.43343727,y,f", result[10]);
        }
Exemplo n.º 8
0
        public void LoadArguments_ReturnsCorrectArguments()
        {
            //Arrange
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            NonParametricAnalysisModel sut = new NonParametricAnalysisModel(GetDataset());

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

            arguments.Add(new Argument {
                Name = "Response", Value = "Resp 1"
            });
            arguments.Add(new Argument {
                Name = "Treatment", Value = "Treat 1"
            });
            arguments.Add(new Argument {
                Name = "OtherDesignFactor", Value = "Block1"
            });
            arguments.Add(new Argument {
                Name = "Control", Value = "y"
            });
            arguments.Add(new Argument {
                Name = "Significance", Value = "0.05"
            });
            arguments.Add(new Argument {
                Name = "AnalysisType", Value = "MannWhitney"
            });

            Assert.Equal(6, arguments.Count);

            //Act
            sut.LoadArguments(arguments);

            //Assert
            Assert.Equal("Resp 1", sut.Response);
            Assert.Equal("Treat 1", sut.Treatment);
            Assert.Equal("Block1", sut.OtherDesignFactor);
            Assert.Equal("y", sut.Control);
            Assert.Equal("0.05", sut.Significance);
            Assert.Equal("MannWhitney", sut.AnalysisType.ToString());
        }
 public async Task <IActionResult> NonParametricAnalysis(NonParametricAnalysisModel model, bool ignoreWarnings)
 {
     return(await RunAnalysis(model, ignoreWarnings));
 }
 public NonParametricAnalysisValidator(NonParametricAnalysisModel np)
     : base(np.DataTable)
 {
     npVariables = np;
 }