static void Main(string[] args) { IEnterprise enterprise = new Enterprise(); Employee employee = new Employee("pesho", "gosho", 123, Position.Hr, DateTime.Now); enterprise.Add(employee); Employee toReplace = new Employee("replaced", "replacedEmployee", 555, Position.Owner, DateTime.Now); enterprise.Add(new Employee("sosho", "pesho", 321, Position.Manager, DateTime.Now)); enterprise.Add(new Employee("posho", "kosho", 55, Position.Hr, DateTime.Now)); enterprise.Add(new Employee("gosho", "mosho", 1, Position.Manager, DateTime.Now)); Console.WriteLine( enterprise.Change(employee.Id, toReplace)); Console.WriteLine(enterprise.Contains(employee.Id)); Employee byUuid = enterprise.GetByGuid(employee.Id); Console.WriteLine(byUuid.FirstName); //REPLACED Console.WriteLine( byUuid.LastName); //REPLACED EMPLOYEE Console.WriteLine(byUuid.Salary); }
public void ChangeId() { IEnterprise enterprise = new Enterprise(); List <Employee> employees = new List <Employee>(); for (int i = 0; i < 100000; i++) { Employee employee = new Employee("a" + i, "a" + i, 1, Position.Hr, DateTime.Now); employees.Add(employee); enterprise.Add(employee); } int count = enterprise.Count; Assert.AreEqual(100000, count); Stopwatch watch = new Stopwatch(); watch.Start(); foreach (Employee employee in employees) { Assert.AreEqual(true, enterprise.Contains(employee.Id)); Employee byGuid = enterprise.GetByGuid(employee.Id); enterprise.Change(Guid.NewGuid(), byGuid); } watch.Stop(); long l1 = watch.ElapsedMilliseconds; Assert.IsTrue(l1 < 350); }
static void Main(string[] args) { var enterprise = new Enterprise(); Guid guid = Guid.NewGuid(); Console.WriteLine(guid.ToString()); enterprise.Add(new Employee("first", "last", 120, Position.Manager, DateTime.Now)); enterprise.Change(guid, new Employee("sss", "aaa", 120, Position.Developer, DateTime.Now)); Employee emp = enterprise.GetByGuid(guid); var asd = enterprise.GetByPosition(Position.Developer); }