Пример #1
0
        public void AddNewAccountTest()
        {
            Account newAccount = new Account(21, 300, new DateTime(2013, 04, 01),
                                             new List <Donation>()
            {
                new Donation(201, "reason:101", 12.5, DateTime.Today, ""),
                new Donation(202, "reason:102", 12.5, DateTime.Today, ""),
                new Donation(203, "reason:103", 12.5, DateTime.Today, ""),
                new Donation(204, "reason:104", 12.5, DateTime.Today, ""),
                new Donation(205, "reason:105", 12.5, DateTime.Today, ""),
                new PaidDonation(206, "reason:106", 12.5, DateTime.Today, "", DateTime.Today),
                new PaidDonation(207, "reason:107", 12.5, DateTime.Today, "", DateTime.Today),
                new PaidDonation(208, "reason:108", 12.5, DateTime.Today, "", DateTime.Today),
                new PaidDonation(209, "reason:109", 12.5, DateTime.Today, "", DateTime.Today),
                new PaidDonation(210, "reason:110", 12.5, DateTime.Today, "", DateTime.Today)
            });
            int personId = 1;

            Enums.CRUDResults expected = Enums.CRUDResults.CREATE_SUCCESS;
            Enums.CRUDResults actual;
            actual = AccountAccess.AddNewAccount(newAccount, personId);
            Assert.AreEqual(expected, actual);
            Account addedAccount = AccountAccess.GetAccountById(21);

            Assert.AreEqual(newAccount, addedAccount);
        }
Пример #2
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        int    AccountTypeID = Int32.Parse(drpAccountType.SelectedValue);
        string CompanyName   = txtCompanyName.Text;
        string URL1          = txtURL1.Text;
        string URL2          = txtURL2.Text;
        bool   CreditHold    = true; // change to value from dropdown
        bool   Active        = true;

        int    AddressTypeID = Int32.Parse(drpAddressType.SelectedValue);
        string Address1      = txtAddress1.Text;
        string Address2      = txtAddress2.Text;
        string City          = txtCity.Text;
        string State         = txtPostCode.Text;
        string PostCode      = txtPostCode.Text;

        int    ContactTypeID = Int32.Parse(drpContactType.SelectedValue);
        string Phone         = txtPhone.Text;
        string Fax           = txtFax.Text;
        string Email         = txtEmail.Text;
        string ContactName   = txtContactName.Text;

        bool flag = false;

        flag = AccountAccess.Account_Create(AccountTypeID, CompanyName, URL1, URL2, CreditHold, Active,
                                            AddressTypeID, Address1, Address2, City, State, PostCode,
                                            ContactTypeID, Phone, Fax, Email, ContactName);


        lblStatus.Text = flag ? "COMPANY CREATED" : "ERROR ! FAILED TO CREATE COMPANY";
    }
Пример #3
0
        private ConsentRequest GetConsentDetailsForUserSelected(ConsentDetails consentDetails)
        {
            AccountAccess accountAccess;

            if (consentDetails.ConsentPurpose == ConsentDetails.PurposeEnum.AccountDetails)
            {
                accountAccess = new AccountAccess(
                    AvailableAccountsEnum.All
                    , consentDetails.GetAccountReferencesFor(ConsentDetails.PurposeEnum.AccountDetails)
                    .Select(@ref => new AccountReference(@ref.IBAN)
                {
                    BBAN = @ref.BBAN, MSISDN = @ref.MSISDN
                })
                    );
            }
            else
            {
                accountAccess = new AccountAccess(
                    AllPSD2Enum.All
                    , consentDetails.GetAccountReferencesFor(ConsentDetails.PurposeEnum.AccountBalances)
                    .Select(@ref => new AccountReference(@ref.IBAN)
                {
                    BBAN = @ref.BBAN, MSISDN = @ref.MSISDN
                })
                    , consentDetails.GetAccountReferencesFor(ConsentDetails.PurposeEnum.AccountTransactions)
                    .Select(@ref => new AccountReference(@ref.IBAN)
                {
                    BBAN = @ref.BBAN, MSISDN = @ref.MSISDN
                })
                    );
            }

            return(new ConsentRequest(accountAccess, consentDetails.Recurring, consentDetails.ValidUntil?.ToUniversalTime(), consentDetails.AccessFrequency ?? 1, consentDetails.Combined ?? false));
        }
