/// <summary>
 /// Copy Constructor
 /// </summary>
 /// <remarks>値型と, <see cref="Model"/>フィールドは引き継がれる.</remarks>
 private MemberListItemViewModel(MemberListItemViewModel other)
 {
     this.Model = other.Model;
     this.IsCheckedField = other.IsCheckedField;
     this.MemberClickCommand = new DelegateCommand(ClickMember);
     this.MemberExtendedClickCommand = new DelegateCommand(ExtendClickMember);
 }
 public MemberListItemViewModelInstancesTest()
 {
     for (int i = 0; i < 2; i++)
     {
         IPerson modelField = new Mock<IPerson>().Object;
         MemberListItemViewModel instance = new MemberListItemViewModel(modelField);
         instance.SetBackingField(MemberListItemViewModelMember.Model, modelField);
         ModelFields.Add(modelField);
         Instances.Add(instance);
     }
 }
 private MemberListViewModel(IList<Model.IPerson> memberData)
 {
     Members = memberData
         .Select(
             personData =>
             {
                 IMemberListItemViewModel memberListItemViewModel = new MemberListItemViewModel(personData);
                 memberListItemViewModel.MemberClick += Item_MemberClick;
                 memberListItemViewModel.MemberExtendedClick += Item_MemberExtendedClick;
                 return memberListItemViewModel;
             })
         .ToList();
 }
        public void CopyConstructorTest(bool isCheckedFieldValue)
        {
            // Arrange
            IPerson inputModel = new Mock<IPerson>().Object;
            MemberListItemViewModel inputOther = new MemberListItemViewModel(inputModel);
            inputOther.SetPrivateField(MemberListItemViewModelMember.IsCheckedField, isCheckedFieldValue);
            // Expected data
            IPerson expectedModel = (IPerson)inputOther.GetBackingField(MemberListItemViewModelMember.Model);

            // Act
            IMemberListItemViewModel actualReturn = MemberListItemViewModel.CopyMemberListItemViewModel(inputOther);

            // Assert
            // 影響するフィールドの確認
            Assert.Same(inputModel, actualReturn.Model);
            Assert.Equal(isCheckedFieldValue, (bool)actualReturn.GetPrivateField(MemberListItemViewModelMember.IsCheckedField));
            Assert.NotNull(actualReturn.MemberClickCommand);
            Assert.IsType<Microsoft.Practices.Prism.Commands.DelegateCommand>(actualReturn.MemberClickCommand);
            Assert.NotNull(actualReturn.MemberExtendedClickCommand);
            Assert.IsType<Microsoft.Practices.Prism.Commands.DelegateCommand>(actualReturn.MemberExtendedClickCommand);
        }
        public void ConstructorTest()
        {
            // Arrange
            IPerson inputModel = new Mock<IPerson>().Object;
            IPerson expectedModel = inputModel;

            // Act
            MemberListItemViewModel actualReturn = new MemberListItemViewModel(inputModel);

            // Assert
            // 影響するフィールドの確認
            Assert.Same(expectedModel, actualReturn.Model);
            Assert.NotNull(actualReturn.MemberClickCommand);
            Assert.IsType<Microsoft.Practices.Prism.Commands.DelegateCommand>(actualReturn.MemberClickCommand);
            Assert.NotNull(actualReturn.MemberExtendedClickCommand);
            Assert.IsType<Microsoft.Practices.Prism.Commands.DelegateCommand>(actualReturn.MemberExtendedClickCommand);
        }
        public void NameTest()
        {
            // Arrange
            string expectedName = "foobar";

            // Act
            var person = new Person { Name = expectedName };
            var instance = new MemberListItemViewModel(person);
            string actualName = instance.Name;

            // Assert
            Assert.Equal(expectedName, actualName);
        }
        public void IsCheckedTestWithoutEventHandler()
        {
            // Arrange
            bool inputValue = true;
            var person = new Person();
            var target = new MemberListItemViewModel(person);

            // Arrange
            target.IsChecked = inputValue;
            bool actualValue = target.IsChecked;

            // Assert
            Assert.Equal(inputValue, actualValue);
        }
        public void IsCheckedTestWithEventHandler()
        {
            // Arrange
            bool inputValue = true;
            var person = new Person();
            var target = new MemberListItemViewModel(person);
            object actualSender = null;
            PropertyChangedEventArgs actualE = null;
            target.PropertyChanged += (s, e) => { actualSender = s; actualE = e; };

            // Arrange
            target.IsChecked = inputValue;
            bool actualValue = target.IsChecked;

            // Assert
            Assert.Equal(inputValue, actualValue);
            Assert.Same(target, actualSender);
            Assert.Equal(nameof(MemberListItemViewModel.IsChecked), actualE.PropertyName);
        }
        public void DescriptionTest()
        {
            // Arrange
            string expectedDescription = "foobar";

            // Act
            var person = new Person { Description = expectedDescription };
            var instance = new MemberListItemViewModel(person);
            string actualDescription = instance.Description;

            // Assert
            Assert.Equal(expectedDescription, actualDescription);
        }
 public MemberListItemViewModelInstanceTest()
 {
     ModelField = new Mock<IPerson>().Object;
     Instance = new MemberListItemViewModel(ModelField);
     Instance.SetBackingField(MemberListItemViewModelMember.Model, ModelField);
 }