public async void TestPost() { using (var client = server.CreateClient().AcceptJson()) { var step = 1; var service = new RegionService(); var countBefore = service.GetAll().Count(); var item = service.GetAll().FirstOrDefault(); if (item == null) { var newItem = new Region() { Id = 0, Name = string.Format("Region {0}", countBefore) }; service.Add(item); item = service.GetAll().FirstOrDefault(); step = 2; } var response = await client.PostAsJsonAsync("/api/Regions", item); var result = await response.Content.ReadAsJsonAsync <Region>(); var countAfter = service.GetAll().Count(); Assert.Equal(countBefore, countAfter - step); Assert.Equal((int)response.StatusCode, 201); } }
private async Task Save() { if (Id != 0) { await RegionService.Update(RegionModel); } else { await RegionService.Add(RegionModel); } NavigationService.Previous(); }
public void Test2() { CityService cityService = new CityService(); string cityName = DateTime.Now.ToFileTimeUtc().ToString(); long cityId = cityService.AddNew(cityName); RegionService regionSvc = new RegionService(); string regionName = DateTime.Now.ToFileTimeUtc().ToString(); long regionId = regionSvc.Add(regionName, cityId); var region = regionSvc.GetById(regionId); Assert.AreEqual(region.CityName, cityName); Assert.AreEqual(region.Name, regionName); Assert.AreEqual(regionSvc.GetAll(cityId).Length, 1); }
public ActionResult Add(CUSTOMREGION model) { try { IRegionService svc = new RegionService(); var result = svc.Add(model); this.AddNotification("Your Data Has Been Successfully Saved. ", NotificationType.SUCCESS); return(RedirectToAction("Index")); } catch (Exception ex) { general.AddLogError("Region Add", ex.Message, ex.StackTrace); this.AddNotification("ID exist", NotificationType.ERROR); this.ViewBag.Status = new SelectList(this.GetStatus(), "Key", "Value"); return(View("~/Views/Master/Region/Add.cshtml")); } }
public void TestAdd() { ConfigurationHelper.Ensure(); var service = new RegionService(); var countBefore = service.GetAll().Count(); var newItem = new Region() { Id = 0, Name = string.Format("Region {0}", countBefore) }; service.Add(newItem); var countAfter = service.GetAll().Count(); Assert.Equal(countBefore, countAfter - 1); }
public void RegionService_Add_ShouldPersistToSession() { _regionService.Add(new Region()); Session.QueryOver <Region>().RowCount().Should().Be(1); }