public async Task Create_WhenValidPayloadSentAndRequestSuccessful_ThenRedirectToProfileReadViewActionReturned() { var address = AddressProvider.GetPreCreationTestAddress(1); _mockAuthService .Setup(a => a.IsAuthenticated(_user)) .Returns(true); _mockRepository .Setup(r => r.AddAsync(address)) .ReturnsAsync(AddressProvider.GetPostCreationTestAddress(1)); var controller = new AddressController(_mockAuthService.Object, _mockRepository.Object); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = _user } }; var response = await controller.Create(1, address) as PartialViewResult; var actual = response.Model as Address; Assert.IsNotNull(response); Assert.IsInstanceOf <PartialViewResult>(response); Assert.That("_AddressModal", Is.EqualTo(response.ViewName)); Assert.That(1, Is.EqualTo(actual.ClientId)); Assert.That(address.Postcode, Is.EqualTo(actual.Postcode)); }
public void Cloud() { var options = new NetworkingOptions(); var loggerFactory = new NullLoggerFactory(); options.Addresses.Clear(); options.Cloud.DiscoveryToken = null; Assert.That(options.Cloud.Enabled, Is.False); options.Cloud.DiscoveryToken = "*****"; Assert.That(options.Cloud.Enabled, Is.True); options.Cloud.Url = null; Assert.Throws <ArgumentNullException>(() => _ = new AddressProvider(options, loggerFactory)); options.Cloud.Url = new Uri("http://xxxxx"); options.Addresses.Add("192.0.0.1:5701"); Assert.Throws <ConfigurationException>(() => _ = new AddressProvider(options, loggerFactory)); options.Addresses.Clear(); CloudDiscovery.SetResponse(@"[ { ""private-address"":""192.0.0.6:5788"", ""public-address"":""192.147.0.6"" }, { ""private-address"":""192.0.0.7"", ""public-address"":""192.147.0.7"" }, { ""private-address"":""192.0.0.8:5777"", ""public-address"":""192.147.0.8:5703"" }, { ""private-address"":""192.0.0.9"", ""public-address"":""192.147.0.9:5707"" }, ]");
static void Main() { Console.WriteLine("Start"); var doctriniansClinicChain = ClinicHelper.CreateClinicChain("Doctrinians", "Chain of Clinics united by common idea of improving medical system"); var stockholmiansClinicChain = ClinicHelper.CreateClinicChain("Stockholmians", "Classical medical units in Stocklolmian region"); var karolinskaAddress = AddressProvider.CreateAddress("Sweden", "Stockholm LL", "Stockholm", "Solnavägen", 1, null, 17177); var karolinskaClinic = ClinicHelper.CreateClinic("Karolinska", karolinskaAddress); var capioAddress = AddressProvider.CreateAddress("Sweden", "Stockholm LL", "Stockholm", "Ringvägen", 113, null, 11860); var capioClinic = ClinicHelper.CreateClinic("Capio", capioAddress); ClinicHelper.AddClinicToClinicChain(karolinskaClinic, stockholmiansClinicChain); ClinicHelper.AddClinicToClinicChain(karolinskaClinic, stockholmiansClinicChain); var neurologistOccupation = OccupationProvider.CreateOccupation(OccupationType.Doctor, "Neurologist"); var pediatrOccupation = OccupationProvider.CreateOccupation(OccupationType.Doctor, "Pediatr"); var pediatricNurseOccupation = OccupationProvider.CreateOccupation(OccupationType.Nurse, "Pediatric nurse"); var adminOccupation = OccupationProvider.CreateOccupation(OccupationType.Admin, "Administrator"); var neurologist = PersonHelper.CreateNewMedic(196002011364, neurologistOccupation); var pediatr = PersonHelper.CreateNewMedic(197001011089, pediatrOccupation); var pediatricNurse = PersonHelper.CreateNewMedic(199002284501, pediatricNurseOccupation); var admin = PersonHelper.CreateNewMedic(198503122466, adminOccupation); ClinicHelper.Hire(neurologist, karolinskaClinic); ClinicHelper.Hire(admin, karolinskaClinic); ClinicHelper.Hire(pediatr, capioClinic); ClinicHelper.Hire(pediatricNurse, capioClinic); var patientRegisterKarolinska = PatientTreatmentHelper.CreateNewPatietnRegistry(karolinskaClinic); var patientVisitKarolinska = PatientTreatmentHelper.CreateNewPatientVisit(199503280549, patientRegisterKarolinska); var patientRegisterCapio = PatientTreatmentHelper.CreateNewPatietnRegistry(karolinskaClinic); var patientVisitCapio = PatientTreatmentHelper.CreateNewPatientVisit(198511280549, patientRegisterCapio); var bloodTest = IssueProvider.CreateIssue("Blood test", 50.02m); var ultrasound = IssueProvider.CreateIssue("Ultrasound", 150.00m); var ekg = IssueProvider.CreateIssue("Electrocardiogram", 149.99m); var mriScan = IssueProvider.CreateIssue("Magnetic resonance imaging scan", 2000.00m); PatientTreatmentHelper.AddIssue(patientVisitCapio, bloodTest); PatientTreatmentHelper.AddIssue(patientVisitCapio, ultrasound); PatientTreatmentHelper.AddIssue(patientVisitKarolinska, ekg); PatientTreatmentHelper.AddIssue(patientVisitKarolinska, mriScan); ClinicHelper.DeleteClinic(karolinskaClinic); ClinicHelper.DeleteClinicChain(doctriniansClinicChain); PatientTreatmentHelper.DeleteIssueFromPatientVisit(ultrasound, patientVisitCapio); PatientTreatmentHelper.DeletePatientRegistry(patientRegisterKarolinska); OccupationProvider.Delete(adminOccupation); AddressProvider.Delete(karolinskaAddress); IssueProvider.Delete(ekg); PersonHelper.DeletePerson(neurologist); }
[Inject] // Using Ninject for DI public BaseController( AddressProvider AddressProvider, EmailProvider EmailProvider, PhoneProvider PhoneProvider) { this.AddressProvider = AddressProvider; this.EmailProvider = EmailProvider; this.PhoneProvider = PhoneProvider; }
public AdministrationController( CustomerProvider CustomerProvider, EmployeeProvider EmployeeProvider, AddressProvider AddressProvider, EmailProvider EmailProvider, PhoneProvider PhoneProvider) : base(AddressProvider, EmailProvider, PhoneProvider) { this.CustomerProvider = CustomerProvider; this.EmployeeProvider = EmployeeProvider; }
private static ICollection <NetworkAddress> GetAddresses(string address) { var options = new NetworkingOptions(); options.Addresses.Clear(); options.Addresses.Add(address); var a = new AddressProvider(options, new NullLoggerFactory()); return(a.CreateMapFromConfiguration().Values); }
public void TestConfigAddressProvider_emptyAddress() { var cfg = new ClientConfig(); var addressProvider = new AddressProvider(cfg); var addresses = addressProvider.GetAddresses().ToList(); Assert.AreEqual(addresses[0], new Address("localhost", 5701)); Assert.AreEqual(addresses[1], new Address("localhost", 5702)); Assert.AreEqual(addresses[2], new Address("localhost", 5703)); }
public void TestConfigAddressProvider_emptyAddress() { var cfg = new Configuration(); var addressProvider = new AddressProvider(cfg.NetworkConfig, new HazelcastProperties(new Dictionary <string, string>())); var addresses = addressProvider.GetAddresses().ToList(); Assert.AreEqual(addresses[0], new Address("localhost", 5701)); Assert.AreEqual(addresses[1], new Address("localhost", 5702)); Assert.AreEqual(addresses[2], new Address("localhost", 5703)); }
public APICallingResult getTag() { string outputMessage = null; var tags = AddressProvider.getTags(out outputMessage); return(new APICallingResult { Status = tags != null, Data = tags, ProcessMessage = outputMessage }); }
public APICallingResult getContact(int id) { string outputMessage = null; var contact = AddressProvider.getContact(id, out outputMessage); return(new APICallingResult { Status = true, Data = contact, ProcessMessage = outputMessage }); }
public APICallingResult searchContact(int tagId, string keyword) { string outputMessage = null; var contacts = AddressProvider.searchContact(tagId, keyword, out outputMessage); return(new APICallingResult { Status = contacts != null, Data = contacts, ProcessMessage = outputMessage }); }
public void TestMultipleAddressProvider() { var cfg = new ClientConfig(); cfg.GetNetworkConfig().AddAddress("10.0.0.1:5701", "10.0.0.2:5702", "10.0.0.3:5703"); cfg.GetNetworkConfig().GetCloudConfig().SetEnabled(true).SetDiscoveryToken("TOKEN"); Assert.Catch <InvalidConfigurationException>(() => { var addressProvider = new AddressProvider(cfg); addressProvider.GetAddresses(); }); }
public void TestConfigAddressProvider() { var cfg = new ClientConfig(); cfg.GetNetworkConfig().AddAddress("10.0.0.1:5701", "10.0.0.2:5702", "10.0.0.3:5703"); var addressProvider = new AddressProvider(cfg); var addresses = addressProvider.GetAddresses().ToList(); Assert.AreEqual(addresses[0], new Address("10.0.0.1", 5701)); Assert.AreEqual(addresses[1], new Address("10.0.0.2", 5702)); Assert.AreEqual(addresses[2], new Address("10.0.0.3", 5703)); }
public void TestConfigAddressProvider() { var cfg = new Configuration(); cfg.NetworkConfig.AddAddress("10.0.0.1:5701", "10.0.0.2:5702", "10.0.0.3:5703"); var addressProvider = new AddressProvider(cfg.NetworkConfig, new HazelcastProperties(new Dictionary <string, string>())); var addresses = addressProvider.GetAddresses().ToList(); Assert.AreEqual(addresses[0], new Address("10.0.0.1", 5701)); Assert.AreEqual(addresses[1], new Address("10.0.0.2", 5702)); Assert.AreEqual(addresses[2], new Address("10.0.0.3", 5703)); }
public void Cloud() { var options = new NetworkingOptions(); var loggerFactory = new NullLoggerFactory(); options.Addresses.Clear(); options.Cloud.Enabled = true; options.Cloud.DiscoveryToken = null; Assert.Throws <ArgumentException>(() => _ = new AddressProvider(options, loggerFactory)); options.Cloud.DiscoveryToken = "*****"; options.Cloud.UrlBase = null; Assert.Throws <ArgumentNullException>(() => _ = new AddressProvider(options, loggerFactory)); options.Cloud.UrlBase = new Uri("http://xxxxx"); options.Addresses.Add("192.0.0.1:5701"); Assert.Throws <ConfigurationException>(() => _ = new AddressProvider(options, loggerFactory)); options.Addresses.Clear(); CloudDiscovery.SetResponse(@"[ { ""private-address"":""192.0.0.7"", ""public-address"":""192.147.0.7"" }, { ""private-address"":""192.0.0.8"", ""public-address"":""192.147.0.8"" }, { ""private-address"":""192.0.0.9"", ""public-address"":""192.147.0.9:5707"" }, ]"); try { var addressProvider = new AddressProvider(options, loggerFactory); Assert.That(addressProvider.Map(new NetworkAddress("192.0.0.7")), Is.EqualTo(new NetworkAddress("192.147.0.7"))); Assert.That(addressProvider.Map(new NetworkAddress("192.0.0.8")), Is.EqualTo(new NetworkAddress("192.147.0.8"))); Assert.That(addressProvider.Map(new NetworkAddress("192.0.0.9", 5707)), Is.EqualTo(new NetworkAddress("192.147.0.9", 5707))); Assert.That(addressProvider.Map(new NetworkAddress("192.0.0.10")), Is.Null); Assert.That(addressProvider.GetAddresses().Count(), Is.EqualTo(3)); Assert.That(addressProvider.GetAddresses(), Does.Contain(new NetworkAddress("192.0.0.7"))); Assert.That(addressProvider.GetAddresses(), Does.Contain(new NetworkAddress("192.0.0.8"))); Assert.That(addressProvider.GetAddresses(), Does.Contain(new NetworkAddress("192.0.0.9", 5707))); addressProvider = new AddressProvider(options, loggerFactory); Assert.That(addressProvider.Map(new NetworkAddress("192.0.0.10")), Is.Null); Assert.That(addressProvider.Map(new NetworkAddress("192.0.0.10")), Is.Null); } finally { CloudDiscovery.SetResponse(null); } }
public APICallingResult mergeTag(ContactTagModel tagModel) { string outputMessage = null; int idOut = 0; var tag = AddressProvider.mergeTag(tagModel, out idOut, out outputMessage); return(new APICallingResult { Status = tag != null, Data = tag, ProcessMessage = outputMessage, Id = idOut }); }
public APICallingResult deleteTag(int id) { int idOut = 0; string outputMessage = null; AddressProvider.deleteTag(id, out idOut, out outputMessage); return(new APICallingResult { Status = (idOut == id), Data = null, Id = idOut, ProcessMessage = outputMessage }); }
public APICallingResult assignTag(int contactId, int tagId) { string outputMessage = null; int idOut = 0; AddressProvider.changeTagAssign(contactId, tagId, out idOut, out outputMessage); return(new APICallingResult { Status = true, Data = null, ProcessMessage = outputMessage, Id = idOut }); }
public void TestHzCloudAddressProvider() { Environment.SetEnvironmentVariable(HazelcastCloudDiscovery.CloudUrlBaseProperty, LocalTestBaseUrl); var cfg = new ClientConfig(); cfg.GetNetworkConfig().GetCloudConfig().SetEnabled(true).SetDiscoveryToken(DiscoveryToken); var addressProvider = new AddressProvider(cfg); var providedAddresses = addressProvider.GetAddresses().ToList(); Assert.IsNotEmpty(providedAddresses); foreach (var key in providedAddresses) { Assert.True(Addresses.ContainsKey(key)); Assert.AreEqual(addressProvider.TranslateToPublic(key), Addresses[key]); } }
private volatile int _disposed; // disposed flag /// <summary> /// Initializes a new instance of the <see cref="ClusterConnections"/> class. /// </summary> public ClusterConnections(ClusterState clusterState, ClusterMembers clusterMembers, SerializationService serializationService) { _clusterState = clusterState; _clusterMembers = clusterMembers; _logger = _clusterState.LoggerFactory.CreateLogger <ClusterConnections>(); _authenticator = new Authenticator(_clusterState.Options.Authentication, serializationService); _addressProvider = new AddressProvider(_clusterState.Options.Networking, _clusterState.LoggerFactory); _connectRetryStrategy = new RetryStrategy("connect to cluster", _clusterState.Options.Networking.ConnectionRetry, _clusterState.LoggerFactory); if (_clusterState.IsSmartRouting) { _smartRouting = true; _connectAddresses = new ConnectAddresses(GetOrConnectAsync, _clusterState.LoggerFactory); } HConsole.Configure(options => options.Set(this, x => x.SetPrefix("CCNX"))); }
public void TestMultipleAddressProvider() { var cfg = new Configuration(); cfg.NetworkConfig.AddAddress("10.0.0.1:5701", "10.0.0.2:5702", "10.0.0.3:5703"); cfg.NetworkConfig.ConfigureHazelcastCloud(hazelcastCloudConfig => { hazelcastCloudConfig.Enabled = true; hazelcastCloudConfig.DiscoveryToken = "TOKEN"; }); Assert.Catch <InvalidConfigurationException>(() => { var addressProvider = new AddressProvider(cfg.NetworkConfig, new HazelcastProperties(new Dictionary <string, string>())); addressProvider.GetAddresses(); }); }
public IdentityController( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IEmailSender emailSender, ISmsSender smsSender, ILoggerFactory loggerFactory) { _userManager = userManager; _signInManager = signInManager; _emailSender = emailSender; _smsSender = smsSender; _logger = loggerFactory.CreateLogger <IdentityController>(); _dbContext = new ApplicationDbContext(); _addressProvider = new AddressProvider(); _emailProvider = new EmailProvider(); _authEmail = new AuthEmail(); _organisationProvider = new OrganisationProvider(); }
private volatile int _disposed; // disposed flag /// <summary> /// Initializes a new instance of the <see cref="ClusterConnections"/> class. /// </summary> public ClusterConnections(ClusterState clusterState, ClusterMembers clusterMembers, SerializationService serializationService) { _clusterState = clusterState; _clusterMembers = clusterMembers; _logger = _clusterState.LoggerFactory.CreateLogger <ClusterConnections>(); _authenticator = new Authenticator(_clusterState.Options.Authentication, serializationService, _clusterState.LoggerFactory); _addressProvider = new AddressProvider(_clusterState.Options.Networking, _clusterState.LoggerFactory); _connectRetryStrategy = new RetryStrategy("connect to cluster", _clusterState.Options.Networking.ConnectionRetry, _clusterState.LoggerFactory); if (_clusterState.IsSmartRouting) { _connectMembers = ConnectMembers(_cancel.Token); } _clusterState.StateChanged += OnStateChanged; HConsole.Configure(x => x.Configure <ClusterConnections>().SetPrefix("CCNX")); }
private HazelcastClient(ClientConfig config) { _config = config; var groupConfig = config.GetGroupConfig(); _instanceName = "hz.client_" + _id + (groupConfig != null ? "_" + groupConfig.GetName() : string.Empty); _lifecycleService = new LifecycleService(this); try { //TODO make partition strategy parametric var partitioningStrategy = new DefaultPartitioningStrategy(); _serializationService = new SerializationServiceBuilder().SetManagedContext(new HazelcastClientManagedContext(this, config.GetManagedContext())) .SetConfig(config.GetSerializationConfig()) .SetPartitioningStrategy(partitioningStrategy) .SetVersion(SerializationService.SerializerVersion) .Build(); } catch (Exception e) { throw ExceptionUtil.Rethrow(e); } _proxyManager = new ProxyManager(this); //TODO EXECUTION SERVICE _executionService = new ClientExecutionService(_instanceName, config.GetExecutorPoolSize()); _clusterService = new ClientClusterService(this); _loadBalancer = config.GetLoadBalancer() ?? new RoundRobinLB(); _addressProvider = new AddressProvider(_config); _connectionManager = new ClientConnectionManager(this); _invocationService = CreateInvocationService(); _listenerService = new ClientListenerService(this); _userContext = new ConcurrentDictionary <string, object>(); _partitionService = new ClientPartitionService(this); _lockReferenceIdGenerator = new ClientLockReferenceIdGenerator(); _statistics = new Statistics(this); _nearCacheManager = new NearCacheManager(this); _credentialsFactory = InitCredentialsFactory(config); }
public bool ExecuteMareketingPlan(decimal budget) { bool result = false; AddressProvider MyAddressProvider = new AddressProvider(); DoAfterGetAddresses ToDoAfterAddresses; if (budget < 10000) { PenCompany MyBallpenCompany = new PenCompany(); ToDoAfterAddresses = MyBallpenCompany.SendPens; } else { CoffeeCupCompany MyCoffeeCupCompany = new CoffeeCupCompany(); ToDoAfterAddresses = MyCoffeeCupCompany.SendCoffeCups; } result = MyAddressProvider.HandleCampaign(ToDoAfterAddresses); return(result); }
private HazelcastClient(Configuration config) { Configuration = config; HazelcastProperties = new HazelcastProperties(config.Properties); if (config.InstanceName != null) { _instanceName = config.InstanceName; } else { _instanceName = "hz.client_" + _id; } LifecycleService = new LifecycleService(this); try { //TODO make partition strategy parametric var partitioningStrategy = new DefaultPartitioningStrategy(); SerializationService = new SerializationServiceBuilder().SetConfig(config.SerializationConfig) .SetPartitioningStrategy(partitioningStrategy) .SetVersion(IO.Serialization.SerializationService.SerializerVersion).Build(); } catch (Exception e) { throw ExceptionUtil.Rethrow(e); } ProxyManager = new ProxyManager(this); //TODO EXECUTION SERVICE ExecutionService = new ExecutionService(_instanceName); LoadBalancer = config.LoadBalancer ?? new RoundRobinLB(); PartitionService = new PartitionService(this); AddressProvider = new AddressProvider(Configuration.NetworkConfig, HazelcastProperties); ConnectionManager = new ConnectionManager(this); InvocationService = new InvocationService(this); ListenerService = new ListenerService(this); ClusterService = new ClusterService(this); LockReferenceIdGenerator = new ClientLockReferenceIdGenerator(); // Statistics = new Statistics(this); NearCacheManager = new NearCacheManager(this); CredentialsFactory = config.SecurityConfig.AsCredentialsFactory() ?? new StaticCredentialsFactory(new UsernamePasswordCredentials()); }
public void Should_Return_Deserialized_Example_API_Result() { var addressProvider = new AddressProvider(new RestClient()); var zipCodeLookupRequest = new ZipCodeLookupRequest { Address = new Address { Address1 = "911 Military St", City = "Port Huron", State = "MI" } }; var zipCodeResponse = addressProvider.SendZipCodeLookupRequest(zipCodeLookupRequest); Assert.NotNull(zipCodeResponse); Assert.Equal("PORT HURON", zipCodeResponse.Address.City); Assert.Equal("48060", zipCodeResponse.Address.Zip5); Assert.Equal("5414", zipCodeResponse.Address.Zip4); }
public void TestHzCloudAddressProvider() { Environment.SetEnvironmentVariable(HazelcastProperties.CloudUrlBase.Name, LocalTestBaseUrl); var cfg = new Configuration(); cfg.NetworkConfig.ConfigureHazelcastCloud(hzCloudCfg => { hzCloudCfg.Enabled = true; hzCloudCfg.DiscoveryToken = DiscoveryToken; }); var addressProvider = new AddressProvider(cfg); var providedAddresses = addressProvider.GetAddresses().ToList(); Assert.IsNotEmpty(providedAddresses); foreach (var key in providedAddresses) { Assert.True(Addresses.ContainsKey(key)); Assert.AreEqual(addressProvider.TranslateToPublic(key), Addresses[key]); } }
/// <summary> /// Enregistre ou insert les objets nécessaire sur la facture /// </summary> /// <param name="invoicepo"></param> public void SaveFullInvoice(Invoice invoicepo) { try { SOLUTIONS.INVOICES.CONTACT.AddressProvider addressProvider = new AddressProvider(this.Connector); if (invoicepo.IDInvoice < 0) { this.InsertInvoice(invoicepo); // mode insertion } // ENREGISTREMENT DES ADDRESS if (invoicepo.BuyerAddress != null) { addressProvider.SaveAddress(invoicepo.BuyerAddress); if (invoicepo.BuyerAddress.IDAddress != invoicepo.BuyerIDAddress) { invoicepo.BuyerIDAddress = invoicepo.BuyerAddress.IDAddress; } } if (invoicepo.SellerAddress != null) { addressProvider.SaveAddress(invoicepo.SellerAddress); if (invoicepo.SellerAddress.IDAddress != invoicepo.SellerIDAddress) { invoicepo.SellerIDAddress = invoicepo.SellerAddress.IDAddress; } } // ENREGISTREMENT DES LIGNES foreach (InvoiceLine item in invoicepo.Lines) { this.SaveLine(item, invoicepo); } // ENREGISTREMENT FINAL this.SaveInvoice(invoicepo); } catch (Exception ex) { throw new Exception("SaveInvoice" + ex.Message, ex); } }
private HazelcastClient(ClientConfig config) { ClientConfig = config; if (config.InstanceName != null) { _instanceName = config.InstanceName; } else { _instanceName = "hz.client_" + _id; } LifecycleService = new LifecycleService(this); try { //TODO make partition strategy parametric var partitioningStrategy = new DefaultPartitioningStrategy(); SerializationService = new SerializationServiceBuilder().SetConfig(config.GetSerializationConfig()) .SetPartitioningStrategy(partitioningStrategy) .SetVersion(IO.Serialization.SerializationService.SerializerVersion).Build(); } catch (Exception e) { throw ExceptionUtil.Rethrow(e); } ProxyManager = new ProxyManager(this); //TODO EXECUTION SERVICE ExecutionService = new ExecutionService(_instanceName, config.GetExecutorPoolSize()); LoadBalancer = config.GetLoadBalancer() ?? new RoundRobinLB(); PartitionService = new PartitionService(this); AddressProvider = new AddressProvider(ClientConfig); ConnectionManager = new ConnectionManager(this); InvocationService = new InvocationService(this); ListenerService = new ListenerService(this); ClusterService = new ClusterService(this); LockReferenceIdGenerator = new ClientLockReferenceIdGenerator(); // Statistics = new Statistics(this); NearCacheManager = new NearCacheManager(this); CredentialsFactory = InitCredentialsFactory(config); }