public void CreateFriendAndSendNotification()
        {
            var mockFriendRepository = Mock.Create<IFriendRepository>();
            var mockNotificationService = Mock.Create<INotificationService>();

            var myFriendsService = new FriendsService(mockFriendRepository, mockNotificationService);

            myFriendsService.AddFriend(Guid.NewGuid(), "", "", "");

            Mock.Assert(() => mockFriendRepository.Create(Arg.IsAny<Guid>(), Arg.IsAny<string>()), Occurs.Once());
            Mock.Assert(() => mockNotificationService.SendNotification(Arg.IsAny<string>(), Arg.IsAny<string>(), Arg.IsAny<string>()), Occurs.Once());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string currentUserName = MyProfile.CurrentUser.Name;
            string currentUserEmail = SecurityMembership.GetUser().Email;
            string friendEmail = Request.QueryString["email"];
            Guid currentUserId = (Guid)SecurityMembership.GetUser().ProviderUserKey;

            var friendsService = new FriendsService(new EfFriendRepository(),
                new NotificationService(new EfQueryUsersByEmail(), new DebugEmailSender()));

            friendsService.AddFriend(currentUserId, currentUserEmail, currentUserName, friendEmail);

            SuccessLabel.Text = "Added friend: " + Request.QueryString["email"];
        }
Ejemplo n.º 3
0
        public void AddFriendWithValidEmail()
        {
            // arrange
            string currentUserName = "******";
            string currentUserEmail = "*****@*****.**";
            string friendEmail = "*****@*****.**";
            Guid currentUserId = new Guid("EEECAA7B-57D5-45E1-AF11-6EBACCAC4117");

            // act
            var friendsService = new FriendsService(new FakeFriendRepository(),
                new NotificationService(new FakeQueryUsersByEmail(), new FakeEmailSender()));

            friendsService.AddFriend(currentUserId, currentUserEmail, currentUserName, friendEmail);

            // assert
        }