예제 #1
0
        public void FindByOption_Pass()
        {
            //Arrange
            var filterByID = new DropDownItem {
                Filter = "ID", Value = "1"
            };
            var filterByName = new DropDownItem {
                Filter = "Name", Value = "Henrique"
            };
            var filterByDescription = new DropDownItem {
                Filter = "Description", Value = "Description"
            };

            datasource = new Mock <ISqliteDataAccess>();
            datasource
            .Setup(m => m.FindByOption <CrudModel>(It.IsAny <string>()))
            .Returns(getList());

            //Act
            mockLog = new Mock <ILog>();
            var process            = new DataBaseService(datasource.Object, mockLog.Object);
            var actual_ID          = process.FindByOption(filterByID);
            var actual_Name        = process.FindByOption(filterByName);
            var actual_Description = process.FindByOption(filterByDescription);
            var expected           = getList();

            //Assert
            Assert.Equal(expected.Count, actual_ID.Count);
            Assert.Equal(expected.Count, actual_Name.Count);
            Assert.Equal(expected.Count, actual_Description.Count);
        }
예제 #2
0
        private async Task GetInfoData()
        {
            IsBusy = true;
            var userResponse = await ApiService.Get <User>("", "?results=50");

            Items.Clear();
            foreach (var userInfo in userResponse.Results)
            {
                Items.Add(new UserInfo
                {
                    FullName     = $"{userInfo.Name.Title.ToString()} {userInfo.Name.First} {userInfo.Name.Last}",
                    City         = userInfo.Location.City,
                    Email        = userInfo.Email,
                    ProfileImage = userInfo.Picture.Thumbnail
                });
            }
            var localData = await DataBaseService.GetItemsAsync <UserInfo>();

            if (localData.Any())
            {
                foreach (var userInfo in localData)
                {
                    Items.Add(userInfo);
                }
            }


            IsBusy = false;
        }
예제 #3
0
 public HomeController(INewsRepository newsRepository, DataBaseService dataBaseService, IRegistrationService registrationService, IArticleRepository articleRepository)
 {
     _newsRepository      = newsRepository;
     _registrationService = registrationService;
     _dataBaseService     = dataBaseService;
     _articleRepository   = articleRepository;
 }
        public async Task TestReadDataBaseEnvies()
        {
            var databaseService = new DataBaseService();

            var FireBaseClient = databaseService.GetFirebaseClient();

            var userGet = await FireBaseClient.Child("users").Child("Bérengère").OnceAsync <User>();

            var user = userGet.FirstOrDefault()?.Object;

            var envie = new Envie("sapin de noel", "celui que je veux c'est Cdiscount a 35€ avec plein de fleurs", user);

            var temp = await FireBaseClient.Child("envies").PostAsync(envie);

            var key = temp.Key;

            var comment = new Commentaire("commentaire1");

            envie = envie.SetCommentaire(comment);

            var tempEnvie = await FireBaseClient.Child("envies").Child(key).PostAsync(comment);

            var envieDB = await FireBaseClient.Child("envies").Child(key).OnceSingleAsync <Envie>();

            Check.That(envie).HasFieldsWithSameValues(envieDB);
        }
        private void SaveSomeDriverInfoToDB(DataBaseService dbService)
        {
            dbService.SignUp("Taras", "password");
            dbService.SignUp("Oleg", "1234");
            dbService.SignUp("Petro", "day");


            TaxiDriver.Driver driver = new TaxiDriver.Driver("Oleg", "1234", 0, 0)
            {
                LastScore = 70
            };
            dbService.SaveResult(driver);

            driver = new TaxiDriver.Driver("Taras", "password", 0, 0)
            {
                LastScore = 80
            };

            dbService.SaveResult(driver);

            driver = new TaxiDriver.Driver("Petro", "day", 0, 0)
            {
                LastScore = 120
            };
            dbService.SaveResult(driver);

            driver = new TaxiDriver.Driver("Taras", "password", 0, 0)
            {
                LastScore = 110
            };
            dbService.SaveResult(driver);
        }
        public void TestSignUp()
        {
            using (DataBaseService dbService = new DataBaseService())
            {
                dbService.SetConfiguration(SetDBConfigurationAndClearDriverInfoTable());

                Assert.IsTrue(dbService.SignUp("Taras", "password"));

                TaxiDriver.Driver driver = new TaxiDriver.Driver("Taras", "password", 0, 0);
                Assert.AreEqual(driver.Name, dbService.Driver.Name);
                Assert.AreEqual(driver.Password, dbService.Driver.Password);
                Assert.AreEqual(driver.TotalScore, dbService.Driver.TotalScore);
                Assert.AreEqual(driver.BestScore, dbService.Driver.BestScore);
                Assert.AreEqual(driver.LastScore, dbService.Driver.LastScore);

                Assert.AreEqual(null, dbService.Message);

                dbService.SignUp("Oleg", "1234");

                string message = "User with such name already exists.";
                Assert.IsFalse(dbService.SignUp("Taras", "password"));
                Assert.AreEqual(dbService.Message, message);
                Assert.AreEqual(null, dbService.Driver);

                Assert.IsFalse(dbService.SignUp("Taras", "hello"));
                Assert.AreEqual(dbService.Message, message);
                Assert.AreEqual(null, dbService.Driver);
            }
        }
