Askme.Domain.UserTest.TestFailUsersRegistrationIfSaveUserThrowsException C# (CSharp) Method

TestFailUsersRegistrationIfSaveUserThrowsException() private method

        public void TestFailUsersRegistrationIfSaveUserThrowsException()
        {
            User user = new User("ShilpaG", "test123", "[email protected]");
            var mock = new Mock<IRepository>();
            mock.Setup(ps => ps.IsUserPresent(user.Username)).Returns(false).AtMostOnce();
            mock.Setup(ps => ps.SaveUser(user)).Throws(new Exception("User could not be saved")).AtMostOnce();
            user.Register(mock.Object);
        }