Пример #4
0
        public AccountAccess SetAccountAccess_Checked(Account slave, Account master, AccountAccessRoles role)
        {
            var currentAccess = UserContext.Data.AccountAccesses.Find(slave.Login, master.Login);

            if (role == AccountAccessRoles.None && currentAccess == null)
            {
                return(null);
            }

            if (role == AccountAccessRoles.None)
            {
                UserContext.Data.AccountAccesses.Remove(currentAccess);
                currentAccess = null;
            }
            else if (currentAccess == null)
            {
                currentAccess = new AccountAccess(slave, master, role);
                UserContext.Data.AccountAccesses.Add(currentAccess);
            }
            else
            {
                currentAccess.Role = role;
            }

            UserContext.Data.SaveChanges();
            SetAccessChangeGameEvents(slave, master, role);
            return(currentAccess);
        }
Пример #5
0
        public void RegisterUser_ShortUsername_False()
        {
            var options = new DbContextOptionsBuilder <Mystivate_dbContext>()
                          .UseInMemoryDatabase(databaseName: "RegisterUser_ShortUsername_False")
                          .Options;

            using (var context = new Mystivate_dbContext(options))
            {
                IAccountAccess accountAccess = new AccountAccess(context);

                IRegisterService registerService = new SignInService(null, accountAccess);

                string username = "******";
                string email    = "*****@*****.**";
                string password = "******";

                RegisterResult result = registerService.RegisterUser(new RegisterModel
                {
                    Email    = email,
                    Username = username,
                    Password = password
                });

                Assert.AreEqual(RegisterResult.UsernameShort, result);
            }
        }
Пример #6
0
        public void OnGet()
        {
            int           userID        = Convert.ToInt32(HttpContext.User.Claims.Where(claim => claim.Type == "ID").Select(c => c.Value).FirstOrDefault());
            AccountAccess accountAccess = new AccountAccess(new DBAccess());
            int           id            = accountAccess.GetUserId(userID, "teacher");
            TeacherAccess teacherAccess = new TeacherAccess(new DBAccess());
            Teacher       teacher       = teacherAccess.GetTeacherByID(id);

            teacherController = new TeacherController(teacher);
            subjects          = teacherController.GetSubjects();
            if (selectedSubject == 0)
            {
                groups = teacherController.GetGroups(subjects[0].id);
                exams  = teacherController.GetExams(subjects[0].id);
            }
            else
            {
                groups = teacherController.GetGroups(selectedSubject);
                exams  = teacherController.GetExams(selectedSubject);
            }
            if (groups.Count > 0)
            {
                foreach (Group group in groups)
                {
                    allGroups = allGroups + group.title + ", ";
                }
                allGroups = allGroups.Remove(allGroups.Length - 2);
            }
        }
Пример #7
0
 public ConsentRequest(AccountAccess access, bool recurring = false, DateTime?validUntil = null, int accessFrequencyPerDay = 1, bool combinedService = false)
 {
     this.Access                = access;
     this.Recurring             = recurring;
     this.ValidUntil            = validUntil ?? DateTime.Now.AddMinutes(30);
     this.AccessFrequencyPerDay = accessFrequencyPerDay;
     this.CombinedService       = combinedService;
 }
Пример #8
0
 public static AccountAccessModel MapAccountAccess(AccountAccess accountAccess)
 {
     return new AccountAccessModel()
     {
         AccessId = accountAccess.AccessID,
         AccountId = accountAccess.AccountID,
         Id = accountAccess.ID
     };
 }
Пример #9
0
        public void GetByPersonIdTest()
        {
            int     personId = 1;
            Account expected = new Account(1, 0, DateTime.Today, DonationAccess.GetAllDonations(1));
            Account actual;

            actual = AccountAccess.GetByPersonId(personId);
            Assert.AreEqual(expected, actual);
        }
Пример #10
0
        public void GetByNonexsitentDonationTest()
        {
            Donation donationToLookBy = new Donation(50, "reason:50", 25, DateTime.MaxValue, "");
            Account  expected         = null;
            Account  actual;

            actual = AccountAccess.GetByDonation(donationToLookBy);
            Assert.AreEqual(expected, actual);
        }
Пример #11
0
 public static AccountAccessModel MapAccountAccess(AccountAccess accountAccess)
 {
     return(new AccountAccessModel()
     {
         AccessId = accountAccess.AccessID,
         AccountId = accountAccess.AccountID,
         Id = accountAccess.ID
     });
 }
Пример #12
0
        public void GetAllAccountsTest()
        {
            List <Account> expected = AccountAccess_Accessor.ConvertMultipleDbAccountsToLocalType(
                AccountAccess_Accessor.LookupAllAccounts());
            List <Account> actual;

            actual = AccountAccess.GetAllAccounts();
            CollectionAssert.AreEqual(expected, actual);
        }
Пример #13
0
        public void GetByNonExsistentPersonIdTest()
        {
            int     personId = 0;
            Account expected = null;
            Account actual;

            actual = AccountAccess.GetByPersonId(personId);
            Assert.AreEqual(expected, actual);
        }
