예제 #1
0
        public void Test_CompanyAddressesAll()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadStateProvinceCodeTable(context);
                    HOSTestData.LoadCompanyAddresses(context);
                }

                using (var context = new HOSContext(options))
                {
                    IRepository repository = new Repository(context);
                    var         addresses  = repository.All <Address>();
                    Assert.NotNull(addresses);
                    Assert.Equal(6, addresses.Count());
                }
            } finally {
                connection.Close();
            }
        }
예제 #2
0
        public void Test_CompanyFilter()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadCompanyTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    IRepository repository = new Repository(context);
                    var         companies  = repository.Filter <Company>(c => c.CompanyName.Contains("Swift"));

                    Assert.NotNull(companies);
                    Assert.Equal(2, companies.ToList().Count());
                }
            } finally {
                connection.Close();
            }
        }
예제 #3
0
        public void Test_CompanyMgr_GetAll()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadCompanyTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    ICompanyManager companyMgr = new CompanyManager(new Repository(context));
                    var             companies  = companyMgr.GetAll().ToList();
                    Assert.NotNull(companies);
                    Assert.Equal(7, companies.Count());
                }
            } finally {
                connection.Close();
            }
        }
예제 #4
0
        public void Test_DailyLogMgr_CreateDailyLog()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadStateProvinceCodeTable(context);
                    HOSTestData.LoadDutyStatusTable(context);
                    HOSTestData.LoadDutyStatusActivityTable(context);
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadAppUserTable(context);
                    HOSTestData.LoadDailyLogTable(context);
                    HOSTestData.LoadDailyLogDetailTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    IDailyLogManager logMgr = new DailyLogManager(new Repository(context));

                    var dailyLogModel = new DailyLogModel
                    {
                        LogID            = 4,
                        LogDate          = new DateTime(2016, 9, 10),
                        BeginningMileage = 963000,
                        TruckNumber      = "3082",
                        TrailerNumber    = "9225",
                        IsSigned         = false,
                        Notes            = "Dropped trailer  9225 at Whirlpool and picked up loaded trailer 9159",
                        DriverID         = 4,
                        CreatedBy        = "sysadmin",
                        CreatedOn        = new DateTime(2016, 9, 10, 8, 0, 0),
                        UpdatedBy        = "sysadmin",
                        UpdatedOn        = new DateTime(2016, 9, 10, 8, 0, 0),
                    };

                    logMgr.Create(dailyLogModel);
                    logMgr.SaveChanges();

                    var test = logMgr.GetDailyLog(log => log.LogID == dailyLogModel.LogID);
                    Assert.NotNull(test);
                    Assert.Equal(new DateTime(2016, 9, 10), test.LogDate.Date);
                }
            } finally {
                connection.Close();
            }
        }
예제 #5
0
        public void Test_DailyLogUpdate()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadAppUserTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    IRepository repository = new Repository(context);

                    var dailyLog = new DailyLog
                    {
                        LogID            = 1,
                        LogDate          = new DateTime(2016, 9, 7),
                        BeginningMileage = 899201,
                        EndingMileage    = 899423,
                        TruckNumber      = "3082",
                        TrailerNumber    = "9225",
                        IsSigned         = true,
                        Notes            = "Dropped trailer  9225 at Whirlpool and picked up loaded trailer 9159",
                        DriverID         = 4
                    };

                    repository.Create <DailyLog>(dailyLog);
                    repository.Save();

                    var test = repository.Find <DailyLog>(log => log.LogID == dailyLog.LogID);

                    Assert.NotNull(test);
                    Assert.Equal(new DateTime(2016, 9, 7), dailyLog.LogDate);

                    test.LogDate = new DateTime(2016, 9, 9);
                    repository.Update <DailyLog>(test);
                    repository.Save();

                    test = repository.Find <DailyLog>(log => log.LogID == dailyLog.LogID);
                    Assert.Equal(new DateTime(2016, 9, 9), test.LogDate);
                }
            } finally {
                connection.Close();
            }
        }
        public void Test_CompanyAddressMgr_Create()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .EnableSensitiveDataLogging()
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadStateProvinceCodeTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    ICompanyAddressManager addressMgr = new CompanyAddressManager(new Repository(context));

                    var companyAddress = new CompanyAddress
                    {
                        AddressLine1    = "5333 Davidson Highway",
                        AddressLine2    = "",
                        City            = "Concord",
                        StateProvinceId = 28,
                        Zipcode         = "28027",
                        CountryCode     = "USA",
                        IsHQ            = true,
                        CreatedBy       = "admin",
                        CreatedOn       = DateTime.Now,
                        UpdatedBy       = "admin",
                        UpdatedOn       = DateTime.Now,
                        CompanyId       = 6
                    };

                    addressMgr.Create(companyAddress);
                    addressMgr.SaveChanges();

                    var test = addressMgr.GetCompanyAddress(a => a.CompanyId == 6 && a.AddressLine1 == "5333 Davidson Highway");
                    Assert.Equal(companyAddress.CreatedOn, test.CreatedOn);
                }
            } finally {
                connection.Close();
            }
        }
