public void AddApplicationTest() { ApplicationDAL applicationDAL = new ApplicationDAL(connectionString); int preInsertCount = applicationDAL.GetAllApplications().Count; Application testApplication = new Application() { UnitID = 1, FirstName = "Test", LastName = "Johnson", PhoneNumber = "555-555-5555", EmailAddress = "*****@*****.**", LastResidenceOwner = "Test Management Services", LastResidenceContactPhoneNumber = "666-666-6666", LastResidenceTenancyStartDate = "January 1, 0000", LastResidenceTenancyEndDate = "December 31, 9999", EmploymentStatus = false, EmployerName = "Test Recruiting Company", EmployerContactPhoneNumber = "777-777-7777", AnnualIncome = "99,999", NumberOfResidents = 9, NumberOfCats = 9, NumberOfDogs = 9 }; bool checkAddApplicationSuccess = applicationDAL.AddApplication(testApplication); int postInsertCount = applicationDAL.GetAllApplications().Count; Assert.AreEqual(true, checkAddApplicationSuccess); Assert.AreEqual(preInsertCount + 1, postInsertCount); }
public Response <Application> Post(Application application) { try { Application app = ApplicationDAL.Create(application); return(new Response <Application>(app)); } catch (Exception ex) { return(new Response <Application>(ex.Message)); } }
void GetApplication_TestFDM() { List <Application> listApp = ApplicationDAL.GetApplicationByName(); Assert.NotNull(listApp); string query = "select * from application order by app_id limit 1;"; Assert.Equal(GetApplication_Test(query).GetHashCode(), listApp[0].GetHashCode()); query = "select * from application order by app_id desc limit 1;"; Assert.Equal(GetApplication_Test(query).GetHashCode(), listApp[listApp.Count - 1].GetHashCode()); query = "select * from application order by rand() limit 1;"; Assert.Contains(GetApplication_Test(query), listApp); }
public IApplication Get(string id) { try { using (var cmd = new DBCommand()) { return(ApplicationDAL.Get(cmd, id)); } } catch (Exception ex) { using (var builder = new MessageBuilder()) { string err = builder.AppendLine("读取申请单错误!").AppendLine(ex).Message; throw new Exception(err); } } }
public IList <IApplication> GetAllPaged(IDictionary <IAttributeDefinition, object> criterias, ref int pageNum, ref int pageCount, int pageSize, ref int itemCount) { using (var cmd = new DBCommand()) { try { return(ApplicationDAL.GetAllPaged(cmd, criterias, ref pageNum, pageSize, ref pageCount, ref itemCount)); } catch (Exception ex) { using (var builder = new MessageBuilder()) { string err = builder.AppendLine("读取申请单列表错误!").AppendLine(ex).Message; throw new Exception(err); } } } }
public void GetAllApplicationsTest() { ApplicationDAL applicationDAL = new ApplicationDAL(connectionString); List <Application> applications = applicationDAL.GetAllApplications(); Application testApplication = new Application(); foreach (Application application in applications) { if (application.ApplicationID == 999) { testApplication = application; } } Assert.IsNotNull(applications); CollectionAssert.Contains(applications, testApplication); }
public void TestCreateBillBL() { //Pass BillBL billBL = new BillBL(); Bill bill = new Bill() { App = ApplicationDAL.GetApplicationById(6), User = UserDAL.GetUserById(2), UnitPrice = ApplicationDAL.GetApplicationById(6).Price }; Assert.True(billBL.CreateBill(bill)); //fail //this app not exist! Bill bill2 = new Bill() { App = ApplicationDAL.GetApplicationById(10000), User = UserDAL.GetUserById(2), UnitPrice = ApplicationDAL.GetApplicationById(1).Price }; Assert.False(billBL.CreateBill(bill2)); //this user not exists! bill = new Bill() { App = ApplicationDAL.GetApplicationById(8), User = UserDAL.GetUserById(200000), UnitPrice = ApplicationDAL.GetApplicationById(8).Price }; Assert.False(billBL.CreateBill(bill)); //this user has bought this app! bill = new Bill() { App = ApplicationDAL.GetApplicationById(1), User = UserDAL.GetUserById(1), UnitPrice = ApplicationDAL.GetApplicationById(1).Price }; Assert.False(billBL.CreateBill(bill)); }
public Response <Application> Get(string id) { try { Application app = ApplicationDAL.GetApplication(new Guid(id)); if (app == null) { return(new Response <Application>(string.Format("'{0}' is not a valid Appliation ID", id))); } else { return(new Response <Application>(app)); } } catch (Exception ex) { return(new Response <Application>(ex.Message)); } }
public void CreateBill_Test() { //Pass Bill bill = new Bill() { App = ApplicationDAL.GetApplicationById(3), User = UserDAL.GetUserById(2), Payment = PaymentDAL.GetPaymentById(2), UnitPrice = ApplicationDAL.GetApplicationById(3).Price }; Assert.True(CreateBill(bill)); //Fail //buy this app that has bougth bill = new Bill() { App = ApplicationDAL.GetApplicationById(1), User = UserDAL.GetUserById(1), UnitPrice = ApplicationDAL.GetApplicationById(1).Price * 0.5, }; Assert.False(CreateBill(bill)); //buy an app that haven't sold! bill = new Bill() { App = ApplicationDAL.GetApplicationById(1000), User = UserDAL.GetUserById(1), UnitPrice = ApplicationDAL.GetApplicationById(1).Price * 0.5, }; Assert.False(CreateBill(bill)); //buy an app by an user haven't resigter! bill = new Bill() { App = ApplicationDAL.GetApplicationById(7), User = UserDAL.GetUserById(100), UnitPrice = ApplicationDAL.GetApplicationById(1).Price * 0.5, }; Assert.False(CreateBill(bill)); }
public IApplication Delete(IApplication instance) { using (var cmd = new DBCommand()) { try { ApplicationDAL.Delete(cmd, instance); cmd.Commit(); return(instance); } catch (Exception ex) { cmd.RollBack(); using (var builder = new MessageBuilder()) { string err = builder.AppendLine("删除申请单错误!").AppendLine(ex).Message; throw new Exception(err); } } } }
public IApplication Update(IApplication instance, string id, string customerId, string region, DateTime?dateApplied, DateTime?dateTraved, string offNoteNo, DateTime?offNoteDate, string remark) { using (var cmd = new DBCommand()) { try { ApplicationDAL.Update(cmd, instance, id, customerId, region, dateApplied, dateTraved, offNoteNo, offNoteDate, remark); cmd.Commit(); return(instance); } catch (Exception ex) { cmd.RollBack(); using (var builder = new MessageBuilder()) { string err = builder.AppendLine("更新申请单错误!").AppendLine(ex).Message; throw new Exception(err); } } } }
public bool IsExisting(string appId) { using (var cmd = new DBCommand()) { try { var od = AppCore.AppSingleton.FindObjDef <ApplicationObjDef>(); return(ApplicationDAL.IsExisting(cmd, new Dictionary <IAttributeDefinition, object>() { { od.ID, appId } })); } catch (Exception ex) { using (var builder = new MessageBuilder()) { string err = builder.AppendLine("查找申请表错误!").AppendLine(ex).Message; throw new Exception(err); } } } }
public List<Application> SearchApplicationByName(string name) { return ApplicationDAL.GetApplicationByName(name); }
void GetApplicationByName_Test_True(string nameApp) { List <Application> result = ApplicationDAL.GetApplicationByName(nameApp); Assert.True(result.Count > 0); }
public List <Application> GetApplicationBoughtByUserID(int UserID) { return(ApplicationDAL.GetApplicationBoughtByUserID(UserID)); }
public ApplicationDalTest() : base() { testApplicationContext = _appContext; subject = new ApplicationDAL(testApplicationContext, mockAppLogger.Object); }
public override void SetDAL() { _dal = new ApplicationDAL(); }
/// <summary> /// Get the application info for an application ID /// </summary> /// <param name="applicationID">ID associated with the application in question</param> /// <returns>Application info for an application ID if exist, null otherwise</returns> public Application GetApplicationInfo(Guid applicationID) { return(ApplicationDAL.GetApplication(applicationID)); }