Пример #14
0
        public ResetUsernameUI(Business_Logic.Admin adminUser, AccountAccess acctReader)
        {
            InitializeComponent();

            //set data members
            this.adminUser  = adminUser;
            this.acctReader = acctReader;
            usernameChanged = false;
        }
Пример #15
0
        public void GetByNonExsistentDonationIdTest()
        {
            int     donationId = 0;
            Account expected   = null;
            Account actual;

            actual = AccountAccess.GetByDonation(donationId);
            Assert.AreEqual(expected, actual);
        }
Пример #16
0
        public void GetByAccountIdTest()
        {
            int     accountId = 10;
            Account expected  = new Account(10, 0, DateTime.Today, new List <Donation>());
            Account actual;

            actual = AccountAccess.GetAccountById(accountId);
            Assert.AreEqual(expected, actual);
        }
Пример #17
0
        public void DeleteSingleNonexstintAccountTest()
        {
            Account deletedAccount = new Account(50, 250, DateTime.Today, new List <Donation>());
            int     personId       = 1;

            Enums.CRUDResults expected = Enums.CRUDResults.DELETE_FAIL;
            Enums.CRUDResults actual;
            actual = AccountAccess.DeleteSingleAccount(deletedAccount, personId);
            Assert.AreEqual(expected, actual);
        }
Пример #18
0
        public void UpdateSingleNonExsistentAccountTest()
        {
            Account updatedAccount = new Account(50, 43, DateTime.Today, new List <Donation>());
            int     personId       = 1;

            Enums.CRUDResults expected = Enums.CRUDResults.UPDATE_FAIL;
            Enums.CRUDResults actual;
            actual = AccountAccess.UpdateSingleAccount(updatedAccount, personId);
            Assert.AreEqual(expected, actual);
        }
Пример #19
0
        public AdminUI_ModifyUser(int userId, AccountAccess acctReader)
        {
            InitializeComponent();

            //set data members
            this.userId          = userId;
            this.acctReader      = acctReader;
            thisUser             = acctReader.GetUserAccount(userId);
            userHasBeenModified  = false;
            userModifiedAndSaved = false;
        }
Пример #20
0
        public void DeleteSingleAccountTest()
        {
            Account deletedAccount = new Account(2, 0, DateTime.Today, new List <Donation>());
            int     personId       = 1;

            Enums.CRUDResults expected = Enums.CRUDResults.DELETE_SUCCESS;
            Enums.CRUDResults actual;
            actual = AccountAccess.DeleteSingleAccount(deletedAccount, personId);
            Assert.AreEqual(expected, actual);
            List <Account> allCurrentAccounts = AccountAccess.GetAllAccounts();

            Assert.IsFalse(allCurrentAccounts.Contains(deletedAccount));
        }
Пример #21
0
        public AdminUI_AddUser(AdminUI ui_admin, AccountAccess acctReader)
        {
            InitializeComponent();

            //set data members
            this.ui_admin   = ui_admin;
            this.acctReader = acctReader;
            this.newAdmin   = null;
            this.newUser    = null;

            //UI setup
            lbl_Info.ResetText();
        }
Пример #22
0
 public Admin(string FirstName, string LastName, string ID) : base(FirstName, LastName)
 {
     adminID = ID;
     IoC.RegisterObject <IDBAccess, DBAccess>();
     IoC.RegisterObject <ISubject, Subject>();
     IoC.RegisterObject <IGroup, Group>();
     dbAccess      = new DBAccess();
     teacherAccess = new TeacherAccess(dbAccess);
     groupAccess   = new GroupAccess(dbAccess);
     subjectAccess = new SubjectAccess(dbAccess);
     accountAccess = new AccountAccess(dbAccess);
     studentAccess = new StudentAccess(dbAccess);
 }
Пример #23
0
        public void UpsertUpdateSingleAccountTest()
        {
            Account upsertedAccount = new Account(7, 613, DateTime.MinValue, new List <Donation>());
            int     personId        = 1;

            Enums.CRUDResults expected = Enums.CRUDResults.UPDATE_SUCCESS;
            Enums.CRUDResults actual;
            actual = AccountAccess.UpsertSingleAccount(upsertedAccount, personId);
            Assert.AreEqual(expected, actual);
            Account afterUpsert = AccountAccess.GetAccountById(7);

            Assert.AreEqual(upsertedAccount, afterUpsert);
        }
Пример #24
0
        public void UpsertAddSingleAccountTest()
        {
            Account upsertedAccount = new Account(613, 9857, DateTime.Today, new List <Donation>());
            int     personId        = 1;

            Enums.CRUDResults expected = Enums.CRUDResults.CREATE_SUCCESS;
            Enums.CRUDResults actual;
            actual = AccountAccess.UpsertSingleAccount(upsertedAccount, personId);
            Assert.AreEqual(expected, actual);
            Account afterUpsert = AccountAccess.GetAccountById(613);

            Assert.AreEqual(upsertedAccount, afterUpsert);
        }
