public Employees SearchEmployees(string idType, string lastName, string firstName, string location, string badgeNumber) { //Get issue search data KronosClient client = null; Employees employees = new Employees(); try { string _lastName = (lastName != null && lastName.Trim().Length > 0) ? lastName : null; string _firstName = (firstName != null && firstName.Trim().Length > 0) ? firstName : null; string _location = (location != null && location.Trim().Length > 0) ? location : null; string _badgeNumber = (badgeNumber != null && badgeNumber.Trim().Length > 0) ? badgeNumber : null; if (_lastName == null && _firstName == null && _location == null && _badgeNumber == null) { return(new Employees()); } client = new KronosClient(); employees = client.SearchEmployees(idType, _lastName, _firstName, _location, _badgeNumber); client.Close(); } catch (FaultException fe) { throw new ApplicationException("SearchEmployees() service error.", fe); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException("SearchEmployees() timeout error.", te); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException("SearchEmployees() communication error.", ce); } return(employees); }
protected override void AdditionalSetup() { _data = Prepare.Bytes(PackageSize); Task kronos = KronosClient.ClearAsync(); Task redis = RedisServer.FlushAllDatabasesAsync(); Task.WaitAll(kronos, redis); }
protected override void AdditionalSetup() { _data = Prepare.Bytes(PackageSize); Task kronos = KronosClient.ClearAsync(); Task[] redisTasks = RedisServers.Select(x => x.FlushAllDatabasesAsync()).ToArray(); Task.WaitAll(redisTasks); Task.WaitAll(kronos); }
public void WriteLogEntry(TraceMessage m) { //Get the operating enterprise terminal KronosClient _Client = null; try { _Client = new KronosClient(); _Client.WriteLogEntry(m); _Client.Close(); } catch (FaultException fe) { throw new ApplicationException("WriteLogEntry() service error.", fe); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("WriteLogEntry() timeout error.", te); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("WriteLogEntry() communication error.", ce); } }
public async Task Delete_CallsSendToServerAsync() { var connectionMock = Substitute.For <IConnection>(); connectionMock.SendAsync(Arg.Any <DeleteRequest>()) .Returns(SerializationUtils.Serialize(true)); KronosConfig config = LoadTestConfiguration(); IKronosClient client = new KronosClient(config, endpoint => connectionMock); await client.DeleteAsync("key"); await connectionMock.Received(1).SendAsync(Arg.Any <DeleteRequest>()); }
public Employees GetEmployeeList(string idType) { //Get a list all employees from idType database Employees employees = null; KronosClient _Client = null; try { _Client = new KronosClient(); employees = _Client.GetEmployeeList(idType); _Client.Close(); } catch (FaultException fe) { throw new ApplicationException("GetEmployeeList() service error.", fe); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetEmployeeList() timeout error.", te); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetEmployeeList() communication error.", ce); } return(employees); }
public object[] GetIDTypes() { //Get invoices for the specified client object[] types = null; KronosClient _Client = null; try { _Client = new KronosClient(); types = _Client.GetIDTypes(); _Client.Close(); } catch (FaultException fe) { throw new ApplicationException("GetIDTypes() service error.", fe); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetIDTypes() timeout error.", te); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetIDTypes() communication error.", ce); } return(types); }
public TerminalInfo GetTerminalInfo() { //Get the operating enterprise terminal TerminalInfo terminal = null; KronosClient _Client = null; try { _Client = new KronosClient(); terminal = _Client.GetTerminalInfo(); _Client.Close(); } catch (FaultException fe) { throw new ApplicationException("GetTerminalInfo() service error.", fe); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetTerminalInfo() timeout error.", te); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetTerminalInfo() communication error.", ce); } return(terminal); }
public UserConfiguration GetUserConfiguration(string application, string[] usernames) { //Get the operating enterprise terminal UserConfiguration config = null; KronosClient _Client = null; try { _Client = new KronosClient(); config = _Client.GetUserConfiguration(application, usernames); _Client.Close(); } catch (FaultException fe) { throw new ApplicationException("GetUserConfiguration() service error.", fe); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetUserConfiguration() timeout error.", te); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetUserConfiguration() communication error.", ce); } return(config); }
public void Kronos() { Parallel.For(0, Clients, _ => { string key = Prepare.Key(); KronosClient.InsertAsync(key, _data, null) .GetAwaiter().GetResult(); KronosClient.GetAsync(key) .GetAwaiter().GetResult(); KronosClient.DeleteAsync(key) .GetAwaiter().GetResult(); }); }
public Employee GetEmployee(string idType, int idNumber) { //Get an individual employee from idType database Employee employee = null; KronosClient _Client = null; try { _Client = new KronosClient(); employee = _Client.GetEmployee(idType, idNumber); _Client.Close(); } catch (FaultException fe) { throw new ApplicationException("GetEmployee() service error.", fe); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetEmployee() timeout error.", te); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetEmployee() communication error.", ce); } return(employee); }
public async Task Get_DoestNotReturnObject() { byte[] serverResponse = SerializationUtils.Serialize(RequestStatusCode.NotFound); var connectionMock = Substitute.For <IConnection>(); connectionMock.SendAsync(Arg.Any <GetRequest>()) .Returns(SerializationUtils.Serialize(serverResponse)); KronosConfig config = LoadTestConfiguration(); IKronosClient client = new KronosClient(config, endpoint => connectionMock); byte[] response = await client.GetAsync("key"); Assert.Null(response); await connectionMock.Received(1).SendAsync(Arg.Any <GetRequest>()); }
public async Task Contains_ReturnsTrueIfElementExistsInStorage() { bool expected = true; string key = "lorem ipsum"; var connectionMock = Substitute.For <IConnection>(); connectionMock.SendAsync(Arg.Any <ContainsRequest>()) .Returns(SerializationUtils.Serialize(expected)); KronosConfig config = LoadTestConfiguration(); IKronosClient client = new KronosClient(config, endpoint => connectionMock); bool exists = await client.ContainsAsync(key); Assert.Equal(expected, exists); await connectionMock.Received(1).SendAsync(Arg.Any <ContainsRequest>()); }
public async Task Count_ReturnsNumberOfElementsInStorage() { int countPerServer = 5; var connectionMock = Substitute.For <IConnection>(); connectionMock.SendAsync(Arg.Any <CountRequest>()) .Returns(SerializationUtils.Serialize(countPerServer)); KronosConfig config = LoadTestConfiguration(); int serverCount = config.ClusterConfig.Servers.Length; IKronosClient client = new KronosClient(config, endpoint => connectionMock); int sum = await client.CountAsync(); Assert.Equal(sum, countPerServer * serverCount); await connectionMock.Received(serverCount).SendAsync(Arg.Any <CountRequest>()); }
public async Task Insert_InsertsObjectToStorage() { string key = "key"; byte[] package = Encoding.UTF8.GetBytes("package"); DateTime expiryDate = DateTime.Today.AddDays(1); var connectionMock = Substitute.For <IConnection>(); connectionMock.SendAsync(Arg.Any <IRequest>()) .Returns(SerializationUtils.Serialize(true)); KronosConfig config = LoadTestConfiguration(); IKronosClient client = new KronosClient(config, endpoint => connectionMock); await client.InsertAsync(key, package, expiryDate); await connectionMock.Received(1).SendAsync(Arg.Any <InsertRequest>()); }
public async Task Get_ReturnsObject() { const string word = "lorem ipsum"; byte[] package = SerializationUtils.Serialize(word); var connectionMock = Substitute.For <IConnection>(); connectionMock.SendAsync(Arg.Any <GetRequest>()) .Returns(SerializationUtils.Serialize(package)); KronosConfig config = LoadTestConfiguration(); IKronosClient client = new KronosClient(config, endpoint => connectionMock); byte[] response = await client.GetAsync("key"); string responseString = SerializationUtils.Deserialize <string>(response); Assert.Equal(responseString, word); await connectionMock.Received(1).SendAsync(Arg.Any <GetRequest>()); }
public async Task Kronos() { string key = Prepare.Key(); await KronosClient.ContainsAsync(key); }