예제 #7
0
        public async Task <IActionResult> surveys()
        {
            Logger.HttpRequestOutput("GET", "api/survey/surveys");
            List <Survey> SurveyList = DataBaseService.GetSurveyList();

            return(Json(SurveyList));
        }
예제 #8
0
        public async Task <IActionResult> deletesurvey(int id)
        {
            Logger.HttpRequestOutput("DELETE", "api/survey/survey");
            bool result = DataBaseService.Delete(id);

            return(Json(result));
        }
예제 #9
0
        public void Create_Campaign_Test()
        {
            //Arrange
            using (var dbService = new DataBaseService())
            {
                ICampaignService countChanges = new CampaignDBService(dbService, new ManagerDBService(dbService));

                var testManager = dbService.Managers.Find(1);
                var campaign    = new Campaign();
                campaign.Description = "Donacion";
                campaign.Place       = "Lugar";
                campaign.Title       = "Titulo";
                campaign.StartTime   = new System.DateTime();
                campaign.Latitude    = 5565555;
                campaign.Longitude   = 555585;
                campaign.ManagerId   = 1;
                campaign.Manager     = testManager;//Se agrega el manager a la campaña para evitar error de FK en la DB


                // Act

                var resultado = countChanges.CreateCampaign(campaign);

                // Assert
                Assert.IsNotNull(resultado);
            }
        }
예제 #10
0
        public async Task <IActionResult> survey(int questionid, int surveyid)
        {
            Logger.HttpRequestOutput("POST", "api/question/survey");
            bool result = DataBaseService.Subscribe(questionid, surveyid);

            return(Json(result));
        }
예제 #11
0
        private void SetStats(EogStatsBlock eog)
        {
            var players = eog.Teams.SelectMany(s => s.Players).ToList();

            Players = players.Select(s =>
            {
                var model = new EndGamePlayerStats
                {
                    Assists                = s.Stats.Assists,
                    ChampionId             = s.ChampionId,
                    Team                   = s.TeamId,
                    TotalDamageToChampions = s.Stats.TotalDamageDealtToChampions,
                    Leaves                 = s.Leaves,
                    Wins                   = s.Wins,
                    Losses                 = s.Losses,
                    Level                  = s.Level,
                    SummonerName           = s.SummonerName,
                    SummonerId             = s.SummonerId,
                    Deaths                 = s.Stats.NumDeaths,
                    Kills                  = s.Stats.ChampionsKilled
                };

                if (eog.SummonerId != s.SummonerId && !s.BotPlayer)
                {
                    var findHistory          = DataBaseService.GetSummoner(s.SummonerId);
                    model.GamesPlayedWithHim = findHistory == null ? 0 : findHistory.GamesPlayedWithHim;

                    DataBaseService.IncreaseSummonerGwh(s.SummonerId);
                }

                return(model);
            }).OrderByDescending(o => o.TotalDamageToChampions).ToList();

            SelectedPlayer = Players.First(f => f.SummonerName == eog.SummonerName);
        }