Пример #25
0
        public void DeleteMultipleAccountsTest()
        {
            List <Account> deletedAccountList = new List <Account>()
            {
                new Account(4, 0, DateTime.Today, new List <Donation>()),
                new Account(5, 0, DateTime.Today, new List <Donation>())
            };
            int personId = 1;

            AccountAccess.DeleteMultipleAccounts(deletedAccountList, personId);
            List <Account> allCurrentAccounts = AccountAccess.GetAllAccounts();

            Assert.IsFalse(allCurrentAccounts.Contains(deletedAccountList[0]));
            Assert.IsFalse(allCurrentAccounts.Contains(deletedAccountList[1]));
        }
Пример #26
0
        public void AddTodo_NormalName_True()
        {
            var options = new DbContextOptionsBuilder <Mystivate_dbContext>()
                          .UseInMemoryDatabase(databaseName: "AddTodo_NormalName_True")
                          .Options;

            using (var context = new Mystivate_dbContext(options))
            {
                IAccountAccess accountAccess = new AccountAccess(context);
                string         email         = "*****@*****.**";
                UserTestsMethods.RegisterUser(accountAccess, "test", email, "test123");
                int taskId = AddTodo(new TaskAccess(context), UserTestsMethods.GetUserId(accountAccess, email), "Normal task");
                Assert.IsTrue(ToDoExists(context, taskId));
            }
        }
Пример #27
0
        public void UpdateSingleAccountAfterChangingDonationsTest()
        {
            Account updatedAccount = AccountAccess.GetAccountById(8);

            updatedAccount.UnpaidDonations.Add(new Donation(900, "reason:900", 12.6, DateTime.Today, ""));
            int personId = 1;

            Enums.CRUDResults expected = Enums.CRUDResults.UPDATE_SUCCESS;
            Enums.CRUDResults actual;
            actual = AccountAccess.UpdateSingleAccount(updatedAccount, personId);
            Assert.AreEqual(expected, actual);
            Account afterUpdate = AccountAccess.GetAccountById(8);

            Assert.AreEqual(updatedAccount, afterUpdate);
        }
Пример #28
0
        private ConsentRequest GetConsentDetailsForEverything(ConsentDetails consentDetails)
        {
            AccountAccess accountAccess;

            if (consentDetails.ConsentPurpose == ConsentDetails.PurposeEnum.AccountDetails)
            {
                accountAccess = new AccountAccess(AvailableAccountsEnum.All);
            }
            else
            {
                accountAccess = new AccountAccess(AllPSD2Enum.All);
            }

            return(new ConsentRequest(accountAccess, consentDetails.Recurring, consentDetails.ValidUntil?.ToUniversalTime(), consentDetails.AccessFrequency ?? 1, consentDetails.Combined ?? false));
        }
Пример #29
0
        public void GetByLastMonthlyPaymentDateTest()
        {
            DateTime       lastPayment = DateTime.Today;
            List <Account> expected    = AccountAccess.GetAllAccounts();
            List <Account> actual;

            actual = AccountAccess.GetByLastMonthlyPaymentDate(lastPayment);
            for (int i = 0; i < expected.Count; i++)
            {
                if (expected[i].LastMonthlyPaymentDate == lastPayment)
                {
                    Assert.IsTrue(actual.Contains(expected[i]));
                }
            }
        }
Пример #30
0
        public void TestGetUserID()
        {
            //Arrange
            Student       expextedStudent = new Student("Name", "Surname", "StudentID", "RecordBook", "TEST", "login2");
            AccountAccess accountAccess   = new AccountAccess(new TestDBAccess());

            accountAccess.RegisterStudent("password2", expextedStudent);
            int accountID  = GetMaxAccountID("student");
            int expectedID = GetMaxIDOfStudent();

            //Act
            int actualID = accountAccess.GetUserId(accountID, "student");

            //Assert
            Assert.AreEqual(expectedID, actualID);
        }
Пример #31
0
        public void GetByMonthlyPaymentTotalTest()
        {
            int            monthlyTotal = 0;
            List <Account> expected     = AccountAccess.GetAllAccounts();
            List <Account> actual;

            actual = AccountAccess.GetByMonthlyPaymentTotal(monthlyTotal);

            for (int i = 0; i < expected.Count; i++)
            {
                if (expected[i].MonthlyPaymentTotal == monthlyTotal)
                {
                    Assert.IsTrue(actual.Contains(expected[i]));
                }
            }
        }