/// <summary> /// One time call to create Private Client /// /// </summary> /// <param name="accessHelper"></param> public void CreatePrivateClient(string serverURL = null) { if (_privateClient == null) { try { ILoggerFactory l = null; //Log.Info("Creating PrivateClient on " + serverURL); LoggerFactory factory = new LoggerFactory(); factory.AddDebug(Microsoft.Extensions.Logging.LogLevel.Trace); PrivateServerSettings settings = new PrivateServerSettings { ServerUrl = new Uri(serverURL ?? TestConfig.GetValueFromConfig("PrivateServer")), LoggerFactory = factory }; _privateClient = PrivateClient.CreateClient(settings); } catch (Exception e) { //Log.Error(e); } } else { //Log.Info("PrivateClient already created"); } }
public async Task ServerTest() { var req = FieldRequest.CreateFields(); req = req.Append(CreateFieldRequest.Builder().With(ResourceId.Activity, FieldType.Number, "test").Build().Content); var built = ((CreateFieldsRequest.IBuilderWithRecord)req).Build(); IPrivateClient client = PrivateClient.CreateClient(new PrivateServerSettings { ServerUrl = new Uri("http://namtest3-web.dynamic.ps.porters.local"), LoggerFactory = TestLoggerFactoryAttribute.CurrentLoggerFactory }); using (var session = client.CreateSession(PrivateAuthentication.WithCredentials("TestCompany", "*****@*****.**", "password"))) { var fields = await session.CallAsync(built); Assume.That(fields.FieldFailed, Has.Count.EqualTo(0)); Assume.That(fields.FieldSuccess, Has.Count.GreaterThan(0)); var mapping = fields.FieldSuccess.ToDictionary(entry => entry.Value, entry => entry.Key); var res = await session.CallAsync(FieldRequest.GetFields().Select(FieldProperty.Name).WhereGuid(fields.FieldSuccess.Values)); var conv = res .ToDictionary(fieldEntry => mapping[(Guid)fieldEntry.Value[FieldProperty.Id]], fieldEntry => fieldEntry.Value); Assert.That(res, Has.Count.GreaterThan(0)); } }
public void TestPrivateAuthenticationSuccess() { IPrivateClient client = PrivateClient.CreateClient(new PrivateServerSettings { ServerUrl = new Uri("http://namtest3-web.dynamic.ps.porters.local") }); using (var session = client.CreateSession(PrivateAuthentication.WithCredentials("TestCompany", "*****@*****.**", "password"))) { var result = session.Call(MetaDataRequest.LastUpdated(1)); Assert.That(result.LastUpdateDate, Is.GreaterThan(0)); } }
public async Task UpdateSingleField() { IPrivateClient client = PrivateClient.CreateClient(new PrivateServerSettings { ServerUrl = new Uri("http://namtest2-web.dynamic.ps.porters.local"), LoggerFactory = TestLoggerFactoryAttribute.CurrentLoggerFactory }); using (var session = client.CreateSession(PrivateAuthentication.WithCredentials("TestCompany", "*****@*****.**", "password"))) { var req = await session.CallAsync(FieldRequest.UpdateField().Field("Client.P_Name".ToField()).Label("Woof")); Assert.That(req); } }
public ClientMocker(Mock <HttpClientHandler> mock, IPrivateClient client) { Mock = mock; Client = client; }