public void MapRecordCreateInstanceNotNull() { CustomDataRecord record = new CustomDataRecord(new List <KeyValuePair <string, object> >()); Employee model = _mapper.MapRecord <Employee>(record); Assert.IsNotNull(model); }
public void MapFullEmployeeModel() { bool active = _faker.Random.Bool(); int departmentID = _faker.Random.Int(); string phoneNumber = _faker.Phone.PhoneNumber(); decimal salary = _faker.Random.Decimal(); Guid managerID = _faker.Random.Guid(); DateTime hireDate = _faker.Date.Soon(); PhoneType phoneType = _faker.PickRandom <PhoneType>(); List <KeyValuePair <string, object> > kvp = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("Earnings", salary), new KeyValuePair <string, object>("ManagerID", managerID), new KeyValuePair <string, object>("PhoneType", phoneType), new KeyValuePair <string, object>("Active", active), new KeyValuePair <string, object>("DepartmentID", departmentID), new KeyValuePair <string, object>("PhoneNumber", phoneNumber), new KeyValuePair <string, object>("HireDate", hireDate) }; CustomDataRecord record = new CustomDataRecord(kvp); Employee model = _mapper.MapRecord <Employee>(record); Assert.AreEqual(active, model.Active); Assert.AreEqual(salary, model.Salary); Assert.AreEqual(hireDate, model.HireDate); Assert.AreEqual(departmentID, model.DepartmentID); Assert.AreEqual(managerID, model.ManagerID); Assert.AreEqual(phoneNumber, model.PhoneNumber); Assert.AreEqual(phoneType, model.PhoneType); }
public void MapRecordCreateInstance() { decimal salary = _faker.Random.Decimal(); PhoneType type = _faker.PickRandom <PhoneType>(); Guid id = _faker.Random.Guid(); string title = _faker.Random.AlphaNumeric(30); int departmentID = _faker.Random.Int(); List <KeyValuePair <string, object> > kvp = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("EmployeeID", id), new KeyValuePair <string, object>("Title", title), new KeyValuePair <string, object>("Salary", salary), new KeyValuePair <string, object>("DepartmentID", departmentID), new KeyValuePair <string, object>("PhoneType", type) }; CustomDataRecord record = new CustomDataRecord(kvp); Employee model = _mapper.MapRecord <Employee>(record); Assert.AreEqual(salary, model.Salary); Assert.AreEqual(title, model.Title); Assert.AreEqual(id, model.EmployeeID); Assert.AreEqual(departmentID, model.DepartmentID); Assert.AreEqual(type, model.PhoneType); }
public void MapDbFieldNull() { List <KeyValuePair <string, object> > kvp = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("EmployeeTitle", DBNull.Value) }; CustomDataRecord record = new CustomDataRecord(kvp); Employee model = _mapper.MapRecord <Employee>(record); Assert.IsTrue(model.Title == "SoftwareDeveloper"); }
public void MapNullableWithNullValue() { List <KeyValuePair <string, object> > kvp = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("ManagerID", DBNull.Value) }; CustomDataRecord record = new CustomDataRecord(kvp); Employee model = _mapper.MapRecord <Employee>(record); Assert.IsNull(model.ManagerID); }
public void MapNullValueNullEnumProperty() { List <KeyValuePair <string, object> > kvp = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("PhoneType", DBNull.Value) }; CustomDataRecord record = new CustomDataRecord(kvp); Employee model = _mapper.MapRecord <Employee>(record); Assert.IsNull(model.PhoneType); }
public void MapNullableWithValue() { Guid managerID = Guid.NewGuid(); List <KeyValuePair <string, object> > kvp = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("ManagerID", managerID) }; CustomDataRecord record = new CustomDataRecord(kvp); Employee model = _mapper.MapRecord <Employee>(record); Assert.AreEqual(managerID, model.ManagerID); }
public void MapValueNullEnumProperty() { PhoneType type = _faker.PickRandom <PhoneType>(); List <KeyValuePair <string, object> > kvp = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("PhoneType", type) }; CustomDataRecord record = new CustomDataRecord(kvp); Employee model = _mapper.MapRecord <Employee>(record); Assert.AreEqual(type, model.PhoneType); }
public void MapNormalProperty() { Guid employeedID = Guid.NewGuid(); List <KeyValuePair <string, object> > kvp = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("EmployeeID", employeedID) }; CustomDataRecord record = new CustomDataRecord(kvp); Employee model = _mapper.MapRecord <Employee>(record); Assert.AreEqual(employeedID, model.EmployeeID); }
public void MapNonExistentProperty() { decimal wage = _faker.Random.Decimal(); List <KeyValuePair <string, object> > kvp = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("Wage", wage) }; CustomDataRecord record = new CustomDataRecord(kvp); Employee model = _mapper.MapRecord <Employee>(record); Assert.IsTrue(model.Salary == default); }
public void MapDbField() { decimal earnings = _faker.Random.Decimal(); List <KeyValuePair <string, object> > kvp = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("Earnings", earnings) }; CustomDataRecord record = new CustomDataRecord(kvp); Employee model = _mapper.MapRecord <Employee>(record); Assert.IsTrue(model.Salary == earnings); }
public void MapPropertyColumnNameHasUnderscores() { DataMapper mapper = new DataMapper(true); decimal salary = _faker.Random.Decimal(); List <KeyValuePair <string, object> > kvp = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("S_a_l_a_r_y", salary) }; CustomDataRecord record = new CustomDataRecord(kvp); Employee model = mapper.MapRecord <Employee>(record); Assert.IsTrue(model.Salary == salary); }