예제 #7
0
        public void Test_CompanyAddressUpdate()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadStateProvinceCodeTable(context);
                    HOSTestData.LoadCompanyAddresses(context);
                }

                using (var context = new HOSContext(options))
                {
                    IRepository repository = new Repository(context);
                    var         company    = repository.Find <Company>(c => c.CompanyCode == "FCT001");
                    Assert.NotNull(company);

                    var address = repository.Find <Address>(a =>
                                                            a.CompanyId == company.ID && a.AddressLine1 == "1346 Markum Ranch Rd");

                    Assert.NotNull(address);

                    address.AddressLine1 = "1346 Markum Ranch Road";
                    address.AddressLine2 = "Bldg One";
                    address.UpdatedBy    = "sysadmin";
                    address.UpdatedOn    = DateTime.Now;

                    repository.Update <Address>(address);
                    repository.Save();

                    var test = repository.Find <Address>(a => a.ID == address.ID);
                    Assert.NotNull(test);
                    Assert.Equal(address.AddressLine1, test.AddressLine1);
                    Assert.Equal(address.AddressLine2, test.AddressLine2);
                    Assert.Equal(address.UpdatedOn, test.UpdatedOn);
                }
            } finally {
                connection.Close();
            }
        }
예제 #8
0
        public void Test_CompanyAddressCreate()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadStateProvinceCodeTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    IRepository repository = new Repository(context);
                    var         company    = repository.Find <Company>(c => c.CompanyCode == "FCT001");

                    Assert.NotNull(company);

                    company.Addresses.Add(
                        new Address()
                    {
                        AddressLine1    = "1346 Markum Ranch Rd",
                        AddressLine2    = "Ste 100",
                        City            = "Fort Worth",
                        StateProvinceId = 45,
                        Zipcode         = "76126",
                        IsHQ            = true,
                        CompanyId       = company.ID,
                        CreatedBy       = "sysadmin"
                    }
                        );

                    repository.Save();

                    Assert.Equal(1, company.Addresses.Count);
                }
            } finally {
                connection.Close();
            }
        }
예제 #9
0
        public void Test_DailyLogMgr_UpdateDailyLog()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .EnableSensitiveDataLogging()
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadStateProvinceCodeTable(context);
                    HOSTestData.LoadDutyStatusTable(context);
                    HOSTestData.LoadDutyStatusActivityTable(context);
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadAppUserTable(context);
                    HOSTestData.LoadDailyLogTable(context);
                    HOSTestData.LoadDailyLogDetailTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    IDailyLogManager logMgr = new DailyLogManager(new Repository(context));

                    var dailyLogModel    = logMgr.GetDailyLog(log => log.LogID == 1);
                    var currentTimestamp = DateTime.Now;
                    dailyLogModel.UpdatedOn = currentTimestamp;

                    logMgr.Update(dailyLogModel);
                    logMgr.SaveChanges();

                    dailyLogModel = logMgr.GetDailyLog(log => log.LogID == 1);
                    Assert.Equal(currentTimestamp, dailyLogModel.UpdatedOn);
                }
            } finally {
                connection.Close();
            }
        }
예제 #10
0
        public void Test_CompanyAddressMgr_Update()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .EnableSensitiveDataLogging()
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadStateProvinceCodeTable(context);
                    HOSTestData.LoadCompanyAddresses(context);
                }

                using (var context = new HOSContext(options))
                {
                    // context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
                    ICompanyAddressManager companyAddressMgr = new CompanyAddressManager(new Repository(context));

                    var companyAddress = companyAddressMgr.GetCompanyAddress(5, 4);
                    Assert.NotNull(companyAddress);

                    DateTime currentTimeStamp = DateTime.Now;
                    companyAddress.UpdatedOn = currentTimeStamp;
                    companyAddressMgr.Update(companyAddress);
                    companyAddressMgr.SaveChanges();

                    companyAddress = companyAddressMgr.GetCompanyAddress(a => a.CompanyId == 5 && a.ID == 4);
                    Assert.NotNull(companyAddress);
                    Assert.Equal(currentTimeStamp, companyAddress.UpdatedOn);
                }
            } finally {
                connection.Close();
            }
        }
