Пример #1
0
        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);
        }
Пример #2
0
 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);
        }
Пример #4
0
 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);
         }
     }
 }
Пример #5
0
 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);
             }
         }
     }
 }
Пример #6
0
        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);
        }
Пример #7
0
        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));
        }
Пример #8
0
        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));
            }
        }
Пример #9
0
        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));
        }
Пример #10
0
 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);
             }
         }
     }
 }
Пример #11
0
        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);
                    }
                }
            }
        }
Пример #12
0
 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);
             }
         }
     }
 }
Пример #13
0
 public List<Application> SearchApplicationByName(string name)
 {
     return ApplicationDAL.GetApplicationByName(name);
 }
Пример #14
0
        void GetApplicationByName_Test_True(string nameApp)
        {
            List <Application> result = ApplicationDAL.GetApplicationByName(nameApp);

            Assert.True(result.Count > 0);
        }
Пример #15
0
 public List <Application> GetApplicationBoughtByUserID(int UserID)
 {
     return(ApplicationDAL.GetApplicationBoughtByUserID(UserID));
 }
Пример #16
0
 public ApplicationDalTest() : base()
 {
     testApplicationContext = _appContext;
     subject = new ApplicationDAL(testApplicationContext, mockAppLogger.Object);
 }
Пример #17
0
 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));
 }