public void AddEmployeeTest() { var emp = new Employee { FullName = "Васин Василий Васильевич", HireDate = new DateTime(2012, 10, 25), Phone = "+7(3452)736291", Position = "Уборщик", Department = "Уборщики" }; var accessControl = new AccessControlModule(); var jsonSerializer = new JsonConvertWrapper(); var serializedEmp = jsonSerializer.Serialize(emp); var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(serializedEmp); writer.Flush(); stream.Position = 0; var answer = accessControl.AddEmployee(stream); var reader = new StreamReader(answer); var data = reader.ReadToEnd(); var res = JsonConvert.DeserializeObject <int>(data); Assert.AreEqual(res, 1); }
public void AddEmployeeTest() { var emp = new Employee { FullName = "Васин Василий Васильевич", HireDate = new DateTime(2012, 10, 25), Phone = "+7(3452)736291", Position = "Уборщик", Department = "Уборщики" }; var accessControl = new AccessControlModule(); var jsonSerializer = new JsonConvertWrapper(); var serializedEmp = jsonSerializer.Serialize(emp); var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(serializedEmp); writer.Flush(); stream.Position = 0; var answer = accessControl.AddEmployee(stream); var reader = new StreamReader(answer); var data = reader.ReadToEnd(); var res = JsonConvert.DeserializeObject<int>(data); Assert.AreEqual(res, 1); }
public void AddSeveralEmployeesTest() { var employees = new List <Employee>(); var rnd = new Random(); var bytes = new byte[30]; for (int i = 0; i < 1000; i++) { var emp = new Employee(); rnd.NextBytes(bytes); emp.FullName = Encoding.UTF8.GetString(bytes); emp.HireDate = DateTime.MinValue.AddDays(rnd.Next(1000000, 3000000)); emp.Phone = rnd.Next(111111, 9999999).ToString(); rnd.NextBytes(bytes); emp.Position = Encoding.UTF8.GetString(bytes); rnd.NextBytes(bytes); emp.Department = Encoding.UTF8.GetString(bytes); employees.Add(emp); } Stopwatch sWatch = new Stopwatch(); sWatch.Start(); var accessControl = new AccessControlModule(); var jsonSerializer = new JsonConvertWrapper(); foreach (var employee in employees) { var serializedEmp = jsonSerializer.Serialize(employee); var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(serializedEmp); writer.Flush(); stream.Position = 0; var answer = accessControl.AddEmployee(stream); } sWatch.Stop(); TimeSpan tSpan = sWatch.Elapsed; }
public void AddSeveralEmployeesTest() { var employees = new List<Employee>(); var rnd = new Random(); var bytes = new byte[30]; for (int i = 0; i < 1000; i++) { var emp = new Employee(); rnd.NextBytes(bytes); emp.FullName = Encoding.UTF8.GetString(bytes); emp.HireDate = DateTime.MinValue.AddDays(rnd.Next(1000000,3000000)); emp.Phone = rnd.Next(111111, 9999999).ToString(); rnd.NextBytes(bytes); emp.Position = Encoding.UTF8.GetString(bytes); rnd.NextBytes(bytes); emp.Department = Encoding.UTF8.GetString(bytes); employees.Add(emp); } Stopwatch sWatch = new Stopwatch(); sWatch.Start(); var accessControl = new AccessControlModule(); var jsonSerializer = new JsonConvertWrapper(); foreach (var employee in employees) { var serializedEmp = jsonSerializer.Serialize(employee); var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(serializedEmp); writer.Flush(); stream.Position = 0; var answer = accessControl.AddEmployee(stream); } sWatch.Stop(); TimeSpan tSpan = sWatch.Elapsed; }