コード例 #1
0
        public void TestUpdateMeteorology()
        {
            BoraNowSeeder.Seed();
            var mbo     = new MeteorologyBusinessObject();
            var resList = mbo.List();
            var item    = resList.Result.FirstOrDefault();

            var meteo = new Meteorology(10, 11, 50, 2, 7, DateTime.Now.AddDays(200));

            item.MaxTemperature = meteo.MaxTemperature;
            item.MinTemperature = meteo.MinTemperature;
            item.RainPercentage = meteo.RainPercentage;
            item.UvIndex        = meteo.UvIndex;
            item.WindIndex      = meteo.WindIndex;
            item.Date           = meteo.Date;

            var resUpdate = mbo.Update(item);

            resList = mbo.List();

            Assert.IsTrue(resUpdate.Success && resList.Success &&
                          resList.Result.First().MaxTemperature == meteo.MaxTemperature && resList.Result.First().MinTemperature == meteo.MinTemperature &&
                          resList.Result.First().RainPercentage == meteo.RainPercentage && resList.Result.First().UvIndex == meteo.UvIndex &&
                          resList.Result.First().WindIndex == meteo.WindIndex && resList.Result.First().Date == meteo.Date);
        }
コード例 #2
0
        public void TestDeleteMeteorology()
        {
            BoraNowSeeder.Seed();
            var mbo       = new MeteorologyBusinessObject();
            var resList   = mbo.List();
            var resDelete = mbo.Delete(resList.Result.First().Id);

            resList = mbo.List();

            Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.First().IsDeleted);
        }
コード例 #3
0
        public void TestListMeteorology()
        {
            BoraNowSeeder.Seed();
            var mbo     = new MeteorologyBusinessObject();
            var resList = mbo.List();

            Assert.IsTrue(resList.Success && resList.Result.Count == 1);
        }
コード例 #4
0
        public ActionResult <List <MeteorologyViewModel> > List()
        {
            var res = _bo.List();

            if (!res.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            var list = new List <MeteorologyViewModel>();

            foreach (var item in res.Result)
            {
                list.Add(MeteorologyViewModel.Parse(item));
            }
            return(list);
        }