コード例 #1
0
        public void TestJobToString()
        {
            using (var reader = EntityDataMock.mockJobReader())
            {
                string correctString = $"{reader["title"]}";

                Job job = new Job(reader);
                Assert.AreEqual(job.ToString(), correctString);
            }
        }
コード例 #2
0
ファイル: EmployeeTest.cs プロジェクト: mtyton/LogisticApp
        public void testCreationFromDataReader()
        {
            using (var reader = EntityDataMock.mockEmployeeReader())
            {
                string correctString = $"" +
                                       $"{reader["name"]} {reader["surname"]}";

                Employee employee = new Employee(reader);
                Assert.AreEqual(employee.ToString(), correctString);
            }
        }
コード例 #3
0
ファイル: EmployeeTest.cs プロジェクト: mtyton/LogisticApp
 public void testToUpdateSuccess()
 {
     using (var reader = EntityDataMock.mockEmployeeReader())
     {
         string correctString = $"name='{reader["name"]}', surname='{reader["surname"]}', " +
                                $"birth_date='{DateTime.Parse(reader["birth_date"].ToString()).ToString("yyyy/MM/dd")}', " +
                                $"date_of_employment='{DateTime.Parse(reader["date_of_employment"].ToString()).ToString("yyyy/MM/dd")}'," +
                                $"hourly_payment={reader["hourly_payment"]}";
         Employee employee = new Employee(reader);
         Assert.AreEqual(employee.ToUpdate(), correctString);
     }
 }
コード例 #4
0
        public void TestToString()
        {
            using (var reader = EntityDataMock.mockAddressReader())
            {
                string correctString = $"" +
                                       $"{reader["country"]}, {reader["city"]}, " +
                                       $"{reader["postal_code"]}, {reader["street"]} " +
                                       $"{reader["building_number"]}/{reader["apartment_number"]}";

                Address addr = new Address(reader);
                Assert.AreEqual(addr.ToString(), correctString);
            }
        }
コード例 #5
0
        public void TestToUpdateSuccess()
        {
            using (var reader = EntityDataMock.mockAddressReader())
            {
                Address addr          = new Address(reader);
                string  correctString = $"city='{reader["city"]}', " +
                                        $"postal_code='{reader["postal_code"]}', " +
                                        $"country='{reader["country"]}', street='{reader["street"]}', " +
                                        $"building_number={reader["building_number"]}, " +
                                        $"apartment_number={reader["apartment_number"]}";

                Assert.AreEqual(addr.ToUpdate(), correctString);
            }
        }
コード例 #6
0
        public void Serialization_IsConsistent()
        {
            // Arrange
            EntityDataMock data = new EntityDataMock()
            {
                Id        = "你好世界",
                Version   = Encoding.UTF8.GetBytes("version"),
                CreatedAt = DateTimeOffset.Parse("2013-10-07T21:55:45.8677285Z"),
                UpdatedAt = DateTimeOffset.Parse("2013-11-07T21:55:45.8677285Z"),
                Deleted   = true
            };

            // Act/Assert
            SerializationAssert.VerifySerialization(data, "{\"id\":\"你好世界\",\"version\":\"dmVyc2lvbg==\",\"createdAt\":\"2013-10-07T21:55:45.867Z\",\"updatedAt\":\"2013-11-07T21:55:45.867Z\",\"deleted\":true}");
        }
コード例 #7
0
        public void TestToInsertSuccess()
        {
            using (var reader = EntityDataMock.mockAddressReader())
            {
                Address addr          = new Address(reader);
                string  correctString = $"" +
                                        $"(city, postal_code, country, street, building_number, apartment_number)" +
                                        $" VALUES ('{reader["city"]}', '{reader["postal_code"]}'," +
                                        $" '{reader["country"]}', '{reader["street"]}', " +
                                        $"{reader["building_number"]}, {reader["apartment_number"]});";


                Assert.AreEqual(addr.ToInsert(), correctString);
            }
        }
コード例 #8
0
 public void TestToInsertCompanySuccess()
 {
     using (var reader = EntityDataMock.mockJobReader())
     {
         Job job = new Job(reader);
         job.clientCompany    = EntityObjectMock.createCompany();
         job.assignedEmployee = EntityObjectMock.createEmployee();
         string correctString = $"(title, company_id, description, " +
                                $"assigned_employee, predicted_time, predicted_cost) " +
                                $"VALUES ('{reader["title"]}', {job.clientCompany.id}," +
                                $" '{reader["description"]}', {job.assignedEmployee.id}," +
                                $" {reader["predicted_time"]}, {reader["predicted_cost"]});";
         Assert.AreEqual(job.ToInsert(), correctString);
     }
 }
コード例 #9
0
ファイル: EmployeeTest.cs プロジェクト: mtyton/LogisticApp
 public void testToInsertSuccess()
 {
     using (var reader = EntityDataMock.mockEmployeeReader())
     {
         string correctString = $"(name, surname, birth_date, " +
                                $"date_of_employment, hourly_payment)" +
                                $"VALUES('{reader["name"]}', " +
                                $"'{reader["surname"]}', " +
                                $"'{DateTime.Parse(reader["birth_date"].ToString()).ToString("yyyy/MM/dd")}', " +
                                $"'{DateTime.Parse(reader["date_of_employment"].ToString()).ToString("yyyy/MM/dd")}', " +
                                $"{reader["hourly_payment"]});";
         Employee employee = new Employee(reader);
         Assert.AreEqual(employee.ToInsert(), correctString);
     }
 }