예제 #11
0
        public void Test_DailyLogMgr_SelectAllDetailsForOneDay()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .EnableSensitiveDataLogging()
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadStateProvinceCodeTable(context);
                    HOSTestData.LoadDutyStatusTable(context);
                    HOSTestData.LoadDutyStatusActivityTable(context);
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadAppUserTable(context);
                    HOSTestData.LoadDailyLogTable(context);
                    HOSTestData.LoadDailyLogDetailTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    IDailyLogManager logMgr = new DailyLogManager(new Repository(context));

                    var dailyLogModel = logMgr.GetDailyLog(log => log.LogDate == new DateTime(2016, 9, 7));
                    Assert.NotNull(dailyLogModel);

                    var dailyLogDetailModel = logMgr.GetDailyLogDetails(details => details.LogID == dailyLogModel.LogID);
                    Assert.NotNull(dailyLogDetailModel);
                    Assert.Equal(8, dailyLogDetailModel.ToList().Count());
                }
            } finally {
                connection.Close();
            }
        }
예제 #12
0
        public void Test_DailyLogMgr_SelectDailyLog()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .EnableSensitiveDataLogging()
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadStateProvinceCodeTable(context);
                    HOSTestData.LoadDutyStatusTable(context);
                    HOSTestData.LoadDutyStatusActivityTable(context);
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadAppUserTable(context);
                    HOSTestData.LoadDailyLogTable(context);
                    HOSTestData.LoadDailyLogDetailTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    IDailyLogManager logMgr = new DailyLogManager(new Repository(context));

                    var allLogs       = logMgr.GetAll().ToList();
                    var allLogsForDrv = logMgr.GetDailyLogs(log => log.DriverID == 4);

                    Assert.Equal(3, allLogs.Count());
                    Assert.Equal(3, allLogsForDrv.Count());
                }
            } finally {
                connection.Close();
            }
        }
예제 #13
0
        public void Test_CompanyAddressMgr_Delete()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .EnableSensitiveDataLogging()
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadStateProvinceCodeTable(context);
                    HOSTestData.LoadCompanyAddresses(context);
                }

                using (var context = new HOSContext(options))
                {
                    ICompanyAddressManager addressMgr = new CompanyAddressManager(new Repository(context));

                    var address = addressMgr.GetCompanyAddress(a => a.CompanyId == 5 && a.AddressLine1 == "2150 Cabot Boulevard West");
                    Assert.NotNull(address);

                    addressMgr.Delete(address);
                    addressMgr.SaveChanges();

                    address = addressMgr.GetCompanyAddress(a => a.CompanyId == 5 && a.AddressLine1 == "2150 Cabot Boulevard West");
                    Assert.Null(address);
                }
            } finally {
                connection.Close();
            }
        }
예제 #14
0
        public void Test_DailyLogDetailAllForUser()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadDutyStatusActivityTable(context);
                    HOSTestData.LoadDutyStatusTable(context);
                    HOSTestData.LoadStateProvinceCodeTable(context);
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadAppUserTable(context);
                    HOSTestData.LoadDailyLogTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    IRepository repository = new Repository(context);

                    var user = repository.Find <AppUser>(u => u.UserName == "leadfoot");
                    Assert.NotNull(user);

                    var dailyLogs = repository.Filter <DailyLog>(dl => dl.DriverID == user.Id);
                    Assert.Equal(3, dailyLogs.ToList().Count());
                }
            } finally {
                connection.Close();
            }
        }
예제 #15
0
        public void Test_DailyLogFilter()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadAppUserTable(context);
                    HOSTestData.LoadDailyLogTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    IRepository repository = new Repository(context);

                    var lowDate  = new DateTime(2016, 9, 1);
                    var highDate = new DateTime(2016, 9, 30);

                    var dailyLogs = repository.Filter <DailyLog>(log => log.LogDate > lowDate && log.LogDate < highDate);

                    Assert.NotNull(dailyLogs);
                    Assert.Equal(3, dailyLogs.ToList().Count());
                }
            } finally {
                connection.Close();
            }
        }
