Esempio n. 1
0
        public void MapRecordCreateInstanceNotNull()
        {
            CustomDataRecord record = new CustomDataRecord(new List <KeyValuePair <string, object> >());
            Employee         model  = _mapper.MapRecord <Employee>(record);

            Assert.IsNotNull(model);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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");
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
        }