locked
value object and interface RRS feed

  • Question

  • User888441741 posted

    hi there,

    namespace APP.Model
    {
        public class PartialVisitor : IPartialVisitor
        {
            private string _firstName;
            private string _middleName;
            private string _lastName;
            private string _emailAddress;
            private List<IPartialPerson> _escort new List<IPartialPerson>();

            public string First
            {
                get { return _firstName; }
            }
            public string Middle
            {
                get { return _middleName; }
            }
            public string Last
            {
                get { return _lastName; }
            }
            public string EmailAddress
            {
                get { return _emailAddress; }
            }

            List<IPartialPerson> IPartialVisitor.Escort
            {
                get { return _escort; }
            }
     

            public PartialVisitor()
            {
            }


            public PartialVisitor(string firstName, string middleName, string lastName, string emailAddress, List<IPartialPerson> escorts)
            {
                _firstName = firstName;
                _middleName = middleName;
                _lastName = lastName;
                _emailAddress = emailAddress;
                _escort = escorts;
            }

           
        }
    }


        public interface IPartialPerson
        {
            string FirstName { get; }
            string MiddleName { get; }
            string LastName { get; }
            string FullName { get; }
            string UserID { get; }
        }



    my unittest failed
    
      IPartialPerson _escorts = new PartialPerson("fname", "mn", "lname", "fname and lname", "1001abc");
    
     IPartialVisitor _partialVisitor = new PartialVisitor("first name", "middle name", "last name", "emailaddress@email.com", _escorts);
    
    
    //
    Error	1	The best overloaded method match for 'APP.Model.PartialVisitor.PartialVisitor(string, string, string, string, System.Collections.Generic.List<APP.Model.Interface.IPartialPerson>)' 
    has some invalid arguments VisitTests.cs	
    
    Error	2	Argument '5': cannot convert from 'APP.Model.Interface.IPartialPerson' to 'System.Collections.Generic.List<APP.Model.Interface.IPartialPerson>'	VisitTests.cs	50	84	APP.Web.Tests
    
    
    what i'm doing wrong here?, i know my IPartialVisitor.Escort is readonly.
    
    any help?
    
    
    


     

    Sunday, February 14, 2010 7:33 PM

All replies

  • User-1149223197 posted

    This is a compiler error, right? Here's the problematic lines:

    IPartialPerson _escorts = new PartialPerson("fname""mn""lname""fname and lname""1001abc");
    IPartialVisitor _partialVisitor = new PartialVisitor("first name""middle name""last name""emailaddress@email.com", _escorts);

    The 5th argument to the second line, _escorts, is of type IPartialPerson. However, the IPartialVisitor constructor is expecting a List<IPartialPerson> as the 5th argument. Try this instead:

     

    IPartialPerson _escort1 = new PartialPerson("fname""mn""lname""fname and lname""1001abc");
    List<IPartialPerson> _escorts = new List<IPartialPerson>();
    _escorts.Add(escort1);
    IPartialVisitor _partialVisitor = new PartialVisitor("first name""middle name""last name""emailaddress@email.com", _escorts);

     

     

    Sunday, February 14, 2010 7:44 PM
  • User888441741 posted

    This is a compiler error, right? Here's the problematic lines:

    IPartialPerson _escorts = new PartialPerson("fname""mn""lname""fname and lname""1001abc");
    IPartialVisitor _partialVisitor = new PartialVisitor("first name""middle name""last name""emailaddress@email.com", _escorts);

    The 5th argument to the second line, _escorts, is of type IPartialPerson. However, the IPartialVisitor constructor is expecting a List<IPartialPerson> as the 5th argument. Try this instead:

     

    IPartialPerson _escort1 = new PartialPerson("fname""mn""lname""fname and lname""1001abc");
    List<IPartialPerson> _escorts = new List<IPartialPerson>();
    _escorts.Add(escort1);
    IPartialVisitor _partialVisitor = new PartialVisitor("first name""middle name""last name""emailaddress@email.com", _escorts);

     

     

     

    thanks for your response.

    do you think PartialVisitor class is tightly coupled?

    i am thinking since that class needs to instantiate the List<IPartialPerson> for escorts?

    any comments on this?

    Monday, February 15, 2010 3:33 PM