Ejemplo n.º 1
0
        public void BasicUser_When_Change_Surname(
            string changeSurname, string expected)
        {
            string result = "OK";

            //arrange
            BasicUser basicUser   = null;
            string    coreSurname = "Nazwisko";

            try
            {
                basicUser = new BasicUser(
                    id: 0, pin: new PinVAL(value: "1010"),
                    name: new NameVAL(value: "Imię"),
                    surname: new SurnameVAL(value: coreSurname),
                    bankAccount: new BankAccount(
                        state: new MoneyVAL(value: 200.0M,
                                            currency: Currency.PLN)));
            }
            catch (PinVAL_Exception p_e)
            {
                result = p_e.What();
            }
            catch (NameVAL_Exception n_e)
            {
                result = n_e.What();
            }
            catch (SurnameVAL_Exception s_e)
            {
                result = s_e.What();
            }
            catch (BankAccount_Exception b_e)
            {
                result = b_e.What();
            }
            catch (MoneyVAL_Exception m_e)
            {
                result = m_e.What();
            }

            //act
            if (result.Equals("OK"))
            {
                try
                {
                    basicUser.ChangeSurname(surname: new SurnameVAL(value: changeSurname));
                }
                catch (SurnameVAL_Exception s_e)
                {
                    result = s_e.What();
                }

                if (result.Equals("OK"))
                {
                    if (basicUser._Surname._Value.Equals(changeSurname) == false)
                    {
                        result = "Issue with change surname";
                    }
                }
            }

            //assert
            Assert.AreEqual(expected: expected, actual: result);
        }