本文整理汇总了C#中Tests.DataClasses.SampleWebAppDb类的典型用法代码示例。如果您正苦于以下问题:C# SampleWebAppDb类的具体用法?C# SampleWebAppDb怎么用?C# SampleWebAppDb使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SampleWebAppDb类属于Tests.DataClasses命名空间,在下文中一共展示了SampleWebAppDb类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Check10ValidatePostOk
public void Check10ValidatePostOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
var snap = new DbSnapShot(db);
var existingTag = db.Tags.First();
var existingBlogger = db.Blogs.First();
//ATTEMPT
var newPost = new Post()
{
Blogger = existingBlogger,
Title = "Test post",
Content = "Nothing special",
Tags = new[] { existingTag }
};
db.Posts.Add(newPost);
var status = db.SaveChangesWithChecking();
//VERIFY
status.IsValid.ShouldEqual(true, status.Errors);
snap.CheckSnapShot(db,1,1);
}
}
开发者ID:JonPSmith,项目名称:GenericServices,代码行数:25,代码来源:Tests02Validation.cs
示例2: Check02DatabaseDataLinksOk
public void Check02DatabaseDataLinksOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
DataLayerInitialise.InitialiseThis();
var filepath = TestFileHelpers.GetTestFileFilePath("DbContentSimple.xml");
//ATTEMPT
DataLayerInitialise.ResetDatabaseToTestData(db, filepath);
//VERIFY
var allPosts = db.Posts.Include(x => x.Blogger).Include(x => x.Tags).ToList();
allPosts[0].Blogger.Name.ShouldEqual("Fred Bloggs");
string.Join(",", allPosts[0].Tags.Select(x => x.Slug)).ShouldEqual("ugly,bad");
allPosts[1].Blogger.Name.ShouldEqual("Jon Smith");
string.Join(",", allPosts[1].Tags.Select(x => x.Slug)).ShouldEqual("good,ugly");
allPosts[2].Blogger.Name.ShouldEqual("Jon Smith");
string.Join(",", allPosts[2].Tags.Select(x => x.Slug)).ShouldEqual("bad");
db.PostTagGrades.Count().ShouldEqual(2);
db.PostTagGrades.ToList().All( x => x.PostId == allPosts[0].PostId).ShouldEqual(true);
string.Join(",", db.PostTagGrades.Include(x => x.TagPart).Select(x => x.TagPart.Slug)).ShouldEqual("bad,ugly");
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:25,代码来源:Tests01Setup.cs
示例3: DbSnapShot
public DbSnapShot(SampleWebAppDb db)
{
NumBlogs = db.Blogs.Count();
NumPostTagLinks = db.Database.SqlQuery<int>("SELECT COUNT(*) FROM dbo.TagPosts").First();
NumPosts = db.Posts.Count();
NumTags = db.Tags.Count();
NumPostTagGrades = db.PostTagGrades.Count();
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:8,代码来源:DbSnapShot.cs
示例4: SetUpFixture
public void SetUpFixture()
{
using (var db = new SampleWebAppDb())
{
DataLayerInitialise.InitialiseThis();
var filepath = TestFileHelpers.GetTestFileFilePath("DbContentSimple.xml");
DataLayerInitialise.ResetDatabaseToTestData(db, filepath);
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:9,代码来源:Test02UpdateServiceAsync.cs
示例5: Main
static void Main(string[] args)
{
using (var db = new SampleWebAppDb())
{
var firstId = db.Posts.First().PostId;
RunCommand1(db);
RunCommand2(db);
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:10,代码来源:Program.cs
示例6: CheckSnapShot
public void CheckSnapShot(SampleWebAppDb db, int postsChange = 0, int postTagLinkChange = 0, int blogsChange = 0, int tagsChange = 0, int postTagGradesChange = 0)
{
var newSnap = new DbSnapShot(db);
newSnap.NumPosts.ShouldEqual( NumPosts + postsChange, "posts wrong");
newSnap.NumPostTagLinks.ShouldEqual(NumPostTagLinks + postTagLinkChange, "posttaglinks wrong");
newSnap.NumBlogs.ShouldEqual(NumBlogs + blogsChange, "blogs wrong");
newSnap.NumTags.ShouldEqual(NumTags + tagsChange, "tags wrong");
newSnap.NumPostTagGrades.ShouldEqual(NumPostTagGrades + postTagGradesChange, "postTagGrades wrong");
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:10,代码来源:DbSnapShot.cs
示例7: Check01ReadBlogsNoPostsOk
public void Check01ReadBlogsNoPostsOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
//ATTEMPT
var blogs = db.Blogs.ToList();
//VERIFY
blogs.Count.ShouldEqual(2);
blogs.All( x => x.Posts == null).ShouldEqual(true);
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:14,代码来源:Tests04ReadWrite.cs
示例8: Check01CreateSetupFlowOk
public void Check01CreateSetupFlowOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
var service = new CreateSetupService<Tag, SimpleTagDto>(db);
//ATTEMPT
var dto = service.GetDto();
//VERIFY
dto.FunctionsCalledCommaDelimited.ShouldEqual("SetupSecondaryData");
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:14,代码来源:Test01CreateService.cs
示例9: Test02NoSingleExceptionSetBad
public void Test02NoSingleExceptionSetBad()
{
using (var db = new SampleWebAppDb())
{
//SETUP
GenericServicesConfig.RealiseSingleExceptionMethod = null;
//ATTEMPT
var ex = Assert.Throws<InvalidOperationException>(() => db.Posts.RealiseSingleWithErrorChecking());
//VERIFY
ex.Message.ShouldEqual("Sequence contains more than one element");
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:14,代码来源:Test10RealiseSingleException.cs
示例10: FixtureSetup
public void FixtureSetup()
{
//This remembers the SqlErrorTextDict
_rememberDefaultSqlErrorTextDict =
GenericServicesConfig.SqlErrorDict.Select(x => new KeyValuePair<int, string>(x.Key, x.Value))
.ToList();
GenericServicesConfig.ClearSqlHandlerDict();
using (var db = new SampleWebAppDb())
{
DataLayerInitialise.InitialiseThis();
var filepath = TestFileHelpers.GetTestFileFilePath("DbContentSimple.xml");
DataLayerInitialise.ResetDatabaseToTestData(db, filepath);
}
}
开发者ID:JonPSmith,项目名称:GenericServices,代码行数:15,代码来源:Test02SqlDict.cs
示例11: Test01NoSingleExceptionSetOk
public void Test01NoSingleExceptionSetOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
var id = db.Posts.First().PostId;
GenericServicesConfig.RealiseSingleExceptionMethod = null;
//ATTEMPT
var status = db.Posts.Where(x => x.PostId == id).RealiseSingleWithErrorChecking();
//VERIFY
status.IsValid.ShouldEqual(true, status.Errors);
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:15,代码来源:Test10RealiseSingleException.cs
示例12: Check06ListEfViaDtoOk
public async void Check06ListEfViaDtoOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
var timer = new Stopwatch();
timer.Start();
//ATTEMPT
await db.ListPostEfViaDtoAsync(0);
timer.Stop();
//VERIFY
Console.WriteLine("Ef operation took {0} ms", timer.ElapsedMilliseconds);
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:16,代码来源:Perf04EfPostAsync.cs
示例13: Check01DetailFlowOk
public void Check01DetailFlowOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
var service = new DetailService<Tag, SimpleTagDto>(db);
var firstTag = db.Tags.First();
//ATTEMPT
var status = service.GetDetailUsingWhere(x => x.TagId == firstTag.TagId);
//VERIFY
status.IsValid.ShouldEqual(true, status.Errors);
status.Result.FunctionsCalledCommaDelimited.ShouldEqual("DetailDtoFromDataIn");
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:16,代码来源:Test03DetailService.cs
示例14: Check01UpdateSetupFlowOk
public async void Check01UpdateSetupFlowOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
var service = new UpdateSetupServiceAsync<Tag, SimpleTagDtoAsync>(db);
var firstTag = db.Tags.First();
//ATTEMPT
var status = await service.GetOriginalAsync(firstTag.TagId);
//VERIFY
status.IsValid.ShouldEqual(true, status.Errors);
status.Result.FunctionsCalledCommaDelimited.ShouldEqual("DetailDtoFromDataInAsync,SetupSecondaryDataAsync");
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:16,代码来源:Test02UpdateServiceAsync.cs
示例15: ResetDatabaseToTestData
public static void ResetDatabaseToTestData(SampleWebAppDb context, string filepathOfXmlFile)
{
context.Posts.RemoveRange( context.Posts);
context.Tags.RemoveRange( context.Tags);
context.Blogs.RemoveRange( context.Blogs);
context.PostTagGrades.RemoveRange(context.PostTagGrades);
context.PostLinks.RemoveRange(context.PostLinks);
context.SaveChanges();
var loader = new LoadDbDataFromXml(filepathOfXmlFile);
context.Blogs.AddRange(loader.Bloggers); //note: The order things appear in the database are not obvious
//have to add these by hand
context.PostTagGrades.AddRange(loader.PostTagGrades);
context.SaveChanges();
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:16,代码来源:DataLayerInitialise.cs
示例16: Check02FillComputedNPostOk
public void Check02FillComputedNPostOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
const int numToCreate = 20;
var snap = new DbSnapShot(); //empty
//ATTEMPT
db.FillComputedNPost(numToCreate);
//VERIFY
snap.CheckSnapShot(db, numToCreate, numToCreate, 2, 2);
(db.Posts.Max(x => x.PostId) - db.Posts.Min(x => x.PostId)).ShouldEqual(numToCreate - 1); //check numbers are consecutive
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:16,代码来源:Perf01CheckHelpers.cs
示例17: Perf10CreateSetupServiceOk
public async void Perf10CreateSetupServiceOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
var service = new CreateSetupServiceAsync<Post, DetailPostDtoAsync>(db);
//ATTEMPT
var dto = await service.GetDtoAsync();
dto.LogSpecificName("End");
//VERIFY
foreach (var log in dto.LogOfCalls) { Console.WriteLine(log); }
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:16,代码来源:Perf08PostsViaDetailDtoAsync.cs
示例18: Check05ListEfDirectOk
public void Check05ListEfDirectOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
var timer = new Stopwatch();
timer.Start();
//ATTEMPT
db.ListEfDirect<Post>(0);
timer.Stop();
//VERIFY
Console.WriteLine("Ef operation took {0} ms",timer.ElapsedMilliseconds);
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:16,代码来源:Perf03EfPost.cs
示例19: Check01ValidateTagOk
public void Check01ValidateTagOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
var snap = new DbSnapShot(db);
//ATTEMPT
var dupTag = new Tag { Name = "non-duplicate slug", Slug = Guid.NewGuid().ToString("N") };
db.Tags.Add(dupTag);
var status = db.SaveChangesWithChecking();
//VERIFY
status.IsValid.ShouldEqual(true, status.Errors);
snap.CheckSnapShot(db, 0,0,0,1);
}
}
开发者ID:JonPSmith,项目名称:GenericServices,代码行数:17,代码来源:Tests02Validation.cs
示例20: Check03DetailDirectPostOk
public async Task Check03DetailDirectPostOk()
{
using (var db = new SampleWebAppDb())
{
//SETUP
var service = new DetailServiceAsync(db);
var firstPost = db.Posts.First();
//ATTEMPT
var status = await service.GetDetailAsync<Post>(firstPost.PostId);
//VERIFY
status.IsValid.ShouldEqual(true, status.Errors);
status.Result.PostId.ShouldEqual(firstPost.PostId);
status.Result.Title.ShouldEqual(firstPost.Title);
}
}
开发者ID:huoxudong125,项目名称:GenericServices,代码行数:17,代码来源:Test05CreateServicesAsync.cs
注:本文中的Tests.DataClasses.SampleWebAppDb类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论