예제 #12
0
 private void deleteUser_Click(object sender, EventArgs e)
 {
     if (this.start)
     {
         MessageBox.Show("脚本运行中,不可删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (this.dataGridView1.SelectedRows.Count > 0)
     {
         DataGridViewRow row          = this.dataGridView1.SelectedRows[0];
         DialogResult    dialogResult = MessageBox.Show("您确定要删除 " + row.Cells[1].Value + " 吗?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dialogResult == DialogResult.Yes)
         {
             using (DataBaseService d = new DataBaseService())
             {
                 if (d.DelOneUserById((int)row.Cells[0].Value))
                 {
                     InitDatabase();
                     MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
     }
     else
     {
         MessageBox.Show("请先选择要删除的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
예제 #13
0
 public OrderCreatorViewModel(Order order)
 {
     _order            = order ?? new Order();
     SaveOrderCommand  = new RelayCommand(SaveOrder);
     dataBaseService   = DataBaseService.GetInstance();
     _navigatorService = NavigatorService.Instance;
 }
        public WeatherForecastController(ILogger <WeatherForecastController> logger)
        {
            var lofasz = new DataBaseService();

            lofasz.GetAllUser();
            _logger = logger;
        }
예제 #15
0
        public Query(DataBaseService db)
        {
            Name = "Query";

            Field <LoginType>(
                "loginInfo",
                arguments: null,
                resolve: context =>
            {
                Login login = new Login();

                login.Permissions = new List <string> {
                    "Test"
                };
                return(login);
            }
                ).AuthorizeWith(Permission.CanManageUsers.Value);

            Field <ListGraphType <PermissionType> >(
                "permissionList",
                arguments: null,
                resolve: context =>
            {
                return(Permission.GetAllPermissions());
            }
                ).AuthorizeWith("Authenticated");
        }
예제 #16
0
        public async Task <IActionResult> question(int id)
        {
            Logger.HttpRequestOutput("GET", "api/question/question");
            SenderQuestionContract Question = DataBaseService.GetQuestion(id);

            return(Json(Question));
        }
예제 #17
0
        public void Create_Medical_Center_Name()
        {
            //Arrange
            using (var dbService = new DataBaseService())
            {
                IManagerService       managerService       = new ManagerDBService(dbService);
                IMedicalCenterService medicalCenterService = new MedicalCenterDBService(dbService, managerService);


                var medicalCenter = new MedicalCenter
                {
                    Email       = "*****@*****.**",
                    Name        = "carit",
                    PhoneNumber = 88888,
                    Place       = "San Jose"
                };

                // Act

                var resultado = medicalCenter.Email;
                //var resultado = medicalCenter.Id;


                // Assert
                Assert.IsNotNull(value: resultado);
            }
        }
예제 #18
0
        public async Task <IActionResult> questions()
        {
            Logger.HttpRequestOutput("GET", "api/question/questions");
            List <SenderQuestionContract> QuestionList = DataBaseService.GetQuestionList();

            return(Json(QuestionList));
        }
예제 #19
0
        public void InitDatabase()
        {
            this.dataGridView1.Rows.Clear();
            this.users.Clear();
            using (DataBaseService s = new DataBaseService())
            {
                users     = s.findAllUsers();
                userCount = users.Count;
                //fillDataGrid
                int count = 0;
                foreach (User user in users)
                {
                    user.RowNum = count++;

                    this.dataGridView1.Rows.Add(new object[]
                    {
                        user.Id,
                        user.Username,
                        user.Operation,
                        user.Duration,
                        user.Dotimes,
                        "未执行",
                    });
                }
            }
            this.dataGridView1.ClearSelection();
        }
예제 #20
0
        public async Task <IActionResult> question(int id, [FromBody] QuestionContract question)
        {
            Logger.HttpRequestOutput("PUT", "api/question/question");
            bool result = DataBaseService.EditQuestion(id, question);

            return(Json(result));
        }
예제 #21
0
        private void saveToXMLButton_Click(object sender, EventArgs e)
        {
            DataBaseService.AddingContentToDataBase(GetCustomerData(), dataGridView1);

            CreatingXML.CreateCustomerXML(DataBaseService.GetCollectionOfCustomers());
            CreatingXML.CreateOrdersXML(DataBaseService.GetCollectionOfOrders());
        }
예제 #22
0
        public async Task <IActionResult> survey(int id, [FromBody] SurveyContract survey)
        {
            Logger.HttpRequestOutput("PUT", "api/survey/survey");
            bool result = DataBaseService.SaveSurvey(id, survey);

            return(Json(result));
        }
예제 #23
0
 public override void Init()
 {
     base.Init();
     LoginString      = Login;
     PasswordString   = Password;
     _dataBaseService = new DataBaseService();
 }
        public void TestUpdateDoctor()
        {
            IDataBaseService   iDataBaseService  = new DataBaseService();
            DoctorService      dService          = new DoctorService(iDataBaseService);
            StaticDataServices staticDataService = new StaticDataServices(iDataBaseService);
            ILogger            logger            = new Logger(iDataBaseService);

            DataServices.DataServices dServ   = new DataServices.DataServices(iDataBaseService);
            ViewModelFactory          factory = new ViewModelFactory(dServ, staticDataService);
            DoctorMapper     dMapper          = new DoctorMapper(factory);
            DoctorController dController      = new DoctorController(staticDataService, dServ, factory, dMapper, logger);

            dController.Request = new HttpRequestMessage
            {
                RequestUri = new Uri("http://localhost/Doctor/SaveDoctor")
            };
            dController.Configuration = new HttpConfiguration();
            dController.Configuration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional });

            dController.RequestContext.RouteData = new HttpRouteData(
                route: new HttpRoute(),
                values: new HttpRouteValueDictionary {
                { "controller", "doctor" }
            });

            RequestCarrier req = new RequestCarrier();

            req.From     = "Test";
            req.TanentId = -1;

            DoctorViewModel dvModel = new DoctorViewModel(staticDataService.GetCountry(), staticDataService.GetState(), staticDataService.GetCity(), staticDataService.GetHospital(), staticDataService.GetDegree(), staticDataService.GetSpecialization(), staticDataService.GetDesease());

            dvModel.Id                   = 8;
            dvModel.Address1             = "12, DP Pharma Road";
            dvModel.CityID               = 1;
            dvModel.CreatedBy            = 1;
            dvModel.CreatedByEntity      = 1;
            dvModel.DoctorDegree         = new List <int>();
            dvModel.DoctorDesease        = new List <int>();
            dvModel.DoctorHospital       = new List <int>();
            dvModel.DoctorSpecialization = new List <int>();
            dvModel.EmailAddress         = "*****@*****.**";
            dvModel.FirstName            = "Raj";
            dvModel.LastName             = "Sharma";
            dvModel.OtherInformation     = "Heart Specilist";
            dvModel.PhoneNumber          = "8989889889";
            dvModel.Pincode              = "411014";
            dvModel.ProfilePhotoID       = 1;
            dvModel.RegistrationNumber   = "RJ12123";
            dvModel.TanentId             = -1;
            //dvModel.UpdatedBy = 1;
            req.PayLoad = dvModel;
            var response = dController.SaveDoctor(req);

            Assert.IsNotNull(response);
        }
예제 #25
0
        public async Task <IActionResult> question([FromBody] QuestionContract question)
        {
            Logger.HttpRequestOutput("POST", "api/question/question");
            int  questionid = DataBaseService.SaveQuestion(question);
            bool result     = DataBaseService.SaveAnswer(question, questionid);

            return(Json(result));
        }
예제 #26
0
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            var dbPath = string.IsNullOrWhiteSpace(_dbPathMigrations)
                ? DataBaseService.GetDbPath()
                : _dbPathMigrations;

            optionsBuilder.UseSqlite($"Filename={dbPath}");
        }
예제 #27
0
 private void deleteQuestion_Click(object sender, EventArgs e)
 {
     if (questionsBox.SelectedIndex != -1)
     {
         DataBaseService.deleteQuestion(questions[questionsBox.SelectedIndex]);
         questionsBox.Items.RemoveAt(questionsBox.SelectedIndex);
     }
 }
예제 #28
0
        private async void SaveCommandExecute()
        {
            if (ValidateData())
            {
                await DataBaseService.AddItemAsync(item);

                await NavigationService.GoBackAsync();
            }
        }
예제 #29
0
        private void LoadNotes()
        {
            if (Players == null || Players.Count <= 0)
            {
                return;
            }

            Players.ForEach(f => f.Note = DataBaseService.GetSummoner(f.SummonerId)?.Note);
        }
예제 #30
0
        public bool CheckPhone()
        {
            var table = Builder.TableInfo.TableName;
            var p     = new Param();

            p["@Phone"] = this.Phones;
            p["@MaKH"]  = this.MaKH;
            return(DataBaseService.ExeSql(string.Format("SELECT Count(0) From {0} where [Phones]=@Phone and MaKH<>@MaKH", table), p).Rows[0][0].As <int>() > 0);
        }