本文整理汇总了C#中IUowData类的典型用法代码示例。如果您正苦于以下问题:C# IUowData类的具体用法?C# IUowData怎么用?C# IUowData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IUowData类属于命名空间,在下文中一共展示了IUowData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToAccountViewModel
public static AccountViewModel ToAccountViewModel(this ApplicationUser user, IUowData context)
{
return new AccountViewModel(context)
{
Id = user.Id,
PhoneNumber = user.PhoneNumber,
Email= user.Email,
UserInRole = user.Roles,
UserName = user.UserName
};
}
示例2: GetTweetFromViewModel
protected Tweet GetTweetFromViewModel(TweetsViewModel tweet, string username, IUowData db)
{
// Security risk...
var tweetUser = db.Users.All().ToList().Find(x => x.UserName == username);
Tweet result = new Tweet()
{
Id = tweet.Id,
Content = tweet.Content,
Title = tweet.Title,
User = tweetUser
};
return result;
}
示例3: UserAdministrationControllerTests
/// <summary>
/// Initializes a new instance of the <see cref="UserAdministrationControllerTests" /> class.
/// </summary>
public UserAdministrationControllerTests()
{
this.roles = new List<RoleIntPk>()
{
new RoleIntPk(){ Id = 1, Name="Administrator" },
new RoleIntPk(){ Id = 2, Name="User" },
new RoleIntPk(){ Id = 3, Name="Uploader" },
};
this.users = new List<ApplicationUser>()
{
new ApplicationUser(){ Id = 1, Email="[email protected]", UserName = "user1"},
new ApplicationUser(){ Id = 2, Email="[email protected]", UserName = "user2"},
new ApplicationUser(){ Id = 3, Email="[email protected]", UserName = "user3"},
};
foreach (var user in this.users)
{
user.Roles.Add(new UserRoleIntPk() { UserId = user.Id, RoleId = 1 });
user.Roles.Add(new UserRoleIntPk() { UserId = user.Id, RoleId = 2 });
user.Roles.Add(new UserRoleIntPk() { UserId = user.Id, RoleId = 3 });
}
//Create Mock repositories
Mock<IRepository<RoleIntPk, int>> mockRolesRepository = new Mock<IRepository<RoleIntPk, int>>();
mockRolesRepository.Setup(r => r.All()).Returns(this.roles.AsQueryable());
mockRolesRepository.Setup(u => u.GetById(It.IsAny<int>())).Returns((int x) => { return this.roles[x - 1]; });
this.rolesRepository = mockRolesRepository.Object;
Mock<IRepository<ApplicationUser, int>> mockUsersRepository = new Mock<IRepository<ApplicationUser, int>>();
mockUsersRepository.Setup(u => u.All()).Returns(this.users.AsQueryable());
mockUsersRepository.Setup(u => u.GetById(It.IsAny<int>())).Returns((int x) => { return this.users[x - 1]; });
mockUsersRepository.Setup(u => u.Delete(It.IsAny<ApplicationUser>())).Callback((ApplicationUser x) => { this.users.RemoveAt(0); });
mockUsersRepository.Setup(u => u.Update(It.Is<ApplicationUser>(
au => !au.Email.Contains("@")
))).Throws(new ArgumentException("Email"));
this.usersRepository = mockUsersRepository.Object;
Mock<IUowData> mockUow = new Mock<IUowData>();
mockUow.Setup(p => p.Roles).Returns(this.rolesRepository);
mockUow.Setup(p => p.Users).Returns(this.usersRepository);
this.uowData = mockUow.Object;
var mockControllerContext = new Mock<ControllerContext>();
mockControllerContext.Setup(x => x.HttpContext).Returns(GetMockedHttpContext());
//mockControllerContext.Setup(x=>x.HttpContext.User).Returns(new GenericPrincipal(new GenericIdentity("Test"),new string[]{"test"}));
//mockControllerContext.Setup(x => x.HttpContext.GetOwinContext);
this.controllerContext = mockControllerContext.Object;
}
示例4: FileUploadControllerTests
public FileUploadControllerTests()
{
this.files = new List<FileDescription>()
{
new FileDescription(){ Id = 1, FileName="File1", Size = 1, UserId = 1, ApplicationUser = new ApplicationUser(){ UserName = "test1"}},
new FileDescription(){ Id = 2, FileName="File2", Size = 1, UserId = 2, ApplicationUser = new ApplicationUser(){ UserName = "test2"}},
new FileDescription(){ Id = 3, FileName="File3", Size = 1, UserId = 1, ApplicationUser = new ApplicationUser(){ UserName = "test1"}},
};
this.uploadResults = new List<UploadResult>();
int id = 1;
foreach (var file in this.files)
{
this.uploadResults.Add(new UploadResult(){ Id=id++, FileId = file.Id, File = file, Message="UploadDescription1", RowNumber=1, Status=Status.Ok});
this.uploadResults.Add(new UploadResult(){ Id=id++, FileId = file.Id, File = file, Message="UploadDescription2", RowNumber=2, Status=Status.Warning});
this.uploadResults.Add(new UploadResult(){ Id=id++, FileId = file.Id, File = file, Message="UploadDescription3", RowNumber=3, Status=Status.Error});
}
foreach (var ur in this.uploadResults)
{
this.files[ur.FileId-1].UploadResults.Add(ur);
}
//Create Mock repositories
Mock<IRepository<FileDescription, int>> mockFileDescriptionRepository = new Mock<IRepository<FileDescription, int>>();
mockFileDescriptionRepository.Setup(r => r.All()).Returns(this.files.AsQueryable());
mockFileDescriptionRepository.Setup(r => r.GetById(It.IsAny<int>())).Returns((int x) => (this.files[x - 1]));
Mock<IRepository<UploadResult,int>> mockUploadResultRepository = new Mock<IRepository<UploadResult,int>>();
mockUploadResultRepository.Setup(r => r.All()).Returns(this.uploadResults.AsQueryable());
//initializing repositories
this.fileRepository = mockFileDescriptionRepository.Object;
this.uploadResultsRepository = mockUploadResultRepository.Object;
//Create UowData
Mock<IUowData> mockUow = new Mock<IUowData>();
mockUow.Setup(uow => uow.FileDescriptions).Returns(this.fileRepository);
mockUow.Setup(uow => uow.UploadResults).Returns(this.uploadResultsRepository);
this.uowData = mockUow.Object;
}
示例5: HomeController
public HomeController(IUowData data)
: base(data)
{
}
示例6: DevicesController
public DevicesController(IUowData data, IRemoteControl remoteControl)
: base(data, remoteControl)
{
}
示例7: CommentController
public CommentController(IUowData data)
: base(data)
{
}
示例8: BaseController
public BaseController(IUowData db)
{
this.db = db;
}
示例9: CuisinesController
public CuisinesController(IUowData db)
: base(db)
{
this.db = db;
}
示例10: NewsService
public NewsService(IUowData data) : base(data)
{
}
示例11: RoomsController
public RoomsController(IUowData data, IRemoteControl remoteControl)
: base(data, remoteControl)
{
}
示例12: FileUpploadController
public FileUpploadController(IUowData db)
{
this.db = db;
}
示例13: QuestionsController
public QuestionsController(IUowData data)
: base(data)
{
}
示例14: TweetsController
public TweetsController(IUowData data)
: base(data)
{
}
示例15: HouseSettingsController
public HouseSettingsController(IUowData data, IRemoteControl remoteControl)
: base(data, remoteControl)
{
}