コード例 #1
0
ファイル: IPersonRowModel.cs プロジェクト: suh786/dts.gui
 public PersonRowModel(IPersonRecord personRecord) : base(personRecord)
 {
     FirstName = personRecord.FirstName;
     MiddleName = personRecord.MiddleName;
     LastName = personRecord.LastName;
     Address = personRecord.Address;
     Age = personRecord.Age;
     FatherName = personRecord.FatherName;
     MotherName = personRecord.MotherName;
     OfficeName = personRecord.OfficeName;
     OfficeAddress = personRecord.OfficeAddress;
 }
コード例 #2
0
        /// <summary>
        /// Gets the display name.
        /// </summary>
        /// <param name="personRecord">The person record.</param>
        /// <returns>The name as a single string.</returns>
        /// <remarks>This code was extracted from Person.cs, so see that file for history.</remarks>
        public static string GetFormattedDisplayName(this IPersonRecord personRecord)
        {
            if (string.IsNullOrEmpty(personRecord.GivenName) && string.IsNullOrEmpty(personRecord.FamilyName))
            {
                // We have no name so return ""
                return(string.Empty);
            }

            var formattedTitle = personRecord.GetFormattedTitle();

            if (formattedTitle.HasValue())
            {
                return(string.Format("{0}, {1} ({2})", personRecord.GetFormattedFamilyName(), personRecord.GetFormattedGivenName(), formattedTitle));
            }

            return(string.Format("{0}, {1}", personRecord.GetFormattedFamilyName(), personRecord.GetFormattedGivenName()));
        }
コード例 #3
0
 /// <summary>
 /// Gets the formatted title.
 /// </summary>
 /// <param name="personRecord">The person record.</param>
 /// <returns>The formatted title.</returns>
 public static string GetFormattedTitle(this IPersonRecord personRecord)
 {
     return(CapitalizeFirstLetter(personRecord.Title));
 }
コード例 #4
0
 /// <summary>
 /// Gets the formatted given name.
 /// </summary>
 /// <param name="personRecord">The person record.</param>
 /// <returns>The formatted given name.</returns>
 public static string GetFormattedGivenName(this IPersonRecord personRecord)
 {
     return(CapitalizeFirstLetter(personRecord.GivenName));
 }
コード例 #5
0
 /// <summary>
 /// Gets the formatted family name.
 /// </summary>
 /// <param name="personRecord">The person record.</param>
 /// <returns>The formatted family name.</returns>
 public static string GetFormattedFamilyName(this IPersonRecord personRecord)
 {
     return(personRecord.FamilyName.ToUpper());
 }
コード例 #6
0
        private void AssertErrorMessagesContainNameOfPropertySetterNotHiddenMethod(IPersonRecord personRecord)
        {
            SkipVerificationForThisTest();

            Expect.Once.On(personRecord).SetProperty("FirstName").To("Fred");

            try
            {
                personRecord.LastName = "Bloggs";
            }
            catch (ExpectationException e)
            {
                Assert.IsTrue(e.Message.IndexOf("set_FirstName(\"Fred\")") < 0,
                              "message should not contain set_FirstName(\"Fred\")\nWas: " + e.Message);
                Assert.IsTrue(e.Message.IndexOf("p.FirstName = (equal to \"Fred\")") >= 0,
                              "message should contain p.FirstName = \"Fred\"\nWas: " + e.Message);
                Assert.IsTrue(e.Message.IndexOf("set_LastName(\"Bloggs\")") < 0,
                              "message should not contain set_LastName(\"Bloggs\")\nWas :" + e.Message);
                Assert.IsTrue(e.Message.IndexOf("p.LastName = \"Bloggs\"") >= 0,
                              "message should contain p.LastName = \"Bloggs\"\nWas: " + e.Message);
            }
        }
コード例 #7
0
        private void AssertErrorMessagesContainNameOfPropertyGetterNotHiddenMethod(IPersonRecord personRecord)
        {
            SkipVerificationForThisTest();

            Stub.On(personRecord).GetProperty("FirstName").Will(Return.Value("Fred"));

            try
            {
                String.Intern(personRecord.LastName);
            }
            catch (ExpectationException e)
            {
                Assert.IsTrue(e.Message.IndexOf("get_FirstName()") < 0,
                              "message should not contain get_FirstName()\nWas: " + e.Message);
                Assert.IsTrue(e.Message.IndexOf("p.FirstName") >= 0,
                              "message should contain p.FirstName\nWas: " + e.Message);
                Assert.IsTrue(e.Message.IndexOf("get_LastName()") < 0,
                              "message should not contain get_LastName()\nWas: " + e.Message);
                Assert.IsTrue(e.Message.IndexOf("p.LastName") >= 0,
                              "message should contain p.LastName\nWas: " + e.Message);
            }
        }
コード例 #8
0
        private void AssertCanExpectPropertySetter(IPersonRecord personRecord)
        {
            Expect.Once.On(personRecord).SetProperty("FirstName").To("Fred");
            Expect.Once.On(personRecord).SetProperty("LastName").To("Bloggs");

            personRecord.FirstName = "Fred";
            personRecord.LastName = "Bloggs";
        }
コード例 #9
0
        private void AssertCanExpectPropertyGetter(IPersonRecord personRecord)
        {
            Stub.On(personRecord).GetProperty("FirstName").Will(Return.Value("Fred"));
            Stub.On(personRecord).GetProperty("LastName").Will(Return.Value("Bloggs"));

            Verify.That(personRecord.FirstName, Is.EqualTo("Fred"), "first name");
            Verify.That(personRecord.LastName, Is.EqualTo("Bloggs"), "last name");
        }