本文整理汇总了C#中DataContext.Get方法的典型用法代码示例。如果您正苦于以下问题:C# DataContext.Get方法的具体用法?C# DataContext.Get怎么用?C# DataContext.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataContext
的用法示例。
在下文中一共展示了DataContext.Get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPosts_ReturnsEmptyCollection
public void GetPosts_ReturnsEmptyCollection(string databaseName)
{
// Given
var sut = new DataContext(databaseName);
// When
var result = sut.Get<Post>();
// Then
Assert.Empty(result);
sut.Database.Delete();
sut.Dispose();
}
示例2: GetPosts_DoesNotReturnNull
public void GetPosts_DoesNotReturnNull(string databaseName)
{
// Given
var sut = new DataContext(databaseName);
// When
var result = sut.Get<Post>();
// Then
Assert.NotNull(result);
sut.Database.Delete();
sut.Dispose();
}
示例3: GetPosts_WithNewPostAndEagerLoadedTag_ReturnsPostWithTheSameTag
public void GetPosts_WithNewPostAndEagerLoadedTag_ReturnsPostWithTheSameTag(
Post post,
Tag tag,
string databaseName)
{
// Given
post.Tags.Add(tag);
var sut = new DataContext(databaseName);
// When
sut.RegisterAdded(post);
sut.SaveChanges();
var result = sut.Get<Post>("Tags").SingleOrDefault();
// Then
Assert.True(post.Tags.SequenceEqual(result.Tags));
sut.Database.Delete();
sut.Dispose();
}
示例4: RegisterModified_WithModifiedPost_PersistsPost
public void RegisterModified_WithModifiedPost_PersistsPost(
string databaseName,
Post post,
string modifiedValue)
{
// Given
var sut = new DataContext(databaseName);
sut.RegisterAdded(post);
sut.Commit();
// When
post.Title = modifiedValue;
sut.RegisterModified(post);
sut.Commit();
var result = sut.Get<Post>().FirstOrDefault();
// Then
Assert.Equal(post, result);
sut.Database.Delete();
sut.Dispose();
}
示例5: RegisterDeleted_WithPost_RemovesPost
public void RegisterDeleted_WithPost_RemovesPost(
string databaseName,
Post post)
{
// Given
var sut = new DataContext(databaseName);
sut.RegisterAdded(post);
sut.Commit();
// When
sut.RegisterDeleted(post);
sut.Commit();
var result = sut.Get<Post>().Any();
// Then
Assert.False(result);
sut.Database.Delete();
sut.Dispose();
}
示例6: GetPosts_WithNewPost_ReturnsCollectionWithOneElement
public void GetPosts_WithNewPost_ReturnsCollectionWithOneElement(
Post post,
string databaseName)
{
// Given
var sut = new DataContext(databaseName);
// When
sut.RegisterAdded(post);
sut.SaveChanges();
var result = sut.Get<Post>();
// Then
Assert.Equal(1, result.Count());
sut.Database.Delete();
sut.Dispose();
}
示例7: GetPosts_WithNewPostAndNonExistentEagerLoadedProperty_Throws
public void GetPosts_WithNewPostAndNonExistentEagerLoadedProperty_Throws(
Post post,
string propertyName,
string databaseName)
{
// Given
var sut = new DataContext(databaseName);
// When
sut.RegisterAdded(post);
sut.SaveChanges();
// Then
Assert.Throws<InvalidOperationException>(() => sut.Get<Post>(propertyName).Any());
sut.Database.Delete();
sut.Dispose();
}