public void GetEmployeesTest() { var emp = new Employee { Id = 4, FullName = "Иванов Иван Иванович", HireDate = new DateTime(2012, 10, 25), Phone = "+7(3452)736291", Position = "Уборщик", Department = "Уборщики" }; var accessControl = new AccessControlModule(); var answer = accessControl.GetEmployees(); var reader = new StreamReader(answer); var data = reader.ReadToEnd(); var res = JsonConvert.DeserializeObject <List <Employee> >(data); Assert.AreEqual(res[0], emp); }
public void AddSeveralAccessRules() { var accessControl = new AccessControlModule(); var answer = accessControl.GetEmployees(); var reader = new StreamReader(answer); var data = reader.ReadToEnd(); var employees = JsonConvert.DeserializeObject <List <Employee> >(data); answer = accessControl.GetCardReaders(); reader = new StreamReader(answer); data = reader.ReadToEnd(); var cardReaders = JsonConvert.DeserializeObject <List <CardReader> >(data); var rnd = new Random(); var accessRules = new AccessRulesModule(); var jsonSerializer = new JsonConvertWrapper(); foreach (var employee in employees) { var aclItem = new AclItem { AclObjectID = cardReaders[rnd.Next(1000)].Id, AclSubjectID = employee.Id, ActionID = rnd.Next(1, 10), Access = true }; var serializedCardRearer = jsonSerializer.Serialize(aclItem); var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(serializedCardRearer); writer.Flush(); stream.Position = 0; answer = accessRules.AddAccessRule(stream); } }
public void GetAndDeleteEmployeesTest() { var accessControl = new AccessControlModule(); Stopwatch sWatch = new Stopwatch(); sWatch.Start(); var answer = accessControl.GetEmployees(); sWatch.Stop(); TimeSpan tSpan = sWatch.Elapsed; sWatch = new Stopwatch(); var reader = new StreamReader(answer); var data = reader.ReadToEnd(); var res = JsonConvert.DeserializeObject <List <Employee> >(data); sWatch.Start(); foreach (var employee in res) { accessControl.DeleteEmployee(employee.Id.ToString()); } sWatch.Stop(); tSpan = sWatch.Elapsed; }
public void GetEmployeesTest() { var emp = new Employee { Id = 4, FullName = "Иванов Иван Иванович", HireDate = new DateTime(2012, 10, 25), Phone = "+7(3452)736291", Position = "Уборщик", Department = "Уборщики" }; var accessControl = new AccessControlModule(); var answer = accessControl.GetEmployees(); var reader = new StreamReader(answer); var data = reader.ReadToEnd(); var res = JsonConvert.DeserializeObject<List<Employee>>(data); Assert.AreEqual(res[0], emp); }
public void GetAndDeleteEmployeesTest() { var accessControl = new AccessControlModule(); Stopwatch sWatch = new Stopwatch(); sWatch.Start(); var answer = accessControl.GetEmployees(); sWatch.Stop(); TimeSpan tSpan = sWatch.Elapsed; sWatch = new Stopwatch(); var reader = new StreamReader(answer); var data = reader.ReadToEnd(); var res = JsonConvert.DeserializeObject<List<Employee>>(data); sWatch.Start(); foreach (var employee in res) { accessControl.DeleteEmployee(employee.Id.ToString()); } sWatch.Stop(); tSpan = sWatch.Elapsed; }