コード例 #10
0
 public void TestToUpdateCompanySuccess()
 {
     using (var reader = EntityDataMock.mockJobReader())
     {
         Job job = new Job(reader);
         job.clientCompany    = EntityObjectMock.createCompany();
         job.assignedEmployee = EntityObjectMock.createEmployee();
         string correctString = $"title='{reader["title"]}', " +
                                $"description='{reader["description"]}', " +
                                $"company_id={job.clientCompany.id}, " +
                                $"assigned_employee={job.assignedEmployee.id}, " +
                                $"predicted_time={reader["predicted_time"]}, " +
                                $"predicted_cost={reader["predicted_cost"]}";
         Assert.AreEqual(job.ToUpdate(), correctString);
     }
 }
コード例 #11
0
ファイル: PersonTest.cs プロジェクト: mtyton/LogisticApp
        public void testToUpdateSuccess()
        {
            using (var personReader = EntityDataMock.mockPersonReader())
            {
                Address addr = new Address(null, null, null, null, 0, 0);
                addr.id = 67;
                Person person = new Person(personReader);
                person.address = addr;

                string correctString = $"name='{personReader["name"]}', " +
                                       $"surname='{personReader["surname"]}', " +
                                       $"address_id={addr.id}";

                Assert.AreEqual(person.ToUpdate(), correctString);
            }
        }
コード例 #12
0
ファイル: PersonTest.cs プロジェクト: mtyton/LogisticApp
        public void testToInsertSuccess()
        {
            using (var personReader = EntityDataMock.mockPersonReader())
            {
                Address addr = new Address(null, null, null, null, 0, 0);
                addr.id = 67;
                Person person = new Person(personReader);
                person.address = addr;

                string correctString = $"(id, name, surname, address_id) " +
                                       $"VALUES (NULL, '{personReader["name"]}', '{personReader["surname"]}', " +
                                       $"{addr.id});";

                Assert.AreEqual(person.ToInsert(), correctString);
            }
        }
コード例 #13
0
        public void TestToUpdateSuccess()
        {
            using (var companyReader = EntityDataMock.mockCompanyReader())
            {
                using (var addrReader = EntityDataMock.mockAddressReader())
                {
                    Address addr = new Address(addrReader);
                    addr.id = 5;
                    Company company = new Company(companyReader);
                    company.address = addr;
                    string correctString = $"name='{companyReader["name"]}', " +
                                           $"tax_number='{companyReader["tax_number"]}'," +
                                           $" address_id={addr.id}";

                    Assert.AreEqual(company.ToUpdate(), correctString);
                }
            }
        }
コード例 #14
0
        public void TestToInsertSuccess()
        {
            using (var companyReader = EntityDataMock.mockCompanyReader())
            {
                using (var addrReader = EntityDataMock.mockAddressReader())
                {
                    Address addr = new Address(addrReader);
                    addr.id = 5;
                    Company company = new Company(companyReader);
                    company.address = addr;
                    string correctString = $"(id, name, tax_number, address_id) " +
                                           $"VALUES (NULL, '{companyReader["name"]}', '{companyReader["tax_number"]}', " +
                                           $"{addr.id});";

                    Assert.AreEqual(company.ToInsert(), correctString);
                }
            }
        }
コード例 #15
0
ファイル: PersonTest.cs プロジェクト: mtyton/LogisticApp
        public void testToString()
        {
            using (var personReader = EntityDataMock.mockPersonReader())
            {
                using (var addrReader = EntityDataMock.mockAddressReader())
                {
                    string correctString = $"" +
                                           $"{personReader["name"]} {personReader["surname"]} - " +
                                           $"{addrReader["country"]}, {addrReader["city"]}, " +
                                           $"{addrReader["postal_code"]}, {addrReader["street"]} " +
                                           $"{addrReader["building_number"]}/{addrReader["apartment_number"]}";

                    Address addr   = new Address(addrReader);
                    Person  person = new Person(personReader);
                    person.address = addr;
                    Assert.AreEqual(person.ToString(), correctString);
                }
            }
        }
コード例 #16
0
        public void TestToString()
        {
            using (var companyReader = EntityDataMock.mockCompanyReader())
            {
                using (var addrReader = EntityDataMock.mockAddressReader())
                {
                    string correctString = $"" +
                                           $"{companyReader["name"]} - " +
                                           $"{addrReader["country"]}, {addrReader["city"]}, " +
                                           $"{addrReader["postal_code"]}, {addrReader["street"]} " +
                                           $"{addrReader["building_number"]}/{addrReader["apartment_number"]}";

                    Address addr    = new Address(addrReader);
                    Company company = new Company(companyReader);
                    company.address = addr;
                    Assert.AreEqual(company.ToString(), correctString);
                }
            }
        }
コード例 #17
0
        public void TestToInsertFailure()
        {
            using (var reader = EntityDataMock.mockJobReader())
            {
                string correctString = $"{reader["title"]}";

                Job job = new Job(reader);
                try
                {
                    job.ToInsert();
                }
                catch (Exception error)
                {
                    Assert.AreEqual(true, true);
                    return;
                }
                Assert.AreEqual(false, true);
            }
        }