public void LST_REMOVE_ADD() { ProtobufList <UserBase1> lst = "USERS"; lst.Add(new UserBase1 { Name = "john", Age = 10, City = "wx", Country = "zc" }); lst.Add(new UserBase1 { Name = "bbq", Age = 19, City = "gz", Country = "us" }); Assert.AreEqual("bbq", lst.Remove().Name); }
public void LST_REMOVE_ADD() { ProtobufList <UserBase> lst = "USERS"; lst.Add(new UserBase { Name = "henry", Age = 18, City = "gz", Counrty = "cn" }); lst.Add(new UserBase { Name = "bbq", Age = 18, City = "gz", Counrty = "cn" }); Assert.AreEqual("bbq", lst.Remove().Name); }
public void LST_LENGTH() { ProtobufList <UserBase1> lst = "USERS"; lst.Clear(); lst.Add(new UserBase1 { Name = "john", Age = 19, City = "wx", Country = "zn" }); lst.Add(new UserBase1 { Name = "bbq", Age = 19, City = "wx", Country = "zn" }); Assert.AreEqual(lst.Count(), 2); }
public void LST_Length() { ProtobufList <UserBase> lst = "USERS"; lst.Clear(); lst.Add(new UserBase { Name = "henry", Age = 18, City = "gz", Counrty = "cn" }); lst.Add(new UserBase { Name = "bbq", Age = 18, City = "gz", Counrty = "cn" }); Assert.AreEqual(lst.Count(), 2); }
public void LST_Region() { ProtobufList <UserBase> lst = "USERS"; lst.Clear(); for (int i = 0; i < 10; i++) { lst.Add(new UserBase { Name = "henry" + i, Age = 18, City = "gz", Counrty = "cn" }); } IList <UserBase> items = lst.Range(); Assert.AreEqual(items[0].Name, "henry0"); Assert.AreEqual(items[9].Name, "henry9"); items = lst.Range(5, 7); Assert.AreEqual(items[0].Name, "henry5"); Assert.AreEqual(items[2].Name, "henry7"); }
public void LST_Region() { ProtobufList <UserBase1> lst = "USERS"; lst.Clear(); for (int i = 0; i < 10; i++) { lst.Add(new UserBase1 { Name = "john" + i, Age = 19, City = "wx", Country = "zc" }); } IList <UserBase1> items = lst.Range(); Assert.AreEqual(items[0].Name, "john0"); Assert.AreEqual(items[9].Name, "john9"); items = lst.Range(5, 7); Assert.AreEqual(items[0].Name, "john5"); Assert.AreEqual(items[2].Name, "john7"); }
public void Import() { Model.DataSet1.OrdersDataTable odt = new Model.DataSet1.OrdersDataTable(); odt.ReadXml("Orders.xml"); ProtobufList <Order> orders = "Orders"; orders.Clear(); foreach (Model.DataSet1.OrdersRow order in odt.Rows) { Order item = new Order(); item.CustomerID = order.CustomerID; item.EmployeeID = order.EmployeeID; item.Freight = (double)order.Freight; item.OrderDate = order.OrderDate; item.OrderID = order.OrderID; item.RequiredDate = order.RequiredDate; item.ShipAddress = order.ShipAddress; item.ShipCity = order.ShipCity; item.ShipCountry = order.ShipCountry; item.ShipName = order.ShipName; item.ShippedDate = order.ShippedDate; item.ShipPostalCode = order.ShipPostalCode; item.ShipVia = order.ShipVia; ("order_" + item.OrderID).SetProtobuf(item); orders.Add(item); } Model.DataSet1.EmployeesDataTable edt = new Model.DataSet1.EmployeesDataTable(); edt.ReadXml("Employees.xml"); foreach (Model.DataSet1.EmployeesRow erow in edt.Rows) { Employee emp = new Employee(); emp.EmployeeID = erow.EmployeeID; emp.Address = erow.Address; emp.BirthDate = erow.BirthDate; emp.City = erow.City; emp.Country = erow.Country; emp.Extension = erow.Extension; emp.FirstName = erow.FirstName; emp.HireDate = erow.HireDate; emp.HomePhone = erow.HomePhone; emp.LastName = erow.LastName; emp.Notes = erow.Notes; emp.PostalCode = erow.PostalCode; emp.Region = erow.Region; emp.Title = erow.Title; emp.TitleOfCourtesy = erow.TitleOfCourtesy; ("emp_" + emp.EmployeeID).SetProtobuf(emp); } Model.DataSet1.CustomersDataTable cdt = new Model.DataSet1.CustomersDataTable(); cdt.ReadXml("customers.xml"); foreach (Model.DataSet1.CustomersRow crow in cdt.Rows) { Customer cust = new Customer(); cust.Address = crow.Address; cust.City = crow.City; cust.CompanyName = crow.CompanyName; cust.ContactName = crow.ContactName; cust.ContactTitle = crow.ContactTitle; cust.Country = crow.Country; cust.CustomerID = crow.CustomerID; cust.Fax = crow.Fax; cust.Phone = crow.Phone; cust.PostalCode = crow.PostalCode; ("cust_" + cust.CustomerID).SetProtobuf(cust); } }