예제 #16
0
        public void Test_CompanyAddressMgr_SelectAll()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .EnableSensitiveDataLogging()
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadStateProvinceCodeTable(context);
                    HOSTestData.LoadCompanyAddresses(context);
                }

                using (var context = new HOSContext(options))
                {
                    ICompanyAddressManager addressMgr = new CompanyAddressManager(new Repository(context));

                    var addresses = addressMgr.GetCompanyAddresses(2).ToList();
                    Assert.NotNull(addresses);
                    Assert.Equal(2, addresses.Count());
                }
            } finally {
                connection.Close();
            }
        }
예제 #17
0
        public void Test_CompanyContains()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadCompanyTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    IRepository repository = new Repository(context);
                    var         result     = repository.Contains <Company>(c => c.CompanyCode == "ADMIN001");

                    Assert.True(result);

                    result = repository.Contains <Company>(c => c.CompanyCode == "123456");

                    Assert.False(result);
                }
            } finally {
                connection.Close();
            }
        }
예제 #18
0
        public void Test_DailyLogMgr_CreateDailyLogDetail()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .EnableSensitiveDataLogging()
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadStateProvinceCodeTable(context);
                    HOSTestData.LoadDutyStatusTable(context);
                    HOSTestData.LoadDutyStatusActivityTable(context);
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadAppUserTable(context);
                    HOSTestData.LoadDailyLogTable(context);
                    HOSTestData.LoadDailyLogDetailTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    IDailyLogManager logMgr = new DailyLogManager(new Repository(context));
                    var dailyLog            = logMgr.GetDailyLog(log => log.LogID == 3);

                    // Retrieve the last pre-trip entry for this driver
                    var mostRecentPreTrip = logMgr.GetLastPreTripInspection(drv => drv.DriverID == dailyLog.DriverID);

                    // Determine hours available on 14
                    // Determine hours available on 11
                    // Determine if in violation of 30 min break rule
                    // Determine current duty status
                    // Determine duty status driver is attempting to move to

                    var dailyLogDetailModel = new DailyLogDetailModel
                    {
                        LogDetailID          = 23,
                        LogID                = dailyLog.LogID,
                        DutyStatusID         = 4,
                        StartTime            = new DateTime(2016, 9, 9, 8, 0, 0),
                        LocationCity         = "Fort Worth",
                        StateProvinceId      = 45,
                        DutyStatusActivityID = 1
                    };

                    logMgr.CreateLogDetail(dailyLogDetailModel);
                    logMgr.SaveChanges();

                    dailyLogDetailModel = logMgr.GetDailyLogDetail(details => details.LogID == dailyLog.LogID);
                    Assert.NotNull(dailyLogDetailModel);
                }
            } finally {
                connection.Close();
            }
        }
예제 #19
0
        public void Test_DailyLogDetailDelete()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    HOSTestData.LoadDutyStatusActivityTable(context);
                    HOSTestData.LoadDutyStatusTable(context);
                    HOSTestData.LoadStateProvinceCodeTable(context);
                    HOSTestData.LoadCompanyTable(context);
                    HOSTestData.LoadAppUserTable(context);
                }

                using (var context = new HOSContext(options))
                {
                    IRepository repository = new Repository(context);

                    var dailyLog = new DailyLog
                    {
                        LogID            = 1,
                        LogDate          = new DateTime(2016, 9, 7),
                        BeginningMileage = 899201,
                        EndingMileage    = 899423,
                        TruckNumber      = "3082",
                        TrailerNumber    = "9225",
                        IsSigned         = true,
                        Notes            = "Dropped trailer  9225 at Whirlpool and picked up loaded trailer 9159",
                        DriverID         = 4
                    };

                    var logDetail = new DailyLogDetail
                    {
                        LogDetailID          = 1,
                        DutyStatusID         = 4,
                        StartTime            = new DateTime(2016, 9, 7, 12, 45, 0),
                        StopTime             = new DateTime(2016, 9, 7, 13, 0, 0),
                        LocationCity         = "Ft Worth",
                        StateProvinceId      = 45,
                        DutyStatusActivityID = 1,
                        LogID = 1
                    };

                    dailyLog.DailyLogDetails.Add(logDetail);
                    repository.Create <DailyLog>(dailyLog);
                    repository.Save();

                    var test          = repository.Find <DailyLog>(log => log.LogID == dailyLog.LogID);
                    var logDetailTest = test.DailyLogDetails.FirstOrDefault();

                    Assert.NotNull(logDetailTest);
                    test.DailyLogDetails.Remove(logDetailTest);
                    repository.Save();
                    logDetailTest = test.DailyLogDetails.FirstOrDefault();

                    Assert.Null(logDetailTest);
                }
            } finally {
                connection.Close();
            }
        }