public void TestGetIncumbents() { IRequestParameters requestParams = this.GetRequestParams( req => { req.RegionName = "United States"; req.AccessToken = "Whitespace001"; req.Params = new Parameters { IncumbentType = "MPVD", Registrant = new Vcard { Organization = new Organization { Text = "FCC" } }, MVPDLocation = new Location { Latitude = 3, Longitude = 3 }, TvSpectrum = new TvSpectrum { CallSign = "DTV", Channel = 24 } }; }); RegionManagementResponse expectedResponse = this.GetResponse( response => { response.Result = new Result { IncumbentList = new object[] { new Microsoft.Whitespace.Entities.Incumbent { AntennaId = 1, AntennaType = "SNG-B", IncumbentType = IncumbentType.MVPD }, new Microsoft.Whitespace.Entities.Incumbent { AntennaId = 2, AntennaType = "SNG-B", IncumbentType = IncumbentType.MVPD } } }; }); this.httpClientManager.PostOf1RequestStringString <RegionManagementResponse>((request, regionName, accessToken) => expectedResponse); var actualResponse = this.whitespacesDataClient.GetIncumbents(requestParams); Assert.AreEqual(expectedResponse.Result.IncumbentList.Count(), actualResponse.IncumbentList.Count()); }
/// <summary> /// This method Return the response /// </summary> /// <param name="responseInitializer">Response which we are initializing</param> /// <returns>Returning RegionManagementResponse</returns> private RegionManagementResponse GetResponse(Action <RegionManagementResponse> responseInitializer) { RegionManagementResponse response = new RegionManagementResponse(); responseInitializer(response); return(response); }
public void TestGetChannelList() { IRequestParameters requestParams = this.GetRequestParams( req => { req.RegionName = "United States"; req.Params = new Parameters { IncumbentType = "MVPD", Location = new GeoLocation { Point = new Ellipse { Center = new Point { Latitude = "40.5", Longitude = "-74" } } } }; }); RegionManagementResponse expectedResponse = this.GetResponse( response => { response.Result = new Result { ChannelInfo = new ChannelInfo[] { new ChannelInfo { ChannelId = 2, DeviceType = "Fixed" }, new ChannelInfo { ChannelId = 3, DeviceType = "Fixed" } } }; }); this.httpClientManager.PostOf1RequestStringString <RegionManagementResponse>((request, regionName, accessToken) => expectedResponse); var actualResponse = this.whitespacesDataClient.GetChannelList(requestParams); Assert.AreEqual(expectedResponse.Result.ChannelInfo.Count(), actualResponse.ChannelInfo.Count()); }
private string GetJsonString(string regionName, string methodName, string entityType = null) { Request request = new Request { Method = methodName, Params = new Parameters { IncumbentType = entityType, } }; RegionManagementResponse response = null; if (entityType != null) { var regionManagementResponsestring = this.httpManager.Post(request, regionName); response = JsonConvert.DeserializeObject <RegionManagementResponse>(regionManagementResponsestring); } else { response = this.httpManager.Get <RegionManagementResponse>(request, regionName); } if (response != null) { var error = response.Error; if (error == null) { if (response.Result.IncumbentList != null) { return(JsonConvert.SerializeObject(response.Result.IncumbentList)); } } else if (string.Equals(error.Data, Microsoft.Whitespace.Entities.Constants.ErrorMessageNoData, StringComparison.OrdinalIgnoreCase)) { return(Microsoft.Whitespace.Entities.Constants.ErrorMessageNoData); } else { throw new ResponseErrorException(error.Type, error.Data, error.Code, error.Message); } } return(string.Empty); }
private Result GetResultFromResponse(RegionManagementResponse response) { var error = response.Error; if (error == null) { return(response.Result); } else if (error != null && string.Compare(error.Data, MWEC.ErrorMessageNoData, StringComparison.OrdinalIgnoreCase) == 0) { return(response.Error); } else { throw new ResponseErrorException(error.Type, error.Data, error.Code, error.Message); } }
public async Task <Result> GetMvpdCallsignInfoAsync(string callsign, string regionName) { Request request = new Request { Method = Microsoft.WhiteSpaces.Common.Constants.MethodGetMVPDCallSignInfo, }; RegionManagementResponse response = await this.httpManager.GetAsync <RegionManagementResponse>(request, regionName, callsign); var error = response.Error; if (error != null) { throw new ResponseErrorException(error.Type, error.Data, error.Code, error.Message); } return(response.Result); }