public async Task <TestUserAccount> CreateDefaultUserAccount() { string externalIdentifier = "defaultUser-123"; var userAccount = new TestUserAccount { Email = "*****@*****.**", ContactInformation = new TestContactInformation { CompanyName = "SDET", FirstName = "John", LastName = "Doe", PhoneNumber = "9876543210", Email = "*****@*****.**" }, AccountExternalIds = new TestExternalIdentifiers { LoginExtId = externalIdentifier, AccountMasterExtId = externalIdentifier, ContactExtId = externalIdentifier, UserExtId = externalIdentifier } }; //does not need to validate test user data //clear all account related data await RemoveUserAccount(userAccount.AccountExternalIds); await CreateUserFullPath(userAccount); return(userAccount); }
public void Create_Allpoints_UserAccount_Implicit_Success() { string identifier = "asdasd123"; var testUser = new TestUserAccount { Email = "*****@*****.**", ContactInformation = new TestContactInformation { CompanyName = "implicit", Email = "*****@*****.**", FirstName = "firstName", LastName = "lastName", PhoneNumber = "0123456789" }, AccountExternalIds = new TestExternalIdentifiers { AccountMasterExtId = identifier, ContactExtId = identifier, LoginExtId = identifier, UserExtId = identifier } }; DataFactory.Users.CreateTestUser(testUser); Console.WriteLine(testUser.Username); }
public async Task <TestUserAccount> CreateUserAccount(string userIdentifier) { var userAccount = new TestUserAccount { Email = userIdentifier + "@dfs.com", ContactInformation = new TestContactInformation { CompanyName = "SDET", FirstName = "John", LastName = "Doe", PhoneNumber = "9876543210", Email = "*****@*****.**" }, AccountExternalIds = new TestExternalIdentifiers { LoginExtId = userIdentifier, AccountMasterExtId = userIdentifier, ContactExtId = userIdentifier, UserExtId = userIdentifier } }; //validate user data if (string.IsNullOrEmpty(userIdentifier) || string.IsNullOrWhiteSpace(userIdentifier)) { throw new ArgumentException($"{nameof(userIdentifier)} cannot be empty or null"); } //clear all account related data await RemoveUserAccount(userAccount.AccountExternalIds); await CreateUserFullPath(userAccount); return(userAccount); }
public void Create_Allpoints_UserAccount_Withterms_Success() { string termsDescription = "Net days ;3"; string identifier = "termsUserNoDefault01abc"; var testUser = new TestUserAccount { Email = "*****@*****.**", ContactInformation = new TestContactInformation { CompanyName = "dfs", Email = "*****@*****.**", FirstName = "firstName", LastName = "lastName", PhoneNumber = "0123456789" }, AccountExternalIds = new TestExternalIdentifiers { AccountMasterExtId = identifier, ContactExtId = identifier, LoginExtId = identifier, UserExtId = identifier } }; DataFactory.Users.CreateTestUserWithTerms(termsDescription, testUser); Console.WriteLine(testUser.Username); }
public async Task CREATE_EliAllPointsTestUser() { DataFactory = ConfigurationHelper.SetPlatform(TenantsEnum.AllPoints); string identifier = "elibr-1234"; var testUser = new TestUserAccount { Email = "*****@*****.**", AccountExternalIds = new TestExternalIdentifiers { AccountMasterExtId = identifier, ContactExtId = identifier, LoginExtId = identifier, UserExtId = identifier }, ContactInformation = new TestContactInformation { Email = "*****@*****.**", CompanyName = "allpoints", FirstName = "eli", LastName = "barbarick", PhoneNumber = "1234567890" } }; await DataFactory.UserAccounts.CreateUserAccount(testUser); }
//terms related public TestUserAccount CreateTestUserWithTerms(string termsDescription, TestUserAccount testUser = null) { if (testUser == null) { return(_processor.CreateDefaultUserWithTerms(termsDescription).Result); } return(_processor.CreateUserWithTerms(termsDescription, testUser).Result); }
public async Task <TestUserAccount> CreateUserAccount(TestUserAccount userAccount) { //validate user data ValidateUserData(userAccount); //clear all account related data await RemoveUserAccount(userAccount.AccountExternalIds); await CreateUserFullPath(userAccount); return(userAccount); }
public TestUserAccount CreateTestUser(TestUserAccount testUser = null) { //create default user acount if (testUser == null) { return(_processor.CreateDefaultUserAccount().Result); } //create an explicit user return(_processor.CreateUserAccount(testUser).Result); }
private void ValidateUserData(TestUserAccount userData) { bool StringNullCheck(string value) => (string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value)); void ExceptionHandler(string entityName) => throw new Exception($"{entityName} has no value"); //login email validation if (StringNullCheck(userData.Username)) { ExceptionHandler(nameof(userData.Username)); } //account external identifiers validations if (userData.AccountExternalIds == null) { ExceptionHandler(nameof(userData.AccountExternalIds)); } if (StringNullCheck(userData.AccountExternalIds.AccountMasterExtId)) { ExceptionHandler(nameof(userData.AccountExternalIds.AccountMasterExtId)); } //contact information validations if (userData.ContactInformation == null) { ExceptionHandler(nameof(userData.ContactInformation)); } if (StringNullCheck(userData.ContactInformation.CompanyName)) { ExceptionHandler(nameof(userData.ContactInformation.CompanyName)); } if (StringNullCheck(userData.ContactInformation.FirstName)) { ExceptionHandler(nameof(userData.ContactInformation.FirstName)); } if (StringNullCheck(userData.ContactInformation.LastName)) { ExceptionHandler(nameof(userData.ContactInformation.LastName)); } if (StringNullCheck(userData.ContactInformation.Email)) { ExceptionHandler(nameof(userData.ContactInformation.Email)); } if (StringNullCheck(userData.ContactInformation.PhoneNumber)) { ExceptionHandler(nameof(userData.ContactInformation.PhoneNumber)); } }
public void Create_Fmp_UserAccount_Specific_Test() { var user = new TestUserAccount { Email = "*****@*****.**", ContactInformation = new TestContactInformation { CompanyName = "stk", Email = "*****@*****.**", FirstName = "ivan", LastName = "trujillo", PhoneNumber = "1234567890" } }; DataFactory.Users.CreateTestUser(user); }
private async Task AddTermsToUserAccount(string termsDescription, TestUserAccount userAccountData) { var request = new { TermsConfiguration = new AccountMasterTermConfiguration { HasPaymentTerms = true, TermsDescription = termsDescription } }; var response = await _client.AccountMasters.PatchEntity(userAccountData.AccountExternalIds.AccountMasterExtId, request); if (!response.Success) { throw new Exception("Cannot add terms to the given account, " + userAccountData.AccountExternalIds.AccountMasterExtId); } }
public async Task <TestUserAccount> CreateDefaultUserWithTerms(string termsDescription) { string externalIdentifier = "accountTerm01-abc"; var userAccount = new TestUserAccount { Email = "*****@*****.**", AccountExternalIds = new TestExternalIdentifiers { AccountMasterExtId = externalIdentifier, ContactExtId = externalIdentifier, LoginExtId = externalIdentifier, UserExtId = externalIdentifier }, ContactInformation = new TestContactInformation { CompanyName = "DFS", Email = "*****@*****.**", FirstName = "firstName", LastName = "lastName", PhoneNumber = "0123456789" } }; //basic term validation if (string.IsNullOrEmpty(termsDescription) || string.IsNullOrWhiteSpace(termsDescription)) { throw new ArgumentException($"{nameof(termsDescription)} should not be empty or null"); } //clear all user account related data await RemoveUserAccount(userAccount.AccountExternalIds); //TODO //remove addresses await CreateUserFullPath(userAccount); //add terms await AddTermsToUserAccount(termsDescription, userAccount); return(userAccount); }
public void RemoveUserAccount(TestUserAccount testUser) { _processor.RemoveUserAccount(testUser.AccountExternalIds).Wait(); //TODO //Addresses.RemoveAddresses }
public async Task AllPointsFreeFreight() { string identifier = "freeFreight15"; var testUser = new TestUserAccount { Email = identifier + "@mail.com", ContactInformation = new TestContactInformation { CompanyName = "dfs", Email = "*****@*****.**", FirstName = "John", LastName = "Doe", PhoneNumber = "1234567890" }, AccountExternalIds = new TestExternalIdentifiers { AccountMasterExtId = identifier, ContactExtId = identifier, LoginExtId = identifier, UserExtId = identifier } }; testUser = await DataFactoryAllPoints.UserAccounts.CreateUserAccount(testUser); //Tiene todos los identifiers TestShippingExternals customerCarrierAccount = new TestShippingExternals { AccountMasterExtId = identifier, ConfigurationExtId = identifier, FlatRateGroupExtId = identifier, HandlingGroupExtId = identifier }; await DataFactoryAllPoints.ShippingConfigurationPreferences.RemoveAccountPreferences(customerCarrierAccount); var configuration = new TestShippingConfiguration { Identifier = identifier, DefaultServiceLevel = ServiceLevelCodesEnum.Nextdayam, ServiceLevels = new List <TestServiceLevel> { new TestServiceLevel { Amount = 0, CarrierRateDiscount = 0.5, Code = ServiceLevelCodesEnum.Nextdayam, SortOrder = 7, Label = "Next Day AM", }, new TestServiceLevel { Amount = 1, CarrierRateDiscount = 0.5, Code = ServiceLevelCodesEnum.Ground, SortOrder = 1, Label = "Ground", }, new TestServiceLevel { Amount = 0, CarrierRateDiscount = 0.5, Code = ServiceLevelCodesEnum.Nextdaysaver, SortOrder = 5, Label = "Next Day Air Saver", }, new TestServiceLevel { Amount = 0, CarrierRateDiscount = 0, Code = ServiceLevelCodesEnum.Showroom, Label = "Showroom", SortOrder = 8 } } }; await DataFactoryAllPoints.ShippingConfigurationPreferences.CreateConfiguration(configuration); var preferences = new TestShippingPreferences { ConfigurationExtId = identifier, UseCustomerCarrier = false, FreeFreightRules = new List <SAMFreeFreightRule> { new SAMFreeFreightRule { ServiceLevelCode = (int)ServiceLevelCodesEnum.Ground, ThresholdAmount = 500 } }, //agregar de la imagen FreeFreightForNonContiguousStates = true }; await DataFactoryAllPoints.ShippingConfigurationPreferences.AddAccountPreferences(customerCarrierAccount, preferences); }
public async Task <TestUserAccount> CreateUserAccount(TestUserAccount createUserRequest = null) { //default account var testUserAccount = createUserRequest ?? new TestUserAccount { Email = "*****@*****.**", ContactInformation = new TestContactInformation { CompanyName = "SDET", FirstName = "John", LastName = "Doe", PhoneNumber = "9876543210", Email = "*****@*****.**" }, AccountExternalIds = new TestExternalIdentifiers { LoginExtId = "testLogin-123", AccountMasterExtId = "testAccountMaster-123", ContactExtId = "testContact-123", UserExtId = "testUser-123" } }; //validate given data if (createUserRequest != null) { ValidateUserData(createUserRequest); } //clear all account related data await RemoveUserAccount(testUserAccount.AccountExternalIds); //create account and accountmaster AccountMasterRequest createAccountMasterRequest = new AccountMasterRequest { CreatedBy = System.Security.Principal.WindowsIdentity.GetCurrent().Name, Identifier = testUserAccount.AccountExternalIds.AccountMasterExtId, Name = testUserAccount.ContactInformation.CompanyName, CreateAccount = true, IsWebEnabled = true }; var createAccountMasterResponse = await _client.AccountMasters.Create(createAccountMasterRequest); if (!createAccountMasterResponse.Success) { throw new Exception($"Test user cannot be created, check accountmaster creation process ({createAccountMasterRequest.Identifier})"); } //create contact ContactRequest contactRequest = new ContactRequest { CreatedBy = System.Security.Principal.WindowsIdentity.GetCurrent().Name, ExternalIdentifier = testUserAccount.AccountExternalIds.ContactExtId, AccountMasterExtId = testUserAccount.AccountExternalIds.AccountMasterExtId, ContactEmail = testUserAccount.ContactInformation.Email, FirstName = testUserAccount.ContactInformation.FirstName, LastName = testUserAccount.ContactInformation.LastName, PhoneNumber = testUserAccount.ContactInformation.PhoneNumber }; var createContactResponse = await _client.Contacts.Create(contactRequest); if (!createContactResponse.Success) { throw new Exception("Test contact cannot be created, please check the given contact info. data"); } //create login LoginRequest createLoginRequest = new LoginRequest { CreatedBy = System.Security.Principal.WindowsIdentity.GetCurrent().Name, ExternalIdentifier = testUserAccount.AccountExternalIds.LoginExtId, IsEnabled = true, UserName = testUserAccount.Username, Email = testUserAccount.Email, PasswordHash = "E95FBFCD1C6EB3CA80DCE1F656633017", //password -> 1234 PasswordSalt = "xXJnoJE=" //password -> 1234 }; var loginResponse = await _client.Logins.Create(createLoginRequest); if (!loginResponse.Success) { throw new Exception("Test login cannot be created, check logins endpoint method"); } //create user UserRequest userRequest = new UserRequest { CreatedBy = System.Security.Principal.WindowsIdentity.GetCurrent().Name, AccountMasterExtId = testUserAccount.AccountExternalIds.AccountMasterExtId, ContactExtId = testUserAccount.AccountExternalIds.ContactExtId, ExternalIdentifier = testUserAccount.AccountExternalIds.UserExtId, IsEnabled = true, LoginExtId = testUserAccount.AccountExternalIds.LoginExtId }; var createUserResponse = await _client.Users.Create(userRequest); if (!createUserResponse.Success) { throw new Exception($"Test user cannot be created, check user post endpoint method"); } return(testUserAccount); }
public async Task <TestUserAccount> CreateUserWithTerms(string termsDescription, TestUserAccount userAccount) { //basic term validation if (string.IsNullOrEmpty(termsDescription) || string.IsNullOrWhiteSpace(termsDescription)) { throw new ArgumentException($"{nameof(termsDescription)} should not be empty or null"); } //clear all user account related data await RemoveUserAccount(userAccount.AccountExternalIds); //TODO //remove addresses //remove payments? //create user account await CreateUserFullPath(userAccount); //add terms await AddTermsToUserAccount(termsDescription, userAccount); return(userAccount); }
public async Task AllPointsBestRate() { string identifier = "BestRate01"; var testUser = new TestUserAccount { Email = identifier + "@mail.com", ContactInformation = new TestContactInformation { CompanyName = "dfs", Email = "*****@*****.**", FirstName = "John", LastName = "Doe", PhoneNumber = "1234567890" }, AccountExternalIds = new TestExternalIdentifiers { AccountMasterExtId = identifier, ContactExtId = identifier, LoginExtId = identifier, UserExtId = identifier } }; testUser = await DataFactoryAllPoints.UserAccounts.CreateUserAccount(testUser); TestShippingExternals customerCarrierAccount = new TestShippingExternals { AccountMasterExtId = identifier, ConfigurationExtId = identifier, FlatRateGroupExtId = identifier, HandlingGroupExtId = identifier, FlatRateSchedules = new List <TestSchedule> { new TestSchedule { ExternalIdentifier = identifier + "flatRate", OrderAmountMin = 100, OrderAmountMax = 1000, Rate = 150, ServiceLevelCode = ServiceLevelCodesEnum.Ground }, new TestSchedule { ExternalIdentifier = identifier + "flatRate02", OrderAmountMin = 100, OrderAmountMax = 500, Rate = 45, ServiceLevelCode = ServiceLevelCodesEnum.Nextdayam }, new TestSchedule { ExternalIdentifier = identifier + "flatRate03", OrderAmountMin = 100, OrderAmountMax = 1000, Rate = 15, ServiceLevelCode = ServiceLevelCodesEnum.Nextdaysaver } }, HandlingSchedules = new List <TestSchedule> { new TestSchedule { ExternalIdentifier = identifier + "handling", OrderAmountMin = 100, OrderAmountMax = 200, ServiceLevelCode = ServiceLevelCodesEnum.Ground, Rate = 50 }, new TestSchedule { ExternalIdentifier = identifier + "handling02", OrderAmountMin = 100, OrderAmountMax = 300, Rate = 5, ServiceLevelCode = ServiceLevelCodesEnum.Nextdayam, }, new TestSchedule { ExternalIdentifier = identifier + "handling03", OrderAmountMin = 100, OrderAmountMax = 1000, Rate = 10, ServiceLevelCode = ServiceLevelCodesEnum.Nextdaysaver } } }; await DataFactoryAllPoints.ShippingConfigurationPreferences.RemoveAccountPreferences(customerCarrierAccount); var configuration = new TestShippingConfiguration { FreeParcelShipProximityMessageDollar = 500, FreeParcelShipProximityMessagePercentage = 0.5, Identifier = identifier, DefaultServiceLevel = ServiceLevelCodesEnum.Nextdayam, ServiceLevels = new List <TestServiceLevel> { new TestServiceLevel { Amount = 0, CarrierRateDiscount = 0.5, Code = ServiceLevelCodesEnum.Nextdayam, SortOrder = 1, Label = "Next Day AM", }, new TestServiceLevel { Amount = 1, CarrierRateDiscount = 0.5, Code = ServiceLevelCodesEnum.Ground, SortOrder = 7, Label = "Ground", }, new TestServiceLevel { Amount = 0, CarrierRateDiscount = 0.5, Code = ServiceLevelCodesEnum.Nextdaysaver, SortOrder = 5, Label = "Next Day Air Saver", }, new TestServiceLevel { Amount = 0, CarrierRateDiscount = 0, Code = ServiceLevelCodesEnum.Showroom, Label = "Showroom", SortOrder = 8 } } }; await DataFactoryAllPoints.ShippingConfigurationPreferences.CreateConfiguration(configuration); var preferences = new TestShippingPreferences { UseBestRate = true, ConfigurationExtId = identifier, UseCustomerCarrier = false, FreeFreightRules = new List <SAMFreeFreightRule> { new SAMFreeFreightRule { ServiceLevelCode = (int)ServiceLevelCodesEnum.Ground, ThresholdAmount = 500 } }, //agregar de la imagen FreeFreightForNonContiguousStates = true }; await DataFactoryAllPoints.ShippingConfigurationPreferences.AddAccountPreferences(customerCarrierAccount, preferences); }
private async Task CreateUserFullPath(TestUserAccount userAccountData) { //create account and accountmaster AccountMasterRequest createAccountMasterRequest = new AccountMasterRequest { CreatedBy = System.Security.Principal.WindowsIdentity.GetCurrent().Name, Identifier = userAccountData.AccountExternalIds.AccountMasterExtId, Name = userAccountData.ContactInformation.CompanyName, CreateAccount = true, IsWebEnabled = true }; var createAccountMasterResponse = await _client.AccountMasters.Create(createAccountMasterRequest); if (!createAccountMasterResponse.Success) { throw new Exception($"Test user cannot be created, check accountmaster creation process ({createAccountMasterRequest.Identifier})"); } //create contact ContactRequest contactRequest = new ContactRequest { CreatedBy = System.Security.Principal.WindowsIdentity.GetCurrent().Name, ExternalIdentifier = userAccountData.AccountExternalIds.ContactExtId, AccountMasterExtId = userAccountData.AccountExternalIds.AccountMasterExtId, ContactEmail = userAccountData.ContactInformation.Email, FirstName = userAccountData.ContactInformation.FirstName, LastName = userAccountData.ContactInformation.LastName, PhoneNumber = userAccountData.ContactInformation.PhoneNumber }; var createContactResponse = await _client.Contacts.Create(contactRequest); if (!createContactResponse.Success) { throw new Exception("Test contact cannot be created, please check the given contact info. data"); } //create login LoginRequest createLoginRequest = new LoginRequest { CreatedBy = System.Security.Principal.WindowsIdentity.GetCurrent().Name, ExternalIdentifier = userAccountData.AccountExternalIds.LoginExtId, IsEnabled = true, UserName = userAccountData.Username, Email = userAccountData.Email, PasswordHash = "E95FBFCD1C6EB3CA80DCE1F656633017", //password -> 1234 PasswordSalt = "xXJnoJE=" //password -> 1234 }; var loginResponse = await _client.Logins.Create(createLoginRequest); if (!loginResponse.Success) { throw new Exception("Test login cannot be created, check logins endpoint method"); } //create user UserRequest userRequest = new UserRequest { CreatedBy = System.Security.Principal.WindowsIdentity.GetCurrent().Name, AccountMasterExtId = userAccountData.AccountExternalIds.AccountMasterExtId, ContactExtId = userAccountData.AccountExternalIds.ContactExtId, ExternalIdentifier = userAccountData.AccountExternalIds.UserExtId, IsEnabled = true, LoginExtId = userAccountData.AccountExternalIds.LoginExtId }; var createUserResponse = await _client.Users.Create(userRequest); if (!createUserResponse.Success) { throw new Exception($"Test user cannot be created, check user post endpoint method"); } }