public async Task <ActionResult <LocationDto> > PutLocation(int locationId, LocationDto locationDto) { try { var oldLocation = await _locationRepository.GetLocation(locationId); if (oldLocation == null) { return(NotFound($"We could not find a location with that id: {locationId}")); } var newLocation = _mapper.Map(locationDto, oldLocation); _locationRepository.Update(newLocation); if (await _locationRepository.Save()) { return(NoContent()); } } catch (Exception e) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}")); } return(BadRequest()); }
public void PlayerLoadedMap(string signalrConnectionId, LocationDto location) { repository.AddPlayerLocation(signalrConnectionId, location); repository.SetPlayerLoaded(signalrConnectionId, true); repository.SaveChanges(); }
public LocationDto Map(Dictionary <string, string> from) { var to = new LocationDto(); Map(from, to); return(to); }
private IEnumerable <LinkDto> CreateLinksForLocations(LocationDto locationDto) { var links = new[] { new LinkDto { Href = Url.Link("GetLocation", new { locationId = locationDto.LocationId }).ToLower(), Rel = "self", Method = "GET" }, new LinkDto { Href = Url.Link("PutLocation", new { locationId = locationDto.LocationId }).ToLower(), Rel = "update location", Method = "PUT" }, new LinkDto { Href = Url.Link("DeleteLocation", new { locationId = locationDto.LocationId }).ToLower(), Rel = "delete location", Method = "DELETE" } }; return(links); }
public async void GetLocations_ReturnsFilteredLocations_WhenValidOffsetRequest() { var locationDto1 = new LocationDto { Latitude = 55.6782377, Longitude = 12.5594759 }; var locationDto2 = new LocationDto { Latitude = 55.6782377, Longitude = 12.5594759 }; var tripDto = await Checkin(); await AddLocation(tripDto.TripIdentifier, SerializeContent(locationDto1)); await AddLocation(tripDto.TripIdentifier, SerializeContent(locationDto2)); var response = await _client.GetAsync($"/api/trip/Locations/{tripDto.TripIdentifier}/1"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var responseDto = JsonConvert.DeserializeObject <ICollection <LocationDto> >(await response.Content.ReadAsStringAsync()); Assert.NotNull(responseDto); Assert.Equal(1, responseDto.Count); var actualLocationDto = responseDto.First(); Assert.Equal(locationDto2.Latitude, actualLocationDto.Latitude); Assert.Equal(locationDto2.Longitude, actualLocationDto.Longitude); }
public void UpdateNonexistentLocation() { //Automapper AutoMapperConfig.RegisterMappings(); //Mock context Mock <FortuneDbContext> mockContext = new Mock <FortuneDbContext>(); //Mock repos Mock <IRepo <Location> > mockLocationRepo = new Mock <IRepo <Location> >(); //Test location Location testLocation = new Location { Id = Guid.NewGuid(), Deleted = false, Name = "TEST" }; LocationDto testDto = Mapper.Map <LocationDto>(testLocation); //Mock call mockLocationRepo.Setup(x => x.Get(It.Is <Guid>(y => y == testLocation.Id))).Returns <Location>(null); //Unit of work Mock <IUnitOfWork> mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.SetupGet(x => x.LocationRepo).Returns(mockLocationRepo.Object); //Location Service ILocationService locationService = new LocationService(mockUnitOfWork.Object); //Test LocationDto dto = locationService.Update(testDto); }
public async Task <ActionResult> Index() { try { await GetCategoriesDropdown(); await GetProvinceDropdown(); await GetLocationsDropdown(); //ViewData["locations"] = new List<LocationDto>(); StoreViewModel model = new StoreViewModel(new StoreDto()); var output = await _storeAppService.GetStoreByUser(AbpSession.UserId.Value); model = new StoreViewModel(output); LocationDto loc = new LocationDto(); if (output.LocationId > 0) { loc = await _locationAppService.GetLocation(Convert.ToInt32(output.LocationId)); model.ProvinceId = Convert.ToInt32(loc.ProvinceId); } return(View(model)); } catch (Exception ex) { throw ex; } }
public async Task <LocationDto> GetLocationDto(string deviceId) { var location = await Get(deviceId); if (location == null) { throw new RepositoryException($"{deviceId} id'li device'ın location nesnesi bulunamadı.") { RepositoryName = "Location", ExceptionType = RepositoryExceptionType.LocationNotExist, Value = deviceId } } ; var locationDto = new LocationDto() { Id = location.Id, DeviceId = deviceId, Name = location.Name, DeviceTypeName = DeviceType.GetName(location.Device.TypeId) }; return(locationDto); }
public async Task <bool> UpdateLocatioin(LocationDto locationDto) { //Map the DTO object into the data entity var recDb = Mapper.Map <Location>(locationDto); return(await _db.UpdateAsync(recDb)); }
/// <summary> /// 获取指定速度下行驶时长后线中的点 /// </summary> /// <param name="localtions">线路中的点</param> /// <param name="startLocation">当前点</param> /// <param name="speed">速度,单位km/h</param> /// <param name="interval">间隔时间,单位s</param> /// <param name="nextIndex">下一个关键点的索引</param> /// <returns></returns> public static LocationDto GetNextLation(List <LocationDto> localtions, LocationDto startLocation, double speed, int interval, ref int nextIndex) { var logger = Jt808TerminalEmulator.Core.DependencyInjectionExtensions.ServiceProvider.CreateScope().ServiceProvider.GetRequiredService <ILogger <LocationInterpolation> >(); if (nextIndex >= localtions.Count) { return(null); } var intervalDistance = speed / 3.6 * interval; var nextDistance = intervalDistance; for (; nextIndex < localtions.Count;) { var distance = LocationInterpolation.CalculateDistanceBetweenLocations(startLocation, localtions[nextIndex]); if (distance < nextDistance) { nextDistance -= distance; startLocation = localtions[nextIndex]; nextIndex++; continue; } var endLocation = LocationInterpolation.IntermediaryLocation(startLocation, localtions[nextIndex], nextDistance); distance = LocationInterpolation.CalculateDistanceBetweenLocations(endLocation, localtions[nextIndex]); logger.LogInformation($"当前索引:{nextIndex},差值{distance}起点[{startLocation.Logintude},{startLocation.Latitude}]终点,[{endLocation.Logintude},{endLocation.Latitude}],第{localtions[nextIndex].Order}个关键点[{localtions[nextIndex].Logintude},{localtions[nextIndex].Latitude}]"); return(endLocation); } return(default);
public async Task <IHttpActionResult> PutLocation(int id, LocationDto locationDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != locationDto.ID) { return(BadRequest()); } var location = DtoToEntityIMapper.Map <LocationDto, Location>(locationDto); //// UoW.GetRepository <Location>().ModifyEntityState(location); try { await UoW.SaveAsync(); } catch (DbUpdateConcurrencyException) { if (!LocationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutLocation(int id, LocationDto locationDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != locationDto.Id) { return(BadRequest()); } Location location = _iMapper.Map <LocationDto, Location>(locationDto); try { _unitOfWork.LocationRepository.Add(location); _unitOfWork.Complete(); } catch (DbUpdateConcurrencyException) { if (!LocationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public RetrieveOutput <LocationDto, long> Retrieve(RetrieveLocationInput input) { LocationRepository.Includes.Add(r => r.LastModifierUser); LocationRepository.Includes.Add(r => r.CreatorUser); IList <Location> locationEntities = LocationRepository.GetAll() .WhereIf(input.Id != null, r => r.Id == input.Id) .WhereIf(!String.IsNullOrEmpty(input.Name), r => r.Name.ToLower().Contains(input.Name.ToLower())) .ToList(); if (locationEntities.Count != 1) { throw new CityQuestItemNotFoundException(CityQuestConsts.CityQuestItemNotFoundExceptionMessageBody, "\"Location\""); } if (!LocationPolicy.CanRetrieveEntity(locationEntities.Single())) { throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionRetrieveDenied, "\"Location\""); } LocationDto locationEntity = locationEntities.Single().MapTo <LocationDto>(); LocationRepository.Includes.Clear(); return(new RetrieveOutput <LocationDto, long>() { RetrievedEntity = locationEntity }); }
public static void Compare( LocationDto expected, LocationDto actual, bool idEqual = true, bool deletedEqual = true ) { if (idEqual) { Assert.AreEqual(expected.Id, actual.Id); } else { Assert.AreNotEqual(expected.Id, actual.Id); } Assert.AreEqual(expected.Name, expected.Name); if (deletedEqual) { Assert.AreEqual(expected.Deleted, actual.Deleted); } else { Assert.AreNotEqual(expected.Deleted, actual.Deleted); } }
public LocationDto checkLocationActive(long id) { using (EAharaDB context = new EAharaDB()) { if (id != 0) { var Delete = context.Locations.FirstOrDefault(x => x.Id == id); if (Delete.IsActive) { LocationDto loc = new LocationDto(); loc.Id = Delete.Id; loc.Name = Delete.Name; loc.DeliveryCharge = Delete.DeliveryCharge; loc.DeliveryRange = Delete.DeliveryRange; loc.Lng = Delete.Lng; loc.Lat = Delete.Lat; return(loc); } return(null); } } return(null); }
private LocationDto callIpLocationApi(string ip) { HttpClient httpClient = new HttpClient(); httpClient.Timeout = TimeSpan.FromSeconds(15); ip = (ip != "::1") ? ip : "115.156.252.5"; var url = @"https://freegeoip.net/json/" + ip; var request = new HttpRequestMessage() { RequestUri = new Uri(url), Method = HttpMethod.Get, }; request.Headers.AcceptLanguage.TryParseAdd("zh-CN"); HttpResponseMessage response; try { response = httpClient.SendAsync(request).Result; } catch { throw new Exception("ip location API error"); } string reponseStringSource = response.Content.ReadAsStringAsync().Result; dynamic loc = JsonConvert.DeserializeObject(reponseStringSource); var ipLoc = new LocationDto { Latitude = loc.latitude, Longitude = loc.longitude, Country = loc.country_name, Province = loc.region_name, City = loc.city }; return(ipLoc); }
public async Task <IActionResult> EditLocation(int id, LocationDto model) { if (!ModelState.IsValid) { return(BadRequest("Something want wrong while updating location")); } var locationToEdit = await _locationService.GetLocationByIdAsync(id); if (locationToEdit == null) { return(BadRequest("Location not found")); } locationToEdit.City = model.City; locationToEdit.Country = model.Country; locationToEdit.StreetAddress = model.StreetAddress; locationToEdit.ZipCode = model.ZipCode; await _locationService.UpdateLocationAsync(locationToEdit); await _genericRepository.SaveChangesAsync(); return(Ok(new { status = 200, message = "Location edited successfully" })); }
public async Task <IActionResult> AddLocation(LocationDto model) { if (!ModelState.IsValid) { return(BadRequest("Something want wrong while adding location")); } var location = new Location { ZipCode = model.ZipCode, City = model.City, Country = model.Country, StreetAddress = model.StreetAddress }; await _locationService.AddLocationAsync(location); await _genericRepository.SaveChangesAsync(); return(Ok(new { status = 200, message = "Location Added successfully!" })); }
public async Task <bool> AddLocations(LocationDto LoDto) { var url = $"{Settings.SERVER_ENDPOINT}/UFLocations/AddLocation"; await _requestService.PostAsync <LocationDto>(url, LoDto); return(true); }
public UpdateOutput <LocationDto, long> Update(UpdateInput <LocationDto, long> input) { Location newLocationEntity = input.Entity.MapTo <Location>(); if (newLocationEntity == null) { throw new CityQuestItemNotFoundException(CityQuestConsts.CityQuestItemNotFoundExceptionMessageBody, "\"Location\""); } if (!LocationPolicy.CanUpdateEntity(newLocationEntity)) { throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionUpdateDenied, "\"Location\""); } LocationRepository.Includes.Add(r => r.LastModifierUser); LocationRepository.Includes.Add(r => r.CreatorUser); LocationRepository.Update(newLocationEntity); LocationDto newLocationDto = (LocationRepository.Get(newLocationEntity.Id)).MapTo <LocationDto>(); LocationRepository.Includes.Clear(); return(new UpdateOutput <LocationDto, long>() { UpdatedEntity = newLocationDto }); }
public async Task <IActionResult> UpdateLocation([FromRoute] int id, [FromBody] LocationDto entityDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != entityDto.Id) { return(BadRequest()); } var entity = await _repository.GetByIdAsync(entityDto.Id); if (entity == null) { return(BadRequest("Location does not exist")); } _mapper.Map(entityDto, entity); try { _repository.Update(entity); await _unitOfWork.SaveAsync(); } catch (Exception) { throw new Exception("An unexpected error occured. Could not update."); } return(Ok(_mapper.Map <LocationDto>(entity))); }
public IActionResult EditLocationModal(EditLocation model) { if (ModelState.IsValid) { LocationDto dto = new LocationDto() { Address = model.Address, City = model.City, Country = model.Country, Description = model.Description, LocationId = model.LocationId, LocationName = model.LocationName, StateRegion = model.StateRegion, ZipCode = model.ZipCode }; if (model.IsAddNew) { model.Result = LocationService.AddLocation(dto); } else { model.Result = LocationService.UpdateLocation(dto); } } return(PartialView("_EditLocationPartial", model)); }
public async Task Update(LocationDto locationDto) { var location = _mapper.Map <Location>(locationDto); _locationRepository.Update(location); await _locationRepository.SaveChangesAsync(); }
public IActionResult _deleteLocation(string id) { ChangeResult result = new ChangeResult(); Guid? locationId = Helper.ConvertToGuid(id); if (locationId.HasValue) { var model = LocationService.GetLocation(locationId.Value); if (model != null) { LocationDto dto = new LocationDto() { Address = model.Address, City = model.City, Country = model.Country, Description = model.Description, LocationId = model.LocationId, LocationName = model.LocationName, StateRegion = model.StateRegion, ZipCode = model.ZipCode, DeleteDate = DateTime.UtcNow }; result = LocationService.UpdateLocation(dto); } } return(new JsonResult(result)); }
public IActionResult Put(int id, [FromBody] LocationDtoForUpdate locationDto) { if (locationDto == null) { return(BadRequest()); } if (string.IsNullOrEmpty(locationDto.Name) && string.IsNullOrEmpty(locationDto.Longitude) && string.IsNullOrEmpty(locationDto.Latitude) && string.IsNullOrEmpty(locationDto.GoogleMapsAddress)) { return(StatusCode(500, "Must provide some data")); } Location locationEntity = _locationsRepository.GetLocation(id); if (locationEntity == null) { return(NotFound()); } _mapper.Map(locationDto, locationEntity); var result = _locationsRepository.SaveChanges(); if (!result) { return(StatusCode(500, "Something went wrong updating the location")); } LocationDto locationDtoUpdated = _mapper.Map <LocationDto>(locationEntity); return(Ok(locationDtoUpdated)); }
public ActionResult GetLocations() { List <LocationUpdateModel> models = new List <LocationUpdateModel>(); var locations = LocationBlo.GetLocations2(AppDomain.CurrentDomain.BaseDirectory); foreach (var item in locations) { var location = new LocationUpdateModel { Id = item.Id, Name = item.Name, Address = item.Address, PhoneNumbers = item.PhoneNumbers, FaxNumbers = item.FaxNumbers, LocationType = item.LocationType, Specialists = LocationDto.SpecialistsToString(item.Specialists), Rating = item.Rating.ToString(CultureInfo.CurrentCulture), Area1 = item.Area1, Area2 = item.Area2, Latitude = item.Latitude, Longitude = item.Longitude }; models.Add(location); } return(View(models)); }
public async Task <ActionResult> SetLocation(LocationDto location) { MemberHelper memberHelper = new MemberHelper(); await memberHelper.SetLocation(location); return(Success()); }
public ActionResult Details(string id) { var model = new LocationUpdateModel(); var locations = LocationBlo.GetLocations2(AppDomain.CurrentDomain.BaseDirectory); var exists = locations.Where(x => x.Id == id).ToList(); if (exists.Count > 0) { var item = exists[0]; model = new LocationUpdateModel { Id = item.Id, Name = item.Name, Address = item.Address, PhoneNumbers = item.PhoneNumbers, FaxNumbers = item.FaxNumbers, LocationType = item.LocationType, Specialists = LocationDto.SpecialistsToString(item.Specialists), Rating = item.Rating.ToString(CultureInfo.CurrentCulture), Area1 = item.Area1, Area2 = item.Area2, Latitude = item.Latitude, Longitude = item.Longitude }; } return(View(model)); }
public void GetLocation() { //Automapper AutoMapperConfig.RegisterMappings(); //Mock repos Mock <IRepo <Location> > mockLocationRepo = new Mock <IRepo <Location> >(); //Test location Location testLocation = new Location { Id = Guid.NewGuid(), Deleted = false, Name = "TEST" }; LocationDto testDto = Mapper.Map <LocationDto>(testLocation); //Mock call mockLocationRepo.Setup(x => x.Get(It.Is <Guid>(y => y == testLocation.Id))).Returns(testLocation); //Unit of work Mock <IUnitOfWork> mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.SetupGet(x => x.LocationRepo).Returns(mockLocationRepo.Object); //Location Service ILocationService locationService = new LocationService(mockUnitOfWork.Object); //Test LocationDto dto = locationService.Get(testDto.Id); TestUtil.Compare(testDto, testDto); }
public async Task <ActionResult <LocationDto> > PostLocation([FromBody] LocationDto locationDto) { var insertedId = await _locationService.Add(locationDto); locationDto.Id = insertedId; return(CreatedAtAction("GetLocation", new { id = locationDto.Id }, locationDto)); }
public LocationDto GetLocation(string sessionKey, string locationId) { LocationDto retVal = new LocationDto(); long id = 0; long.TryParse(locationId, out id); retVal.Id = id; if (id == 1) { retVal.Name = "Springfield General Hospital"; retVal.InstructionsUrl = "www.google.com"; } return retVal; }
public LocationDto ToLocationDto(Location entity) { var dto = new LocationDto() { Key = entity.Key, Name = entity.Name, Latitude = entity.Latitude, Longitude = entity.Longitude, GeocodeStatus = entity.GeocodeStatus.ToString(), DbGeogNeedsUpdated = entity.DbGeogNeedsUpdated, LocationTypeKey = entity.LocationTypeKey, UpdateDate = entity.UpdateDate, CreateDate = entity.CreateDate //Viewport = entity.Viewport.ToString(), }; return dto; }
public Location ToLocationEntity(LocationDto dto) { var Entity = new Location() { Key = dto.Key, Name = dto.Name, Latitude = dto.Latitude, Longitude = dto.Longitude, Coordinate = new Coordinate(dto.Latitude, dto.Longitude), GeocodeStatus = DoGeocoding.GetGeocodeStatus(dto.GeocodeStatus), DbGeogNeedsUpdated = dto.DbGeogNeedsUpdated, LocationTypeKey = dto.LocationTypeKey, UpdateDate = dto.UpdateDate, CreateDate = dto.CreateDate //Viewport = new Viewport(dto.Viewport), }; return Entity; }
public void UpdateSubID_SubNotFoundInDPI_ValidateSuccessScenario() { var loc = new LocationDto(); var sub = new SubscriberDto(); // newSubId var newSubId = DateTime.Now.ToString("MMddssff"); newSubId += new Random().Next(1000, 9999); try { // new sub data loc = DataHelper.NewLocationData(); sub = DataHelper.NewSubscriberData(); sub.Accounts[0].Location = loc; sub.CustomFields = DataHelper.DefaultCustomFields_Sub(); sub.Accounts[0].ServiceEnabled = true; DataHelper.RestoreLocation1(loc, false); DataHelper.RestoreSubscriber1(sub, false); // set current subscriber CurrentSubscriber.SetInstance(sub); var updateSubIdModel = new UpdateSubIDModel { OldSubID = sub.ID, NewSubID = newSubId }; // call UpdateSubID action method var result = SubscriberControllerForTests.UpdateSubID(updateSubIdModel) as JsonResult; // expected subDetailsModel after UpdateSubID var subDetailsModel = sub.MapToSubDetailsModel(); subDetailsModel.USI = newSubId; // validate response result Assert.IsNotNull(result, "Json result is null"); Assert.IsNotNull(result.Data, "Json result data is null"); dynamic resultStatus = result.Data; Assert.AreEqual("valid", resultStatus.status as string, "Response status does not match!"); // validate subID changed in db var actualSub = DataHelper.LoadSubscriber(newSubId); Assert.IsNotNull(actualSub, "Subscriber should not be null!"); Assert.AreEqual(newSubId, actualSub.ID); Assert.AreEqual(sub.Name, actualSub.Name); // validate the current subscriber session got updated var currentSubscriber = CurrentSubscriber.GetInstance(); var actualSubDetailsModel = currentSubscriber.MapToSubDetailsModel(); // validate FoundInBilling should be false Assert.IsFalse(actualSubDetailsModel.FoundInBilling, "FoundInBilling should be false"); // validate actualSubDetailsModel matches expectedSubDetailsModel Assert.AreEqual(subDetailsModel.USI, actualSubDetailsModel.USI, "USI does not match"); sub.ID = actualSubDetailsModel.USI; Assert.AreEqual(subDetailsModel.Name, actualSubDetailsModel.Name, "Name does not match"); Assert.AreEqual(subDetailsModel.FoundInBilling, actualSubDetailsModel.FoundInBilling, "FoundInBilling does not match"); Assert.AreEqual(subDetailsModel.CurrentServiceStatus, actualSubDetailsModel.CurrentServiceStatus, "CurrentServiceStatus does not match"); Assert.IsTrue(actualSubDetailsModel.ServiceStatusDisplay.Contains("Enabled"), "ServiceStatusDisplay does not match"); } catch (System.Exception ex) { Assert.IsTrue(ex is AssertFailedException, ex.ToString()); throw; } finally { // delete sub.ID in case UpdateSubID failed DataHelper.DeleteSubscriber(sub.ID); // delete newSubId if UpdateSubID succeed DataHelper.DeleteSubscriber(newSubId); // delete location DataHelper.DeleteLocation(loc.ID); } }
public void LoadLocationValidLocId() { var loc = new LocationDto(); var sub = new SubscriberDto(); try { // new sub and loc data loc = DataHelper.NewLocationData(); sub = DataHelper.NewSubscriberData(); sub.Accounts[0].Location = loc; sub.CustomFields = DataHelper.DefaultCustomFields_Sub(); DataHelper.RestoreLocation1(loc, false); DataHelper.RestoreSubscriber1(sub, false); // set current subscriber CurrentSubscriber.SetInstance(sub); // call LoadLocation action method var result = SubscriberControllerForTests.LoadLocation(loc.ID) as RedirectToRouteResult; // validate response result is not null Assert.IsNotNull(result, "RedirectToRouteResult is null"); // validate the returned RouteValues Assert.IsNotNull(result.RouteValues, "RouteValues is null"); var routeValues = result.RouteValues; Assert.AreEqual(2, routeValues.Count); Assert.AreEqual("Index", routeValues["action"], "Action does not match"); Assert.AreEqual(sub.ID, routeValues["subID"], "Subscriber ID does not match"); } catch (System.Exception ex) { Assert.IsTrue(ex is AssertFailedException, ex.ToString()); throw; } finally { DataHelper.DeleteSubscriber(sub.ID); DataHelper.DeleteLocation(loc.ID); } }
public void Index_Action_HappyPath_With_Minimal_Subscriber_And_Location() { // Arrange var loc = new LocationDto(); var sub = new SubscriberDto(); try { // new sub data loc = DataHelper.NewLocationData(); sub = DataHelper.NewSubscriberData(); sub.Accounts[0].Location = loc; sub.CustomFields = DataHelper.DefaultCustomFields_Sub(); sub.Accounts[0].ServiceEnabled = true; sub.Accounts[0].AccountType = AccountTypeDto.Residential; DataHelper.RestoreLocation1(loc, false); DataHelper.RestoreSubscriber1(sub, false); // set current subscriber CurrentSubscriber.SetInstance(sub); var subscriber = BusinessFacadeforTests.LoadCompositeSubscriber(sub.ID, string.Empty, RosettianUser); // Deliberately not checking to see if subscriber.SubscriberDpi is null as this test doesn't use that data const string strExpectedViewName = "Index2"; var expectedSubscriberModel = subscriber.MapToSubscriberModel(); // Act var actualViewResult = SubscriberControllerForTests.Index(sub.ID) as ViewResult; // Assert Assert.IsNotNull(actualViewResult, "SubscriberControllerForTests.Index returned null"); Assert.AreEqual(strExpectedViewName, actualViewResult.ViewName, "ViewName"); // 2nd Act var actualSubscriberModel = (SubscriberModel) actualViewResult.Model; // 2nd Assert Assert.IsNotNull(actualSubscriberModel, "Index_Action_HappyPath_With_Minimal_Subscriber_And_Location - unexpected model type"); const string successCode = "200"; Assert.AreEqual(successCode, actualSubscriberModel.ActionResponse.Code, "Code was expected to be {0} but was {1} - error message was {2}", successCode, actualSubscriberModel.ActionResponse.Code, actualSubscriberModel.ActionResponse.Message); var jss = new JavaScriptSerializer(); var expectedJssSerialization = jss.Serialize(expectedSubscriberModel.SubDetailsModel); var actualJssSerialization = jss.Serialize(actualSubscriberModel.SubDetailsModel); Assert.AreEqual(expectedJssSerialization, actualJssSerialization); } catch (System.Exception ex) { var exceptionHelper = new ExceptionHelper(); Assert.Fail(exceptionHelper.GetAllInnerExceptionMessagesAndStackTraceForTests(ex)); } finally { DataHelper.DeleteSubscriber(sub.ID); DataHelper.DeleteLocation(loc.ID); } }
public void UpdateMaxBandwidth_ValidateUserAbleToUpdateMaxBandwidth() { var loc = new LocationDto(); var sub = new SubscriberDto(); try { // Given a user that has permission to update provisioned location // And a valid subscriber sub = DataHelper.NewSubscriberData(); sub.CustomFields = DataHelper.DefaultCustomFields_Sub(); // And the subscriber has a valid provisioned location // And the provisioned location has a valid max bandwidth loc = DataHelper.NewLocationData(); loc.MaximumBandwidth = "19"; sub.Accounts[0].Location = loc; DataHelper.RestoreLocation1(loc, false); DataHelper.RestoreSubscriber1(sub, false); CurrentSubscriber.SetInstance(sub); // And the user edits the max bandwidth to a new valid value const string newMaximumBandwidth = "55"; loc.MaximumBandwidth = newMaximumBandwidth; // When updating max bandwith for the subscriber var result = ServicesControllerForTests.UpdateMaxBandwidth(loc.ID, loc.MaximumBandwidth) as JsonResult; // Then the user receives a response Assert.IsNotNull(result, "Json result is null"); Assert.IsNotNull(result.Data, "Json result data is null"); // And the response is successful var jss = new JavaScriptSerializer(); var expectedResult = new { status = "valid", message = string.Format("Successfully updated Max Bandwidth to {0} MB", newMaximumBandwidth) }.ToJSON(); Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(result.Data.ToJSON())); // And the max bandwidth is updated in provisioning system var actualLoc = DataHelper.LoadLocation(loc.ID); Assert.IsNotNull(actualLoc, "Location should not be null!"); Assert.AreEqual(loc.ID, actualLoc.ID, "Location ID does not match!"); Assert.AreEqual(loc.MaximumBandwidth, actualLoc.MaximumBandwidth, "MaximumBandwidth does not match"); // And any other info on the location remains unchanges Assert.AreEqual(loc.AddressLine1, actualLoc.AddressLine1, "Address1 does not match"); // And the max bandwidth is updated in current subscriber session Assert.AreEqual(newMaximumBandwidth, CurrentSubscriber.GetInstance().MaxBandwidth, "Maxbandwidth does not match"); } catch (System.Exception ex) { Assert.IsTrue(ex is AssertFailedException, ex.ToString()); throw; } finally { DataHelper.DeleteSubscriber(sub.ID); DataHelper.DeleteLocation(loc.ID); } }
public void ChangeLocation_Succeed() { var loc = new LocationDto(); var loc2 = new LocationDto(); var sub = new SubscriberDto(); try { // new sub and loc data loc = DataHelper.NewLocationData(); loc.RateCenterName = "WASHINGTON"; loc.NetworkLocationCode = "1234567"; loc2 = DataHelper.NewLocationData(); loc2.RateCenterName = "STAMFORD"; loc2.NetworkLocationCode = "2345668"; sub = DataHelper.NewSubscriberData(); sub.Accounts[0].Location = loc; sub.CustomFields = DataHelper.DefaultCustomFields_Sub(); DataHelper.RestoreLocation1(loc, false); DataHelper.RestoreSubscriber1(sub, false); DataHelper.RestoreLocation1(loc2, false); // set current subscriber CurrentSubscriber.SetInstance(sub); var loc2AsJson = JavaScriptSerializerUtil.Serialize(loc2); // call ChangeLocation action method var actualResult = LocationController4Tests.ChangeLocation(loc2AsJson) as PartialViewResult; // validate returned result and model are not null Assert.IsTrue(actualResult != null && actualResult.Model != null); // validate model var resultModel = actualResult.Model as SubscriberLocationModel; Assert.IsNotNull(resultModel, "Model should not be null"); // validate returned action response var expectedActionResponse = new RozResponseDto { Code = "200", Message = string.Format("Successfully changed location from [{0}] to [{1}] for subscriber [{2}]", loc.ID, loc2.ID, sub.ID) }; Assert.IsNotNull(resultModel.ActionResponse, "ActionResponse should not be null"); Assert.AreEqual(expectedActionResponse.Code, resultModel.ActionResponse.Code); Assert.AreEqual(expectedActionResponse.Message, resultModel.ActionResponse.Message); // validate location changed for subscriber in db var actualSub = DataHelper.LoadSubscriber(sub.ID); Assert.AreEqual(loc2.ID, actualSub.Accounts[0].Location.ID, "Subscriber location id does not match"); } catch (Exception ex) { Assert.IsTrue(ex is AssertFailedException, ex.ToString()); throw; } finally { DataHelper.DeleteSubscriber(sub.ID); DataHelper.DeleteLocation(loc.ID); DataHelper.DeleteLocation(loc2.ID); } }
public void LoadEquipment_EquipmentHasSubscriber_ValidateUserAbleToLoadEquipment() { using (ShimsContext.Create()) { // Given a user ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject(); // And a subscriber const string subId = "subId"; // And the subscriber has a valid provisioned location const string locId = "locId"; var location = new LocationDto {ID = locId}; // And the location has a valid equipment const string equipId = "equipId"; var equip = new EquipmentCollectionDto { new EquipmentDto { AssociatedSubscriberId = subId, LocationId = locId, SerialNumber = equipId } }; var subscriber = new SubscriberDto { ID = subId, Accounts = new List<AccountDto> { new AccountDto { Location = location, Equipment = equip } } }; // When loading that equipment ShimRosettianClient.AllInstances.SearchSubscribersSearchFieldsDtoUserDto = (myTestClient, mySearchCriteria, myUserDto) => new List<SubscriberDto> { subscriber }; ShimRosettianClient.AllInstances.SearchLocationsSearchFieldsDtoUserDto = (myTestClient, mySearchCriteria, myUserDto) => new LocationCollectionDto {location}; var actionResponse = SubscriberControllerForTests.LoadEquipment(equipId) as RedirectToRouteResult; // Then the user receives a response Assert.IsNotNull(actionResponse, "SubscriberController LoadEquipment method returned null"); // And the response is successful // And the response redirects the route values correctly to subscriber index var jss = new JavaScriptSerializer(); var expectedRouteValues = new RouteValueDictionary { {"subID", subId}, {"devID", equipId}, {"action", "Index"}, }; var actualRouteValues = actionResponse.RouteValues; Assert.AreEqual(jss.Serialize(expectedRouteValues), jss.Serialize(actualRouteValues)); } }
public void UpdateLocation_ClearAddresses_ClearRateCenter_ClearNetworkLocationCode_Succeed() { var loc = new LocationDto(); var sub = new SubscriberDto(); try { // new sub and loc data loc = DataHelper.NewLocationData(); loc.RateCenterName = "WASHINGTON"; loc.NetworkLocationCode = "1234567"; sub = DataHelper.NewSubscriberData(); sub.Accounts[0].Location = loc; sub.CustomFields = DataHelper.DefaultCustomFields_Sub(); DataHelper.RestoreLocation1(loc, false); DataHelper.RestoreSubscriber1(sub, false); // set current subscriber CurrentSubscriber.SetInstance(sub); // edit location loc.AddressLine1 = ""; loc.AddressLine2 += ""; loc.RateCenterName = ""; loc.NetworkLocationCode = ""; loc.CityName = ""; loc.StateName = "CT"; loc.ZipCode = ""; loc.HeadendCode = "05"; // map the loc to SubscriberLocationModel var subLocModel = loc.MapToSubLocationModel(); // call UpdateLocation action method var result = LocationController4Tests.UpdateLocation(subLocModel) as JsonResult; // validate response result Assert.IsNotNull(result, "Json result is null"); Assert.IsNotNull(result.Data, "Json result data is null"); dynamic resultStatus = result.Data; Assert.AreEqual("valid", resultStatus.status as string, "Response status does not match!"); // validate the current subscriber session got updated var currentSubscriber = CurrentSubscriber.GetInstance(); var actualSubLocModel = currentSubscriber.MapToSubLocationModel(); ValidateLocation(subLocModel, actualSubLocModel); // validate location updated in db var actualLoc = DataHelper.LoadLocation(loc.ID); Assert.IsNotNull(actualLoc, "Location should not be null!"); ValidateLocation(loc, actualLoc); } catch (Exception ex) { Assert.IsTrue(ex is AssertFailedException, ex.ToString()); throw; } finally { DataHelper.DeleteSubscriber(sub.ID); DataHelper.DeleteLocation(loc.ID); } }
private static void ValidateLocation(LocationDto expected, LocationDto actual) { Assert.AreEqual(expected.ID, actual.ID, "Location ID does not match"); Assert.AreEqual(expected.AddressLine1, actual.AddressLine1, "AddressLine1 does not match"); Assert.AreEqual(expected.AddressLine2, actual.AddressLine2, "Address2 does not match"); Assert.AreEqual(expected.StateName, actual.StateName, "StateName does not match"); Assert.AreEqual(expected.CityName, actual.CityName, "CityName does not match"); Assert.AreEqual(expected.ZipCode, actual.ZipCode, "ZipCode does not match"); Assert.AreEqual(expected.HeadendCode, actual.HeadendCode, "HeadendCode does not match"); Assert.AreEqual(expected.RateCenterName, actual.RateCenterName, "RateCenter does not match"); Assert.AreEqual(expected.NetworkLocationCode, actual.NetworkLocationCode, "NetworkLocatonCode does not match"); }
public void DeleteLocation_Succeed() { var loc = new LocationDto(); try { // new sub and loc data loc = DataHelper.NewLocationData(); DataHelper.RestoreLocation1(loc, false); // expected json result var expectedResult = new { status = "success", successMessage = String.Format("Successfully deleted location [{0}]", loc.ID) }.ToJSON(); // call DeleteLocation action method var result = LocationController4Tests.DeleteLocation(loc.ID) as JsonResult; // validate the json result var jss = new JavaScriptSerializer(); Assert.IsNotNull(result, "Json result is null"); Assert.IsNotNull(result.Data, "Json result data is null"); Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(result.Data.ToJSON())); // validate location deleted db var locExists = DataHelper.LocationExists(loc.ID); Assert.IsFalse(locExists, "Location should be deleted!"); } catch (Exception ex) { Assert.IsTrue(ex is AssertFailedException, ex.ToString()); throw; } finally { DataHelper.DeleteLocation(loc.ID); } }
public void ClearLocation_Succeed() { var loc = new LocationDto(); var sub = new SubscriberDto(); try { // new sub and loc data loc = DataHelper.NewLocationData(); loc.RateCenterName = "WASHINGTON"; loc.NetworkLocationCode = "1234567"; sub = DataHelper.NewSubscriberData(); sub.Accounts[0].Location = loc; sub.CustomFields = DataHelper.DefaultCustomFields_Sub(); DataHelper.RestoreLocation1(loc, false); DataHelper.RestoreSubscriber1(sub, false); // set current subscriber CurrentSubscriber.SetInstance(sub); // call ClearLocation action method var actualResult = LocationController4Tests.ClearLocation(loc.ID) as PartialViewResult; // validate returned result and model are not null Assert.IsTrue(actualResult != null && actualResult.Model != null); // validate model var resultModel = actualResult.Model as SubscriberLocationModel; Assert.IsNotNull(resultModel, "Model should not be null"); // validate returned action response var expectedActionResponse = new RozResponseDto { Code = "200", Message = String.Format("Successfully disassociated subscriber from location [{0}]", loc.ID) }; Assert.IsNotNull(resultModel.ActionResponse, "ActionResponse should not be null"); Assert.AreEqual(expectedActionResponse.Code, resultModel.ActionResponse.Code); Assert.AreEqual(expectedActionResponse.Message, resultModel.ActionResponse.Message); // validate location cleared for subscriber in db var actualSub = DataHelper.LoadSubscriber(sub.ID); Assert.IsTrue(actualSub!=null && actualSub.Accounts.Any() && actualSub.Accounts[0]!=null); Assert.IsTrue(actualSub.Accounts[0].Location == null || string.IsNullOrEmpty(actualSub.Accounts[0].Location.ID)); } catch (Exception ex) { Assert.IsTrue(ex is AssertFailedException, ex.ToString()); throw; } finally { DataHelper.DeleteSubscriber(sub.ID); DataHelper.DeleteLocation(loc.ID); } }
public void Index_ProvisioningLocation_withAddresses_withRateCenter_withNetworkLocCode() { using (ShimsContext.Create()) { // Fake the session state for HttpContext var session = new ShimHttpSessionState { ItemGetString = s => { if (s == "") return null; return null; } }; // Fake the HttpContext var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; // When the Fake HttpContext is called, provide the fake session state ShimHttpContext.AllInstances.SessionGet = (o) => session; var customer = new CustomerDto(); customer.CitizensPostalAddress.AddressTexts.Add(new AddressTextDto() { Address = "TestBillingAddress", SequenceNumber = 0 }); var billingAccountId = new BillingAccountIdDto(); billingAccountId.PhoneNumberAsId.TelephoneNumber.Number = "TestBillingNumber"; ShimCurrentSubscriber.AllInstances.CurrentBillingAccountGet = (myTest) => new CustomerAccountDto() { Customer = customer, BillingAccountId = billingAccountId }; // service account var serviceAccount = new ServiceAccountDto { Address = new ServiceAddressDto{ Address1 = "TestServiceAddress"}, IsBTN = false, SubscriberName = "TestServiceName", TN = "TestServiceNumber", USI = "TestServiceUSI", }; ShimCurrentSubscriber.AllInstances.CurrentServiceAccountGet = (myTest) => serviceAccount; // Expected provisioning locaton var provLocation = new LocationDto { ID = "12345666666444", AddressLine1 = "ADDRESS1", AddressLine2 = "ADDRESS2", CityName = "CITY", StateName = "STATE WA", ZipCode = "12345", HeadendCode = "01", NetworkLocationCode = "1234567", RateCenterName = "123456", }; // CurrentSubscriber location ShimCurrentSubscriber.AllInstances.LocationIdGet = (myTestParam) => provLocation.ID; ShimCurrentSubscriber.AllInstances.AddressGet = (myTestParam) => provLocation.AddressLine1; ShimCurrentSubscriber.AllInstances.Address2Get = (myTestParam) => provLocation.AddressLine2; ShimCurrentSubscriber.AllInstances.CityGet = (myTestParam) => provLocation.CityName; ShimCurrentSubscriber.AllInstances.StateGet = (myTestParam) => provLocation.StateName; ShimCurrentSubscriber.AllInstances.ZipGet = (myTestParam) => provLocation.ZipCode; ShimCurrentSubscriber.AllInstances.HeadendCodeGet = (myTestParam) => provLocation.HeadendCode; ShimCurrentSubscriber.AllInstances.RateCenterGet = (myTestParam) => provLocation.RateCenterName; ShimCurrentSubscriber.AllInstances.NetworkLocationCodeGet = (myTestParam) => provLocation.NetworkLocationCode; ShimCurrentSubscriber.AllInstances.SubIdGet = (myTestParam) => "TestSub"; // account controller var accountsController = DependencyResolver.Current.GetService<AccountsController>(); // call Index action method var result = accountsController.Index(); // results is no null Assert.IsNotNull(result); var accountTuple = (AccountTuple) result.Model; // validate billing info Assert.IsTrue(accountTuple.BillingAccount.Address.AddressLine1.Equals("TestBillingAddress")); Assert.IsTrue(accountTuple.BillingAccount.TN.Equals("TestBillingNumber")); // validate service address Assert.AreEqual(serviceAccount.Address.Address1, accountTuple.ServiceAccount.Addresses.ServiceAddress.AddressLine1, "Service Address1 does not match"); Assert.IsTrue(accountTuple.ServiceAccount.TN.Equals("TestServiceNumber")); // validate provisioning location; var actualProvLocaton = accountTuple.ServiceAccount.Addresses.ProvisioningAddress.Location; Assert.AreEqual(provLocation.ID, actualProvLocaton.LocationID, "Location ID does not match"); Assert.AreEqual(provLocation.AddressLine1, actualProvLocaton.Address1, "Address1 does not match"); Assert.AreEqual(provLocation.AddressLine2, actualProvLocaton.Address2, "Address2 does not match"); Assert.AreEqual(provLocation.HeadendCode, actualProvLocaton.Headend, "Headend does not match"); Assert.AreEqual(provLocation.CityName, actualProvLocaton.City, "City does not match"); Assert.AreEqual(provLocation.StateName, actualProvLocaton.State, "State does not match"); Assert.AreEqual(provLocation.RateCenterName, actualProvLocaton.RateCenter, "RateCenter does not match"); Assert.AreEqual(provLocation.NetworkLocationCode, actualProvLocaton.NetworkLocationCode, "NetworkLocationCode does not match"); } }
public void UpdateSubscriberServiceStatus_SubNotFoundInDPI_ValidateEnableScenario() { var loc = new LocationDto(); var sub = new SubscriberDto(); try { // new sub and loc data loc = DataHelper.NewLocationData(); sub = DataHelper.NewSubscriberData(); sub.Accounts[0].Location = loc; sub.Accounts[0].ServiceEnabled = false; sub.CustomFields = DataHelper.DefaultCustomFields_Sub(); DataHelper.RestoreLocation1(loc, false); DataHelper.RestoreSubscriber1(sub, false); // set current subscriber CurrentSubscriber.SetInstance(sub); // call UpdateSubscriberServiceStatus action method var result = SubscriberControllerForTests.UpdateSubscriberServiceStatus(true) as JsonResult; // expected subDetailsModel after UpdateSubscriberServiceStatus sub.Accounts[0].ServiceEnabled = true; var subDetailsModel = sub.MapToSubDetailsModel(); // validate response result Assert.IsNotNull(result, "Json result is null"); Assert.IsNotNull(result.Data, "Json result data is null"); dynamic resultStatus = result.Data; Assert.AreEqual("valid", resultStatus.status as string, "Response status does not match!"); // validate service enabled in db var actualSub = DataHelper.LoadSubscriber(sub.ID); Assert.IsNotNull(actualSub, "Subscriber should not be null!"); Assert.AreEqual(sub.ID, actualSub.ID); Assert.AreEqual(sub.Accounts[0].ServiceEnabled, actualSub.Accounts[0].ServiceEnabled); // validate the current subscriber session got updated var currentSubscriber = CurrentSubscriber.GetInstance(); var actualSubDetailsModel = currentSubscriber.MapToSubDetailsModel(); // validate FoundInBilling should be false Assert.IsFalse(actualSubDetailsModel.FoundInBilling, "FoundInBilling should be false"); // validate actualSubDetailsModel matches expectedSubDetailsModel Assert.AreEqual(subDetailsModel.USI, actualSubDetailsModel.USI, "USI does not match"); Assert.AreEqual(subDetailsModel.Name, actualSubDetailsModel.Name, "Name does not match"); Assert.AreEqual(subDetailsModel.FoundInBilling, actualSubDetailsModel.FoundInBilling, "FoundInBilling does not match"); Assert.AreEqual(subDetailsModel.CurrentServiceStatus, actualSubDetailsModel.CurrentServiceStatus, "CurrentServiceStatus does not match"); Assert.IsTrue(actualSubDetailsModel.ServiceStatusDisplay.Contains("Enabled"), "ServiceStatusDisplay does not match"); } catch (System.Exception ex) { Assert.IsTrue(ex is AssertFailedException, ex.ToString()); throw; } finally { DataHelper.DeleteSubscriber(sub.ID); DataHelper.DeleteLocation(loc.ID); } }
/// <summary> /// GetFakeLocationDtoObject - returns LocationDto /// </summary> /// <param name="locationId"></param> /// <param name="hasSubscriber"></param> /// <returns></returns> public LocationDto GetFakeLocationDtoObject(string locationId = "9999999", bool hasSubscriber = true) { var fakeLocationDto = new LocationDto() { AddressLine1 = "123 Fake St.", AddressLine2 = "Apt 2", CityName = "Fake City", CustomFields = new List<CustomFieldDto>(), FacilityList = new List<FacilityDto>(), HasSubscriber = hasSubscriber, ID = locationId, HeadendCode = "01", IsBillingAddress = false, RateCenterName = "1234", }; return fakeLocationDto; }
public void UpdateSubscriber_UpdateName_UpdateCBR_UpdateTriadEmail_UpdateAccountType_ValidateSuccessScenario() { var loc = new LocationDto(); var sub = new SubscriberDto(); try { // Given a user // And a subscriber sub = DataHelper.NewSubscriberData(); sub.CustomFields = DataHelper.DefaultCustomFields_Sub(); // And the subscriber has a residential account sub.Accounts[0].AccountType = AccountTypeDto.Residential; // And the subscriber has service enabled sub.Accounts[0].ServiceEnabled = true; // And the subscriber has a location loc = DataHelper.NewLocationData(); sub.Accounts[0].Location = loc; // And the location is a valid provisioning location DataHelper.RestoreLocation1(loc, false); // And the subscriber is a valid provisioning subscriber DataHelper.RestoreSubscriber1(sub, false); // And the subscriber to be updated CurrentSubscriber.SetInstance(sub); var subDetailsModel = sub.MapToSubDetailsModel(); // And the subscriber name needs to be changed on the provisioned account subDetailsModel.Name += " UPDATED"; // And the subscriber cbr needs to be changed on the provisioned account subDetailsModel.CBR = new string(sub.SubContactPhone.Reverse().ToArray()); // And the subscriber triad email needs to be changed on the provisioned account subDetailsModel.TriadEmail = sub.SubContactEmail + ".updated"; // And the subscriber account type needs to be changed on the provisioned account subDetailsModel.AccountType = AccountTypeDto.Business; // When updating the subscriber var result = SubscriberControllerForTests.UpdateSubscriber(subDetailsModel) as JsonResult; // Then the user receives a response Assert.IsNotNull(result, "Json result is null"); Assert.IsNotNull(result.Data, "Json result data is null"); // And the response is successful dynamic resultStatus = result.Data; Assert.AreEqual("valid", resultStatus.status as string, "Response status does not match!"); // And the subscriber details in current subscriber session is updated properly var currentSubscriber = CurrentSubscriber.GetInstance(); var actualSubDetailsModel = currentSubscriber.MapToSubDetailsModel(); // And the USI remains unchanged in current subscriber session Assert.AreEqual(subDetailsModel.USI, actualSubDetailsModel.USI, "USI does not match"); // And the subscriber name is updated in current subscriber session Assert.AreEqual(subDetailsModel.Name, actualSubDetailsModel.Name, "Name does not match"); // And the subscriber account type is updated in current subscriber session Assert.AreEqual(subDetailsModel.AccountType, actualSubDetailsModel.AccountType, "AccountType does not match"); // And the subscriber cbr is updated in current subscriber session Assert.AreEqual(subDetailsModel.CBR, actualSubDetailsModel.CBR, "CBR does not match"); // And the subscriber triad email is updated in current subscriber session Assert.AreEqual(subDetailsModel.TriadEmail, actualSubDetailsModel.TriadEmail, true, "TriadEmail does not match"); // And the FoundInBilling flag remains unchanged in current subscriber session Assert.AreEqual(subDetailsModel.FoundInBilling, actualSubDetailsModel.FoundInBilling, "FoundInBilling does not match"); // And the CurrentServiceStatus remains unchanged in current subscriber session Assert.AreEqual(subDetailsModel.CurrentServiceStatus, actualSubDetailsModel.CurrentServiceStatus, "CurrentServiceStatus does not match"); // And the ServiceStatusDisplay remains unchanged in current subscriber session Assert.IsTrue(actualSubDetailsModel.ServiceStatusDisplay.Contains("Enabled"), "ServiceStatusDisplay does not match"); // And Load updated subscriber var actualSubscriber = DataHelper.LoadSubscriber(sub.ID); Assert.IsTrue(actualSubscriber != null); Assert.AreEqual(subDetailsModel.USI, actualSubscriber.ID, "Subscriber id does not match"); Assert.IsTrue(actualSubscriber.Accounts != null && actualSubscriber.Accounts.FirstOrDefault() != null); // And the subscriber name is updated in provisioning system (triad) Assert.AreEqual(subDetailsModel.Name, actualSubscriber.Name, "Name does not match"); // And the subscriber account type is updated in provisioning system (triad) Assert.AreEqual(subDetailsModel.AccountType, actualSubscriber.Accounts.First().AccountType, "AccountType does not match"); // And the subscriber CBR is updated in provisioning system (triad) Assert.AreEqual(subDetailsModel.CBR, actualSubscriber.SubContactPhone, "CBR does not match"); // And the subscriber triad email is updated in provisioning system (triad) Assert.AreEqual(subDetailsModel.TriadEmail, actualSubscriber.SubContactEmail, true, "TriadEmail does not match"); } catch (System.Exception ex) { Assert.IsTrue(ex is AssertFailedException, ex.ToString()); throw; } finally { DataHelper.DeleteSubscriber(sub.ID); DataHelper.DeleteLocation(loc.ID); } }
/// <summary> /// The build location. /// </summary> /// <param name="dto"> /// The dto. /// </param> /// <returns> /// The <see cref="ILocation"/>. /// </returns> public ILocation BuildLocation(LocationDto dto) { return new Location()//new CustomFieldsCollection(dto.FieldValues) { Key = dto.Key, Name = dto.Name, LocationTypeId = dto.LocationTypeId, Coordinate = _geography.GetCoordinateFromStPointText(dto.Coordinate), Viewport = _geography.GetViewportFromStLinestringText(dto.Viewport), GeocodeStatus = (GeocodeStatus)Enum.Parse(typeof(GeocodeStatus), dto.GeocodeStatus), UpdateDate = dto.UpdateDate, CreateDate = dto.CreateDate }; }
/// <summary> /// RestoreLocation - calls RestoreLocation1 /// </summary> /// <param name="loc"></param> public static void RestoreLocation(LocationDto loc) { RestoreLocation1(loc, true); }
protected static LocationDto DefaultAddress(string locId) { var loc = new LocationDto { ID = locId, AddressLine1 = "1800 41ST ST", CityName = "EVERETT", StateName = "WA", ZipCode = "98201", HeadendCode = "04" }; return loc; }
public void CreateLocation_With_Address_NetworkLocationCode_RateCenter_MaxBandwidth_ValidateUserAbleToCreateLocation() { var loc = new LocationDto(); try { // Given a user that has permission to create new location // And a new location with all valid info // And the new location has a valid address loc = DataHelper.NewLocationData(); // And the new location has a valid max bandwidth loc.MaximumBandwidth = "20"; // And the new location has a valid network location code loc.NetworkLocationCode = "1234567"; // And the new location has a valid rate center name loc.RateCenterName = "washington"; var createLocModel = new CreateLocationModel { LocationID = loc.ID, Address1 = loc.AddressLine1, Address2 = loc.AddressLine2, City = loc.CityName, State = loc.StateName, ZipCode = loc.ZipCode, MaxBandwidth = loc.MaximumBandwidth, NetworkLocationCode = loc.NetworkLocationCode, RateCenter = loc.RateCenterName }; // When creating new location with the valid location info var actionResult = SearchControllerForTest.CreateLocation(createLocModel) as JsonResult; // Then the user receives a response Assert.IsNotNull(actionResult, "Json result is null"); Assert.IsNotNull(actionResult.Data, "Json result data is null"); // And the response is successful var jss = new JavaScriptSerializer(); var expectedResult = new { status = "valid", isModal = false, newLocationID = loc.ID }.ToJSON(); Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResult.Data.ToJSON())); // And the new location created in provisioning system var actualLoc = DataHelper.LoadLocation(loc.ID); Assert.IsNotNull(actualLoc, "Location should not be null!"); Assert.AreEqual(loc.ID, actualLoc.ID, "Location ID does not match!"); // And the new location created with the requested addresses Assert.AreEqual(loc.AddressLine1, actualLoc.AddressLine1, "Address1 does not match"); Assert.AreEqual(loc.AddressLine2, actualLoc.AddressLine2, "Address2 does not match"); Assert.AreEqual(loc.CityName, actualLoc.CityName, "CityName does not match"); Assert.AreEqual(loc.StateName, actualLoc.StateName, "StateName does not match"); Assert.AreEqual(loc.ZipCode, actualLoc.ZipCode, "ZipCode does not match"); // And the new location created with the requested max bandwidth Assert.AreEqual(loc.MaximumBandwidth, actualLoc.MaximumBandwidth, "MaximumBandwidth does not match"); // And the new location created with the requested NetworkLocationCode Assert.AreEqual(loc.NetworkLocationCode, actualLoc.NetworkLocationCode, true,"NetworkLocationCode does not match"); // And the new location created with the requested RateCenterName Assert.AreEqual(loc.RateCenterName, actualLoc.RateCenterName, true,"Rate Center does not match"); } catch (Exception ex) { Assert.IsTrue(ex is AssertFailedException, ex.ToString()); throw; } finally { DataHelper.DeleteLocation(loc.ID); } }
/// <summary> /// RestoreLocation1 - calls either Rosettian CreateLocation or UpdateLocation /// </summary> /// <param name="loc"></param> /// <param name="requiresUpdates"></param> public static void RestoreLocation1(LocationDto loc, bool requiresUpdates) { using (var client = new RosettianClient()) { if (!client.LocationExists(loc.ID, user)) { client.CreateLocation(loc, user); } else if (requiresUpdates) { client.UpdateLocation(loc, user); } } }