本文整理汇总了C#中UserRepository.DeleteUser方法的典型用法代码示例。如果您正苦于以下问题:C# UserRepository.DeleteUser方法的具体用法?C# UserRepository.DeleteUser怎么用?C# UserRepository.DeleteUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRepository
的用法示例。
在下文中一共展示了UserRepository.DeleteUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete_ShouldDeleteUser
public void Delete_ShouldDeleteUser()
{
//arrange
var userRepository = new UserRepository(Properties.Resources.ConnectionString);
User user = TestDataHelper.GenerateUser();
//act
userRepository.CreateUser(user);
User userBeforeDelete = userRepository.GetUser(user.Id);
if (userBeforeDelete == null)
{
Console.WriteLine("User not exist!");
}
else
{
Console.WriteLine("User exist.");
}
userRepository.DeleteUser(user.Id);
//assert
User userAfterDelete = userRepository.GetUser(user.Id);
if (userAfterDelete == null)
{
Console.WriteLine("User deleted.");
}
else
{
Console.WriteLine("User not deleted!");
}
Assert.IsTrue(!(userBeforeDelete == null) & (userAfterDelete == null));
}
示例2: DeleteUserNotExistent
public void DeleteUserNotExistent()
{
var data = SetupMockData();
UserSet.Setup(set => set.Provider).Returns(data.Provider);
UserSet.Setup(set => set.Expression).Returns(data.Expression);
UserSet.Setup(set => set.ElementType).Returns(data.ElementType);
UserSet.Setup(set => set.GetEnumerator()).Returns(data.GetEnumerator());
ContextMock.Setup(c => c.Entity<User>()).Returns(UserSet.Object);
var repository = new UserRepository(ContextMock.Object, LoggingHelperMock.Object);
var userId = 99;
repository.DeleteUser(userId);
UserSet.Verify(set => set.Remove(It.IsAny<User>()), Times.Never);
ContextMock.Verify(c => c.SaveChanges(), Times.Never);
}
示例3: DeleteUser
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
public override bool DeleteUser(string username, bool deleteAllRelatedData)
{
SecUtility.CheckParameter(ref username, true, true, true, 256, "username");
var dbo = new UserRepository(this.Name, _sqlConnectionString, _commandTimeout);
return dbo.DeleteUser(username);
}
示例4: DeleteUser
public override bool DeleteUser(string username, bool deleteAllRelatedData)
{
UserRepository _user = new UserRepository();
_user.DeleteUser(username);
return true;
}