コード例 #1
0
        public void CallMapperService_FriendsCountTimes()
        {
            // Arrange
            var mockedMapperService = new Mock <IMapperService>();
            var mappedFriend        = new ProfileFriendViewModel();

            mockedMapperService.Setup(x => x.MapObject <ProfileFriendViewModel>(It.IsAny <CustomUser>())).Returns(mappedFriend);
            var mockedImageService  = new Mock <IImageService>();
            var mockedUserService   = new Mock <IUserService>();
            var mockedFriendService = new Mock <IFriendService>();

            var viewModelService = new ViewModelService(
                mockedMapperService.Object,
                mockedImageService.Object,
                mockedUserService.Object,
                mockedFriendService.Object);
            var friends = new List <CustomUser>()
            {
                new CustomUser()
                {
                    ProfileImage = new ProfileImage()
                    {
                        Content = new byte[] { 1, 2 }
                    }
                },
                new CustomUser()
                {
                    ProfileImage = new ProfileImage()
                    {
                        Content = new byte[] { 2, 3 }
                    }
                },
                new CustomUser()
                {
                    ProfileImage = new ProfileImage()
                    {
                        Content = new byte[] { 3, 4 }
                    }
                }
            };

            // Act
            viewModelService.GetMappedUserFriends(friends);

            // Assert
            mockedMapperService.Verify(x => x.MapObject <ProfileFriendViewModel>(It.IsAny <CustomUser>()), Times.Exactly(friends.Count));
        }
コード例 #2
0
        public void ReturnCorrectCountMappedUserFriends()
        {
            // Arrange
            var mockedMapperService = new Mock <IMapperService>();
            var mappedFriend        = new ProfileFriendViewModel();

            mockedMapperService.Setup(x => x.MapObject <ProfileFriendViewModel>(It.IsAny <CustomUser>())).Returns(mappedFriend);
            var mockedImageService  = new Mock <IImageService>();
            var mockedUserService   = new Mock <IUserService>();
            var mockedFriendService = new Mock <IFriendService>();

            var viewModelService = new ViewModelService(
                mockedMapperService.Object,
                mockedImageService.Object,
                mockedUserService.Object,
                mockedFriendService.Object);
            var friends = new List <CustomUser>()
            {
                new CustomUser()
                {
                    ProfileImage = new ProfileImage()
                    {
                        Content = new byte[] { 1, 2 }
                    }
                },
                new CustomUser()
                {
                    ProfileImage = new ProfileImage()
                    {
                        Content = new byte[] { 2, 3 }
                    }
                },
                new CustomUser()
                {
                    ProfileImage = new ProfileImage()
                    {
                        Content = new byte[] { 3, 4 }
                    }
                }
            };

            // Act
            var result = viewModelService.GetMappedUserFriends(friends);

            // Assert
            Assert.AreEqual(result.Count(), 3);
        }