public void AddressCreate_Success() { var fakedContext = new XrmFakedContext(); //input object does not contain to record id which is mandatory. string InputLoad = @" { recordtype: 'contact', recordid: '37e64f21-c035-4e49-a6b6-958cdd3af45e', 'address': { 'type': 1, 'uprn': 3458999, 'buildingname': 'Horizon', 'buildingnumber': '3', 'street': 'Road', 'locality': '', 'town': '', 'postcode': '12345678', 'country': 'gbr', 'fromcompanieshouse': '' } } "; //Inputs var inputs = new Dictionary <string, object>() { { "ReqPayload", InputLoad }, }; Contact fakeContact = new Contact(); fakeContact.ContactId = new Guid("37e64f21-c035-4e49-a6b6-958cdd3af45e"); fakeContact.Id = new Guid("37e64f21-c035-4e49-a6b6-958cdd3af45e"); defra_country Country = new defra_country(); Country.defra_isocodealpha3 = "GBR"; Country.Id = Guid.NewGuid(); fakedContext.Initialize(new List <Entity>() { Country, fakeContact }); var result = fakedContext.ExecuteCodeActivity <AddAddress>(inputs); var address = fakedContext.CreateQuery <defra_address>(); #region ErrorMessagesToCheck #endregion String ReturnMessage = (String)result["ResPayload"]; AddressResponse AddressResponseObject = Newtonsoft.Json.JsonConvert.DeserializeObject <AddressResponse>(ReturnMessage); String ErrorDetails = AddressResponseObject.message; Assert.IsNotNull(AddressResponseObject.data.addressid); }
public async Task Run() { var sdk = new Nullafi.NullafiSDK(Environment.GetEnvironmentVariable("API_KEY")); var client = await sdk.CreateClient(); var staticVault = await client.CreateStaticVault("Address Vault Example", null); AddressResponse created = await Create(staticVault); AddressResponse retrieved = await Retrieve(staticVault, created.Id); await RetrieveFromRealData(staticVault, created.Address); await Delete(staticVault, retrieved.Id); Assert.AreEqual(created.Id, retrieved.Id); Assert.AreEqual(created.Address, retrieved.Address); Assert.AreEqual(created.AddressAlias, retrieved.AddressAlias); AddressResponse createdWithState = await CreateWithState(staticVault); AddressResponse retrievedWithState = await Retrieve(staticVault, createdWithState.Id); await RetrieveFromRealData(staticVault, createdWithState.Address); await Delete(staticVault, retrievedWithState.Id); Assert.AreEqual(createdWithState.Id, retrievedWithState.Id); Assert.AreEqual(createdWithState.Address, retrievedWithState.Address); Assert.AreEqual(createdWithState.AddressAlias, retrievedWithState.AddressAlias); await client.DeleteStaticVault(staticVault.VaultId); }
public AddressResponse getServerAddressWithPort(string myMacAddress) { string[] bRet = new string[3]; Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); // Addressing IPAddress ipAddress = IPAddress.Parse(Constants.SERVER_IP_ADDR); IPEndPoint serverEndPoint = new IPEndPoint(ipAddress, Constants.PORT); try { clientSocket.Connect(serverEndPoint); byte[] toSend = System.Text.Encoding.UTF8.GetBytes(GETPORT); byte[] toSend2 = System.Text.Encoding.UTF8.GetBytes((myMacAddress + '\0')); byte[] bufferReceive = new byte[1000]; Send(clientSocket, toSend, 0, toSend.Length, 5000); Send(clientSocket, toSend2, 0, toSend2.Length, 5000); string port = receive(clientSocket); clientSocket.Close(); AddressResponse response = new AddressResponse(Constants.SERVER_IP_ADDR, port.Remove(port.Length - 1), CurrentTimeMillis()); return(response); } catch (SocketException e) { AddressResponse response2 = new AddressResponse(Constants.SERVER_IP_ADDR, "" + 404, -2); return(response2); } }
public void MapsAnAddressDomainDirectlyToAnAddressResponse() { // Arrange var domain = _fixture.Create <Address>(); var response = domain.ToResponse(); // make an exception for SingleLineAddress var address = new AddressResponse() { Line1 = domain.Line1, Line2 = domain.Line2, Line3 = domain.Line3, Line4 = domain.Line4, Town = domain.Town, Postcode = domain.Postcode, }; // Act var exceptions = new Dictionary <string, object>() { { "SingleLineAddress", address.SingleLineAddress } }; // Assert response.ShouldBeEquivalentToExpectedObjectWithExceptions(domain, exceptions); }
public void UpdateFromResponse(AddressResponse response) { Code = response.Code; FkClientServerId = response.FkClientServerId; FkCheminServerId = response.FkCheminServerId; Prenom = response.Prenom; Nom = response.Nom; Societe = response.Societe; Adresse = response.Adresse; CodePostal = response.CodePostal; Ville = response.Ville; DepartmentFr = response.DepartmentFr; Region = response.Region; Longitude = response.Longitude; Latitude = response.Latitude; Altitude = response.Altitude; HeureLundi = response.HeureLundi; HeureMardi = response.HeureMardi; HeureMercredi = response.HeureMercredi; HeureJeudi = response.HeureJeudi; HeureVendredi = response.HeureVendredi; HeureSamedi = response.HeureSamedi; HeureDimanche = response.HeureDimanche; IsBonPassage = response.IsBonPassage; IsCle = response.IsCle; Comment = response.Comment; IsActif = response.IsActif; SynchronizationDate = response.SynchronizationDate ?? DateTime.Now; }
/// <summary> /// This test case tests attempting to add an improperly formed address /// </summary> static void testCaseAddAddressNegative() { AddressMaintenance am = new AddressMaintenance(); try { AddressRequest request = new AddressRequest(); request.StateAbbreviation = "WA"; request.Name = ""; request.City = ""; request.AddressLine1 = ""; request.AddressLine2 = "Address LIne 56"; request.Company = ""; request.ZipCode = ""; AddressResponse response = am.addAddress(request); if (response.Status != "Success") { Console.WriteLine("Exceptions:"); foreach (string e in response.exceptions) { Console.WriteLine(e); } } else { Console.WriteLine("Address id = " + response.id.ToString()); } } catch (Exception exp) { Console.WriteLine(exp.Message); } }
public void ModelFactory_Merchant_IsConverted() { Merchant merchantModel = TestData.MerchantModelWithAddressesContactsDevicesAndOperators; ModelFactory modelFactory = new ModelFactory(); MerchantResponse merchantResponse = modelFactory.ConvertFrom(merchantModel); merchantResponse.ShouldNotBeNull(); merchantResponse.MerchantId.ShouldBe(merchantModel.MerchantId); merchantResponse.MerchantName.ShouldBe(merchantModel.MerchantName); merchantResponse.EstateId.ShouldBe(merchantModel.EstateId); merchantResponse.Addresses.ShouldHaveSingleItem(); AddressResponse addressResponse = merchantResponse.Addresses.Single(); addressResponse.AddressId.ShouldBe(merchantModel.Addresses.Single().AddressId); addressResponse.AddressLine1.ShouldBe(merchantModel.Addresses.Single().AddressLine1); addressResponse.AddressLine2.ShouldBe(merchantModel.Addresses.Single().AddressLine2); addressResponse.AddressLine3.ShouldBe(merchantModel.Addresses.Single().AddressLine3); addressResponse.AddressLine4.ShouldBe(merchantModel.Addresses.Single().AddressLine4); addressResponse.Town.ShouldBe(merchantModel.Addresses.Single().Town); addressResponse.Region.ShouldBe(merchantModel.Addresses.Single().Region); addressResponse.Country.ShouldBe(merchantModel.Addresses.Single().Country); addressResponse.PostalCode.ShouldBe(merchantModel.Addresses.Single().PostalCode); merchantResponse.Contacts.ShouldHaveSingleItem(); ContactResponse contactResponse = merchantResponse.Contacts.Single(); contactResponse.ContactId.ShouldBe(merchantModel.Contacts.Single().ContactId); contactResponse.ContactEmailAddress.ShouldBe(merchantModel.Contacts.Single().ContactEmailAddress); contactResponse.ContactName.ShouldBe(merchantModel.Contacts.Single().ContactName); contactResponse.ContactPhoneNumber.ShouldBe(merchantModel.Contacts.Single().ContactPhoneNumber); }
/// <summary> /// This test case is used to create multiple addresses and report time /// </summary> /// <param name="count">holds the number of addreses to insert</param> static void testCaseAddMultipleAddreses(int count) { AddressMaintenance am = new AddressMaintenance(); for (int i = 0; i < count; i++) { AddressRequest a = new AddressRequest(); a.AddressLine1 = "Address Line 1 " + i.ToString(); a.AddressLine2 = "Address Line 2 " + i.ToString(); a.City = "City " + i.ToString(); a.Company = "Company " + i.ToString(); a.Name = "Name " + i.ToString(); a.ZipCode = "98001 " + i.ToString(); a.StateAbbreviation = "WA"; AddressResponse resp = am.addAddress(a); if (resp.Status != "Success") { Console.WriteLine("Exceptions:"); foreach (string e in resp.exceptions) { Console.WriteLine(e); } } } } // end testCaseAddMultipleAddresses
/// <summary> /// testCaseFindAddress is used to test the findAddres API /// </summary> /// <param name="addressId">holds the id of the addreses to find</param> static void testCaseFindAddress(int addressId) { AddressMaintenance am = new AddressMaintenance(); AddressResponse addressResponse = am.findAddress(addressId); if (addressResponse.Status == "Success") { Console.WriteLine("Address Details"); Console.WriteLine(addressResponse.Name); Console.WriteLine(addressResponse.Company); Console.WriteLine(addressResponse.AddressLine1); Console.WriteLine(addressResponse.AddressLine2); Console.WriteLine(addressResponse.City); Console.WriteLine(addressResponse.ZipCode); Console.WriteLine(addressResponse.state_Abbreviation); Console.WriteLine(addressResponse.state_Name); } else { Console.WriteLine("Exceptions:"); foreach (string e in addressResponse.exceptions) { Console.WriteLine(e); } } }
public async Task PUT_Address_Success() { AddressTestData testData = new AddressTestData { ExternalIdentifier = "putAddress01", AccountMasterExtId = "putAddressAccountMaster01" }; await TestScenarioSetUp(testData); AddressRequest addressRequest = new AddressRequest { AddressLine = "address updated", AddressLine2 = "1212", City = "denver", Country = "US", Name = "name updated", Postal = "0987654321", State = "co" }; AddressResponse response = await Client.Addresses.Update(testData.ExternalIdentifier, addressRequest); //validations Assert.IsNotNull(response, "Response object should not be null"); //specific validations Assert.AreEqual(addressRequest.AddressLine, response.AddressLine); Assert.AreEqual(addressRequest.Name, response.Name); //test scenario clean up await TestScenarioCleanUp(testData); }
public void SingleLineAddress_WithVariousData_ReturnsCorrectResult( string line1, string line2, string line3, string line4, string town, string postcode, string expectedSingleLine) { // Arrange var address = new AddressResponse() { Line1 = line1, Line2 = line2, Line3 = line3, Line4 = line4, Town = town, Postcode = postcode, }; // Act var singleLineAddress = address.SingleLineAddress; // Assert singleLineAddress.Should().Be(expectedSingleLine); }
public async Task Run() { /* * ADDRESS */ // Creating a new Address AddressResponse created = await Create(staticVault); // Retrieving a existent Address AddressResponse retrieved = await Retrieve(staticVault, created.Id); await RetrieveFromRealData(staticVault, created.Address); // Deleting a existent Address await Delete(staticVault, retrieved.Id); /* * ADDRESS WITH STATE */ // Creating a new Address with State AddressResponse createdWithState = await CreateWithState(staticVault); // Retrieving a existent Address AddressResponse retrievedWithState = await Retrieve(staticVault, createdWithState.Id); await RetrieveFromRealData(staticVault, createdWithState.Address); // Deleting a existent Address await Delete(staticVault, retrievedWithState.Id); }
protected override void ConstructResponse() { _sendingBuffer = new AddressResponse(_request, _session.RemoteEndPoint).BuildResponse(); _session.UserInfo.SetIsGotAddressCheckPacketFlag(). UpdateLastPacketReceiveTime(); }
public AddressResponse Get(int id) { AddressResponse response = new AddressResponse(); var resultDb = context.Address.Include(x => x.User).FirstOrDefault(u => u.Id == id); response = _mapper.Map <Address, AddressResponse>(resultDb); return(response); }
public BranchResponse(int id, string name, string code, string phone, AddressResponse address) { Id = Throw.ArgumentNullException.IfNull(id, nameof(id)); Name = Throw.ArgumentNullException.IfNull(name, nameof(name)); Code = Throw.ArgumentNullException.IfNull(code, nameof(code)); Phone = Throw.ArgumentNullException.IfNull(phone, nameof(phone)); Address = Throw.ArgumentNullException.IfNull(address, nameof(address)); }
private async Task <AddressResponse> Retrieve(StaticVault vault, String id) { AddressResponse retrieved = await vault.Address.Retrieve(id); Console.WriteLine("//// AddressExample.retrieve:"); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(retrieved)); return(retrieved); }
public AddressResponse MapCurrentAddressResponse(AddressResponse response) => new AddressResponse { AddressId = response.AddressId, AddressLine1 = response.AddressLine1, AddressLine2 = response.AddressLine2, TownCity = response.TownCity, County = response.County, Postcode = response.Postcode, Country = response.Country };
public void SetBusinessAddress(BusinessAddressResponse businessAddress, AddressResponse currentAddress, bool addressHidden) { if (!addressHidden) { return; } if (businessAddress.Address.Equals(currentAddress)) { businessAddress.Address = null; } }
public async Task <IActionResult> Address(AddressResponse form) { var command = (AddressRequest)form; if (ModelState.IsValid) { await Post <BaseResponse>("address/create", command); } return(RedirectToAction(nameof(Address))); }
public CustomerResponse(int id, string fullName, string nationality, Gender gender, DateTime birthDate, string userId, AddressResponse address) { Id = Throw.ArgumentNullException.IfNull(id, nameof(id)); FullName = Throw.ArgumentNullException.IfNull(fullName, nameof(fullName)); Nationality = Throw.ArgumentNullException.IfNull(nationality, nameof(nationality)); Gender = Throw.ArgumentNullException.IfNull(gender, nameof(gender)); BirthDate = Throw.ArgumentNullException.IfNull(birthDate, nameof(birthDate)); UserId = Throw.ArgumentNullException.IfNull(userId, nameof(userId)); Address = Throw.ArgumentNullException.IfNull(address, nameof(address)); }
public AddressResponse GetAddress() { var response = new AddressResponse(); var s = new AddressService(GetConnectionString(), TraceFile, WriteToLogFile); var r = s.GetAddresses(); response.IsError = r.IsError; response.ErrorDesc = r.ErrorDesc; response.Address = r.Return; return(response); }
public object addaddress(Address addres) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ISAddress address = new SAddressImpl(); AddressResponse rs = address.addaddress(addres); return(rs); }
static void PrintSuggestions(AddressResponse ar) { Console.WriteLine("Response: "); Console.WriteLine("Suggestions.Count: " + ar.Suggestions.Count + "\n"); foreach (var addrResult in ar.Suggestions) { Console.WriteLine(addrResult.Value); Console.WriteLine(addrResult.UnrestrictedValue); } }
public CompanyResponse(int id, DocumentResponse document, EmailResponse email, AddressResponse address, string companyName, string fantasyName, List <EmployeeResponse> employees) { Id = id; Email = email; Address = address; Document = document; Employees = employees; FantasyName = fantasyName; CompanyName = companyName; }
static void Main(string[] args) { using (TextReader reader = new StreamReader(@"Y:\FIAS_XML\regions.csv")) //"Y:\FIAS_XML\regions.csv" using (CsvReader csv = new CsvReader(reader, CultureInfo.InvariantCulture)) { csv.Configuration.HasHeaderRecord = true; regions = csv.GetRecords <Region>().ToList(); } var client = new ApiClient(token, secret); AddressResponse response = client.SuggestionsQueryAddress(new AddressRequest() { Query = "vcr cjrjkmybxtcrfz" //мск сокольническая }).GetAwaiter().GetResult(); Console.WriteLine("Request: <Query = \"vcr cjrjkmybxtcrfz>"); PrintSuggestions(response); string id = "95dbf7fb-0dd4-4a04-8100-4f6c847564b5"; // HouseGUID == e97154b2-18d0-49ce-8ec1-8a2b9284806c == Пермский край, г Александровск, ул Братьев Давыдовых, д 46 // AOGUID = 34b39dc7-7340-4c91-9c46-0f9fbd3bd68b == Пермский край, г Александровск, ул Братьев Давыдовых var house = client.AdditionalQueryFindAddressById(id).GetAwaiter().GetResult(); Console.WriteLine($"Request: < FindAddressById = {id} >"); Console.WriteLine("Response: "); Console.WriteLine("Suggestions.Count: " + house.Suggestions.Count + "\n"); var myPropertyInfo = house.Suggestions[0].Data.GetType().GetProperties(); for (int i = 0; i < myPropertyInfo.Length; i++) { object val = myPropertyInfo[i].GetValue(house.Suggestions[0].Data, null); if (val != null) { val = val.ToString(); } Console.WriteLine(myPropertyInfo[i].Name + ": " + val); } foreach (var addrResult in house.Suggestions) { Console.WriteLine(addrResult.Value); } var piter = client.SuggestionsQueryAddress("gbnth ytdcrbq").GetAwaiter().GetResult(); Console.WriteLine($"Request: < QueryAddress = \"gbnth ytdcrbq\" >"); PrintSuggestions(piter); Console.ReadLine(); }
private async Task <AddressResponse> Create(StaticVault vault) { String name = "Address"; AddressResponse created = await vault.Address.Create(name, null); Console.WriteLine("//// AddressExample.create:"); Console.WriteLine("/// Name: " + name); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(created)); return(created); }
public EmployeeResponse(int id, NameResponse name, DocumentResponse document, EmailResponse email, AddressResponse address, string registerCode, CompanyResponse company, EmployeePositionResponse employeePositionResponse) { Id = id; Name = name; Email = email; Company = company; Address = address; Document = document; RegisterCode = registerCode; EmployeePosition = employeePositionResponse; }
public static TiltedGlobe.Common.Models.ThirdParty.TINCheck.TINCheckResponse CheckTIN(TiltedGlobe.Common.Models.Account.IUser pUser) { TINCheckResponse response = new TINCheckResponse(); var tinNameToCheck = new TINCheck.com.TinNameClass(); tinNameToCheck.FName = pUser.FirstName; tinNameToCheck.LName = pUser.LastName; tinNameToCheck.TIN = pUser.Ein; var tinAddressToCheck = new TINCheck.com.USPSAddressClass(); tinAddressToCheck.Address1 = pUser.Address.Address1; tinAddressToCheck.Address2 = pUser.Address.Address2; tinAddressToCheck.City = pUser.Address.City; tinAddressToCheck.State = pUser.Address.StateCode; tinAddressToCheck.Zip5 = pUser.Address.ZipPostalCode; var tinUser = new TINCheck.com.UserClass(); tinUser.UserLogin = _tinCheckUserName; tinUser.UserPassword = _tinCheckUserPassword; try { using (var client = new TINCheck.com.PVSServiceSoapClient()) { var result = client.ValidateTinNameAddressListMatch(tinNameToCheck, tinAddressToCheck, tinUser); var nameResponse = new NameResponse(); nameResponse.DMFCode = result.TINNAME_RESULT.DMF_CODE; nameResponse.DMFData = result.TINNAME_RESULT.DMF_DATA; nameResponse.DMFDetails = result.TINNAME_RESULT.DMF_DETAILS; nameResponse.TINNameCode = result.TINNAME_RESULT.TINNAME_CODE; nameResponse.TINNameDetails = result.TINNAME_RESULT.TINNAME_DETAILS; var addressResponse = new AddressResponse(); addressResponse.AddressCode = result.ADDRESS_RESULT.ADDRESS_CODE; addressResponse.AddressDetails = result.ADDRESS_RESULT.ADDRESS_DETAILS; response.AddressResponse = addressResponse; response.NameResponse = nameResponse; } } catch (Exception ex) { //TODO } return(response); }
public void PostCode_Required_IfTheCountryIsUK() { var fakedContext = new XrmFakedContext(); //input object does not contain to record id which is mandatory. string InputLoad = @" { recordtype: 'contact', recordid: '37e64f21-c035-4e49-a6b6-958cdd3af45e', 'address': { 'type': 1, 'buildingname': 'Horizon', 'buildingnumber': '3', 'street': 'Road', 'locality': '', 'town': '', 'country': 'USA', 'fromcompanieshouse': '' } } "; //Inputs var inputs = new Dictionary <string, object>() { { "ReqPayload", InputLoad }, }; fakedContext.Initialize(new List <Entity>() { new Entity() { Id = new Guid("37e64f21-c035-4e49-a6b6-958cdd3af45e"), LogicalName = "contact" } }); var result = fakedContext.ExecuteCodeActivity <AddAddress>(inputs); var address = fakedContext.CreateQuery <defra_address>(); #region ErrorMessagesToCheck #endregion String ReturnMessage = (String)result["ResPayload"]; AddressResponse AddressResponseObject = Newtonsoft.Json.JsonConvert.DeserializeObject <AddressResponse>(ReturnMessage); String ErrorDetails = AddressResponseObject.message; StringAssert.Contains(ErrorDetails, PostCodeOrPostalCodeCannotBeEmpty); }
public static AddressResponse ToResponse(this Address entity) { var addressResponse = new AddressResponse { City = entity.City, PostalCode = entity.PostalCode, Street = entity.Street, BuildingNumber = entity.BuildingNumber, LocalNumber = entity.LocalNumber, PubId = entity.PubId }; return(addressResponse); }