public void SetUp()
 {
     _outputModel = new TestOutputModel();
     _behavior = new OutputDebugInformation(new FubuConventions(), new FubuConfiguration(new FubuConventions()))
     {
         InsideBehavior = new DefaultBehavior()
     };
 }
 public void SetUp()
 {
     _outputModel = new TestOutputModel();
     _conventions = new FubuConventions();
     _behavior = new RedirectToNotFoundUrl(_conventions)
     {
         InsideBehavior = new DefaultBehavior()
     };
 }
Ejemplo n.º 3
0
        public void SetUp()
        {
            _behavior    = CreateBehavior();
            _controller  = new TestController();
            _input       = new TestInputModel();
            _outputModel = new TestOutputModel();

            beforeEach();
        }
Ejemplo n.º 4
0
        public void SetUp()
        {
            _uow            = MockRepository.GenerateMock <IUnitOfWork>();
            _insideBehavior = MockRepository.GenerateStub <IControllerActionBehavior>();
            _behavior       = new access_the_database_through_a_unit_of_work(_uow)
            {
                InsideBehavior = _insideBehavior
            };
            _input  = new TestInputModel();
            _output = new TestOutputModel();

            _actionFunc = i => new TestOutputModel();
        }
Ejemplo n.º 5
0
        public ActionResult <TestOutputModel> GetTestAllInfoById(int testId)
        {
            Mapper           mapper       = new Mapper();
            AuthorDataAccess tests        = new AuthorDataAccess();
            var            test           = tests.GetTestById(testId);
            TestStatistics testStatistics = new TestStatistics(testId);

            if (test == null)
            {
                return(BadRequest("Теста не существует"));
            }
            TestOutputModel   model = mapper.ConvertTestDTOToTestOutputModel(tests.GetTestById(testId));
            PassedFailedModel pfs   = testStatistics.GetPassedFailedStats(testId);

            model.Questions     = mapper.ConvertQuestionDTOToQuestionModelList(tests.GetQuestionsByTestID(testId));
            model.Tags          = mapper.ConvertTagDTOToTagModelList(tests.GetTagsInTest(testId));
            model.AverageResult = testStatistics.GetAverageResults(testId);
            model.Passed        = pfs.Passed;
            model.Failed        = pfs.Failed;
            model.SuccessRate   = pfs.SuccessRate;
            foreach (QuestionOutputModel qModel in model.Questions)
            {
                qModel.Answers = mapper.ConvertAnswerDTOToAnswerModelList(tests.GetAnswerByQuestionId(qModel.ID));
                QuestionStatistics statistics = new QuestionStatistics(qModel.ID);
                qModel.PercentageOfCorrectlyAnswered = statistics.GetPercentageOfCorrectlyAnswered(qModel.ID);
                Dictionary <int, double> answersPercent = new Dictionary <int, double>();
                answersPercent = statistics.GetPercentageOfPeopleChoosingAnswer(qModel.ID);
                foreach (var answer in qModel.Answers)
                {
                    foreach (var i in answersPercent)
                    {
                        if (answer.ID == i.Key)
                        {
                            answer.PercentageOfPeopleChoosingAnswer = i.Value;
                        }
                        else
                        {
                            answer.PercentageOfPeopleChoosingAnswer = 0;
                        }
                    }
                }
            }
            return(Ok(model));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 测试用例
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public BaseResultModel <List <TestOutputModel> > Test(TestInputModel model)
        {
            try
            {
                List <TestOutputModel> result;
                result = this.TestTableRepository.List().ToList();

                //增
                this.TestTableRepository.Insert(model);
                var insertresult           = this.TestTableRepository.InsertAndReturn(model);
                List <TestInputModel> list = new List <TestInputModel>();
                list.Add(model);
                list.Add(model);
                this.TestTableRepository.InsertCol(list.ToArray());


                using (this.TestTableRepository.BeginLikeMode())
                {// using里使用like查询
                    PageModel <TestOutputModel> m1 = this.TestTableRepository.ListPage(model);
                }
                //不模糊查询
                PageModel <TestOutputModel> m = this.TestTableRepository.ListPage(model);


                using (this.TestTableRepository.BeginLikeMode())
                {// using里使用like查询
                    //查
                    result = this.TestTableRepository.List(model).ToList();
                    model  = new TestInputModel();
                    var pageresult = this.TestTableRepository.ListPage(model).ListData.ToList();
                    var mymodel    = this.TestTableRepository.SelectWithModel(model);
                    mymodel.Name = "test2";
                    //改
                    this.TestTableRepository.UpdateWithKeys(mymodel);
                    var mymodel2 = this.TestTableRepository.SelectWithKeys(mymodel);
                    model.Name   = "test2";
                    mymodel      = new TestOutputModel();
                    mymodel.Name = "test3";
                    var listUpdateModel = this.TestTableRepository.UpdateWithModelAndReturn(mymodel, model);
                    mymodel2 = this.TestTableRepository.SelectWithKeys(mymodel);
                }

                // 删
                model.Timestamp = new byte[0];
                var i = this.TestTableRepository.DeleteWithModel(model);
                this.TestTableRepository.SelectWithModel(model);
                i = this.TestTableRepository.DeleteWithIdentity(1);
                this.TestTableRepository.Search(model, true);
                this.TestTableRepository.UpdateWithModel(model, model);
                i = this.TestTableRepository.DeleteWithKeys(
                    new TestInputModel()
                {
                    ID = new Guid("F68AA6B5-7BA2-456E-85D7-BE31791B3FDF")
                }
                    );

                TransactionOptions option = new TransactionOptions();
                option.IsolationLevel = IsolationLevel.ReadCommitted;
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option))
                {
                    model.ID = new Guid("A317E4B2-A8C4-4E35-89A0-22A1F515E281");
                    this.TestTableRepository.Insert(model);
                    scope.Complete();
                }
                this.TestTableRepository.TruncateTable();

                //夸数据库事务
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    this.TestTable44Repository.InsertCol(list.ToArray());
                    scope.Complete();
                }
                return(new SuccessResultModel <List <TestOutputModel> >(null));
            }
            catch (Exception e)
            {
                LogWriter.WriteLog(EnumLogLevel.Fatal, "ListData", "", "", "查询数据时发生错误.", e);
                return(new ErrorResultModel <List <TestOutputModel> >("", "查询数据时发生错误"));
            }
        }