public async void Check06UpdateWithListDtoOk() { using (var db = new SampleWebAppDb()) { //SETUP var snap = new DbSnapShot(db); var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First(); var service = new UpdateServiceAsync <Post, SimplePostDtoAsync>(db); var setupService = new UpdateSetupServiceAsync <Post, SimplePostDtoAsync>(db); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(firstPost.PostId); setupStatus.IsValid.ShouldEqual(true, setupStatus.Errors); setupStatus.Result.Title = Guid.NewGuid().ToString(); var status = await service.UpdateAsync(setupStatus.Result); setupStatus.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); status.SuccessMessage.ShouldEqual("Successfully updated Post."); snap.CheckSnapShot(db); } }
public async void Perf22UpdatePostAddTagOk() { int postId; using (var db = new SampleWebAppDb()) postId = db.Posts.Include(x => x.Tags).AsNoTracking().First().PostId; using (var db = new SampleWebAppDb()) { //SETUP var setupService = new UpdateSetupServiceAsync <Post, DetailPostDtoAsync>(db); var updateService = new UpdateServiceAsync <Post, DetailPostDtoAsync>(db); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(postId); setupStatus.Result.Title = Guid.NewGuid().ToString(); setupStatus.Result.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D"); setupStatus.Result.UserChosenTags.FinalSelection = db.Tags.Take(3).ToList().Select(x => x.TagId.ToString("D")).ToArray(); var status = await updateService.UpdateAsync(setupStatus.Result); setupStatus.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); foreach (var log in setupStatus.Result.LogOfCalls) { Console.WriteLine(log); } } }
public async void Check08UpdateWithListDtoCorrectOk() { using (var db = new SampleWebAppDb()) { //SETUP var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First(); var service = new UpdateServiceAsync <Post, SimplePostDtoAsync>(db); var setupService = new UpdateSetupServiceAsync <Post, SimplePostDtoAsync>(db); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(firstPost.PostId); setupStatus.IsValid.ShouldEqual(true, setupStatus.Errors); setupStatus.Result.Title = Guid.NewGuid().ToString(); var status = await service.UpdateAsync(setupStatus.Result); setupStatus.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); var updatedPost = db.Posts.Include(x => x.Tags).First(); updatedPost.Title.ShouldEqual(setupStatus.Result.Title); updatedPost.Blogger.ShouldNotEqualNull(); CollectionAssert.AreEqual(firstPost.Tags.Select(x => x.TagId), updatedPost.Tags.Select(x => x.TagId)); } }
public async void Perf06UpdateWithListDtoOk() { int postId; using (var db = new SampleWebAppDb()) postId = db.Posts.Include(x => x.Tags).AsNoTracking().First().PostId; using (var db = new SampleWebAppDb()) { //SETUP var service = new UpdateServiceAsync <Post, SimplePostDtoAsync>(db); var setupService = new UpdateSetupServiceAsync <Post, SimplePostDtoAsync>(db); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(postId); setupStatus.Result.Title = Guid.NewGuid().ToString(); var status = await service.UpdateAsync(setupStatus.Result); setupStatus.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); foreach (var log in setupStatus.Result.LogOfCalls) { Console.WriteLine(log); } } }
public async void Check22UpdatePostAddTagOk() { using (var db = new SampleWebAppDb()) { //SETUP var snap = new DbSnapShot(db); var setupService = new UpdateSetupServiceAsync <Post, DetailPostDtoAsync>(db); var updateService = new UpdateServiceAsync <Post, DetailPostDtoAsync>(db); var firstPost = db.Posts.First(); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(firstPost.PostId); setupStatus.IsValid.ShouldEqual(true, setupStatus.Errors); setupStatus.Result.Title = Guid.NewGuid().ToString(); setupStatus.Result.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D"); setupStatus.Result.UserChosenTags.FinalSelection = db.Tags.Take(3).ToList().Select(x => x.TagId.ToString("D")).ToArray(); var status = await updateService.UpdateAsync(setupStatus.Result); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); snap.CheckSnapShot(db, 0, 1); var post = db.Posts.Include(x => x.Tags).Single(x => x.PostId == firstPost.PostId); post.Title.ShouldEqual(setupStatus.Result.Title); post.BlogId.ShouldEqual(db.Blogs.First().BlogId); CollectionAssert.AreEquivalent(db.Tags.Take(3).Select(x => x.TagId), post.Tags.Select(x => x.TagId)); } }
public async void Check07UpdateWithListDtoCheckDateOk() { using (var db = new SampleWebAppDb()) { //SETUP var snap = new DbSnapShot(db); var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First(); var originalDateTime = firstPost.LastUpdated; Thread.Sleep(400); var service = new UpdateServiceAsync <Post, SimplePostDtoAsync>(db); var setupService = new UpdateSetupServiceAsync <Post, SimplePostDtoAsync>(db); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(firstPost.PostId); setupStatus.IsValid.ShouldEqual(true, setupStatus.Errors); setupStatus.Result.Title = Guid.NewGuid().ToString(); setupStatus.Result.LastUpdated = new DateTime(); var status = await service.UpdateAsync(setupStatus.Result); setupStatus.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); status.SuccessMessage.ShouldEqual("Successfully updated Post."); snap.CheckSnapShot(db); Assert.GreaterOrEqual(db.Posts.First().LastUpdated.Subtract(originalDateTime).Milliseconds, 400); } }
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"); } }
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"); } }
public async void Check05UpdateSetupNotFoundBad() { using (var db = new SampleWebAppDb()) { //SETUP var service = new UpdateSetupServiceAsync <Post, SimplePostDtoAsync>(db); //ATTEMPT var status = await service.GetOriginalAsync(0); //VERIFY status.IsValid.ShouldEqual(false); status.Errors.Count.ShouldEqual(1); status.Errors[0].ErrorMessage.ShouldEqual("We could not find an entry using that filter. Has it been deleted by someone else?"); status.Result.ShouldNotEqualNull(); } }
public async void Check16UpdateSetupServiceOk() { using (var db = new SampleWebAppDb()) { //SETUP var setupService = new UpdateSetupServiceAsync <Post, DetailPostDtoAsync>(db); var firstPost = db.Posts.First(); //ATTEMPT var status = await setupService.GetOriginalAsync(firstPost.PostId); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); status.Result.Bloggers.KeyValueList.Count.ShouldEqual(db.Blogs.Count() + 1); status.Result.UserChosenTags.AllPossibleOptions.Count.ShouldEqual(db.Tags.Count()); } }
public async Task Check05UpdateSetupServicePost() { using (var db = new SampleWebAppDb()) { //SETUP var firstPostUntracked = db.Posts.AsNoTracking().First(); var service = new UpdateSetupServiceAsync(db); //ATTEMPT var status = await service.GetOriginalAsync <Post>(firstPostUntracked.PostId); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); status.Result.ShouldNotEqualNull(); status.Result.PostId.ShouldEqual(firstPostUntracked.PostId); } }
public static async Task UpdatePostGSelectViaDtoAsync(this SampleWebAppDb db, int postId) { var setupService = new UpdateSetupServiceAsync(db); var setupStatus = await setupService.GetOriginalAsync <DetailPostDtoAsync>(postId); setupStatus.IsValid.ShouldEqual(true, setupStatus.Errors); var guidString = Guid.NewGuid().ToString("N"); setupStatus.Result.Title = guidString; setupStatus.Result.Content = guidString; setupStatus.Result.Tags = new Collection <Tag> { db.Tags.First() }; var service = new UpdateServiceAsync(db); var status = await service.UpdateAsync(setupStatus.Result); status.IsValid.ShouldEqual(true, status.Errors); }
public async void Check05UpdateSetupOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new UpdateSetupServiceAsync <Post, SimplePostDtoAsync>(db); var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First(); //ATTEMPT var status = await service.GetOriginalAsync(firstPost.PostId); status.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); status.Result.PostId.ShouldEqual(firstPost.PostId); status.Result.BloggerName.ShouldEqual(firstPost.Blogger.Name); status.Result.Title.ShouldEqual(firstPost.Title); CollectionAssert.AreEqual(firstPost.Tags.Select(x => x.TagId), status.Result.Tags.Select(x => x.TagId)); } }
public async void Perf05UpdateSetupOk() { int postId; using (var db = new SampleWebAppDb()) postId = db.Posts.Include(x => x.Tags).AsNoTracking().First().PostId; using (var db = new SampleWebAppDb()) { //SETUP var service = new UpdateSetupServiceAsync <Post, SimplePostDtoAsync>(db); //ATTEMPT var status = await service.GetOriginalAsync(postId); status.Result.LogSpecificName("End"); //VERIFY foreach (var log in status.Result.LogOfCalls) { Console.WriteLine(log); } } }
public async void Check09UpdateWithListDtoBad() { using (var db = new SampleWebAppDb()) { //SETUP var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First(); var service = new UpdateServiceAsync <Post, SimplePostDtoAsync>(db); var setupService = new UpdateSetupServiceAsync <Post, SimplePostDtoAsync>(db); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(firstPost.PostId); setupStatus.IsValid.ShouldEqual(true, setupStatus.Errors); setupStatus.Result.Title = "Can't I ask a question?"; var status = await service.UpdateAsync(setupStatus.Result); setupStatus.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(false); status.Errors.Count.ShouldEqual(1); status.Errors[0].ErrorMessage.ShouldEqual("Sorry, but you can't ask a question, i.e. the title can't end with '?'."); } }
public async void Check25UpdatePostFailRunsSetupSecondaryDataAgainOk() { using (var db = new SampleWebAppDb()) { //SETUP var setupService = new UpdateSetupServiceAsync <Post, DetailPostDtoAsync>(db); var updateService = new UpdateServiceAsync <Post, DetailPostDtoAsync>(db); var firstPost = db.Posts.First(); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(firstPost.PostId); setupStatus.IsValid.ShouldEqual(true, setupStatus.Errors); setupStatus.Result.Title = null; //that will fail setupStatus.Result.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D"); setupStatus.Result.UserChosenTags.FinalSelection = db.Tags.Take(3).ToList().Select(x => x.TagId.ToString("D")).ToArray(); var status = await updateService.UpdateAsync(setupStatus.Result); //VERIFY status.IsValid.ShouldEqual(false); setupStatus.Result.Bloggers.KeyValueList.Count.ShouldEqual(db.Blogs.Count() + 1); setupStatus.Result.UserChosenTags.AllPossibleOptions.Count.ShouldEqual(db.Tags.Count()); } }
public async void Check05UpdateSetupNotFoundBad() { using (var db = new SampleWebAppDb()) { //SETUP var service = new UpdateSetupServiceAsync<Post, SimplePostDtoAsync>(db); //ATTEMPT var status = await service.GetOriginalAsync(0); //VERIFY status.IsValid.ShouldEqual(false); status.Errors.Count.ShouldEqual(1); status.Errors[0].ErrorMessage.ShouldEqual("We could not find an entry using that filter. Has it been deleted by someone else?"); status.Result.ShouldNotEqualNull(); } }
public async void Perf06UpdateWithListDtoOk() { int postId; using (var db = new SampleWebAppDb()) postId = db.Posts.Include(x => x.Tags).AsNoTracking().First().PostId; using (var db = new SampleWebAppDb()) { //SETUP var service = new UpdateServiceAsync<Post, SimplePostDtoAsync>(db); var setupService = new UpdateSetupServiceAsync<Post, SimplePostDtoAsync>(db); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(postId); setupStatus.Result.Title = Guid.NewGuid().ToString(); var status = await service.UpdateAsync(setupStatus.Result); setupStatus.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); foreach (var log in setupStatus.Result.LogOfCalls) { Console.WriteLine(log); } } }
public async void Perf22UpdatePostAddTagOk() { int postId; using (var db = new SampleWebAppDb()) postId = db.Posts.Include(x => x.Tags).AsNoTracking().First().PostId; using (var db = new SampleWebAppDb()) { //SETUP var setupService = new UpdateSetupServiceAsync<Post, DetailPostDtoAsync>(db); var updateService = new UpdateServiceAsync<Post, DetailPostDtoAsync>(db); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(postId); setupStatus.Result.Title = Guid.NewGuid().ToString(); setupStatus.Result.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D"); setupStatus.Result.UserChosenTags.FinalSelection = db.Tags.Take(3).ToList().Select(x => x.TagId.ToString("D")).ToArray(); var status = await updateService.UpdateAsync(setupStatus.Result); setupStatus.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); foreach (var log in setupStatus.Result.LogOfCalls) { Console.WriteLine(log); } } }
public async void Perf16UpdateSetupServiceOk() { int postId; using (var db = new SampleWebAppDb()) postId = db.Posts.Include(x => x.Tags).AsNoTracking().First().PostId; using (var db = new SampleWebAppDb()) { //SETUP var setupService = new UpdateSetupServiceAsync<Post, DetailPostDtoAsync>(db); //ATTEMPT var status = await setupService.GetOriginalAsync(postId); status.Result.LogSpecificName("End"); //VERIFY foreach (var log in status.Result.LogOfCalls) { Console.WriteLine(log); } } }
public async Task Check05UpdateSetupServicePost() { using (var db = new SampleWebAppDb()) { //SETUP var firstPostUntracked = db.Posts.AsNoTracking().First(); var service = new UpdateSetupServiceAsync(db); //ATTEMPT var status = await service.GetOriginalAsync<Post>(firstPostUntracked.PostId); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); status.Result.ShouldNotEqualNull(); status.Result.PostId.ShouldEqual(firstPostUntracked.PostId); } }
public async void Check07UpdateWithListDtoCheckDateOk() { using (var db = new SampleWebAppDb()) { //SETUP var snap = new DbSnapShot(db); var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First(); var originalDateTime = firstPost.LastUpdated; Thread.Sleep(400); var service = new UpdateServiceAsync<Post, SimplePostDtoAsync>(db); var setupService = new UpdateSetupServiceAsync<Post, SimplePostDtoAsync>(db); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(firstPost.PostId); setupStatus.IsValid.ShouldEqual(true, setupStatus.Errors); setupStatus.Result.Title = Guid.NewGuid().ToString(); setupStatus.Result.LastUpdated = new DateTime(); var status = await service.UpdateAsync(setupStatus.Result); setupStatus.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); status.SuccessMessage.ShouldEqual("Successfully updated Post."); snap.CheckSnapShot(db); Assert.GreaterOrEqual(db.Posts.First().LastUpdated.Subtract(originalDateTime).Milliseconds, 400); } }
public async void Check09UpdateWithListDtoBad() { using (var db = new SampleWebAppDb()) { //SETUP var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First(); var service = new UpdateServiceAsync<Post, SimplePostDtoAsync>(db); var setupService = new UpdateSetupServiceAsync<Post, SimplePostDtoAsync>(db); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(firstPost.PostId); setupStatus.IsValid.ShouldEqual(true, setupStatus.Errors); setupStatus.Result.Title = "Can't I ask a question?"; var status = await service.UpdateAsync(setupStatus.Result); setupStatus.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(false); status.Errors.Count.ShouldEqual(1); status.Errors[0].ErrorMessage.ShouldEqual("Sorry, but you can't ask a question, i.e. the title can't end with '?'."); } }
public async void Check05UpdateSetupOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new UpdateSetupServiceAsync<Post, SimplePostDtoAsync>(db); var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First(); //ATTEMPT var status = await service.GetOriginalAsync(firstPost.PostId); status.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); status.Result.PostId.ShouldEqual(firstPost.PostId); status.Result.BloggerName.ShouldEqual(firstPost.Blogger.Name); status.Result.Title.ShouldEqual(firstPost.Title); CollectionAssert.AreEqual(firstPost.Tags.Select(x => x.TagId), status.Result.Tags.Select(x => x.TagId)); } }
public async void Check06UpdateWithListDtoOk() { using (var db = new SampleWebAppDb()) { //SETUP var snap = new DbSnapShot(db); var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First(); var service = new UpdateServiceAsync<Post, SimplePostDtoAsync>(db); var setupService = new UpdateSetupServiceAsync<Post, SimplePostDtoAsync>(db); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(firstPost.PostId); setupStatus.IsValid.ShouldEqual(true, setupStatus.Errors); setupStatus.Result.Title = Guid.NewGuid().ToString(); var status = await service.UpdateAsync(setupStatus.Result); setupStatus.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); status.SuccessMessage.ShouldEqual("Successfully updated Post."); snap.CheckSnapShot(db); } }
public async void Check08UpdateWithListDtoCorrectOk() { using (var db = new SampleWebAppDb()) { //SETUP var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First(); var service = new UpdateServiceAsync<Post, SimplePostDtoAsync>(db); var setupService = new UpdateSetupServiceAsync<Post, SimplePostDtoAsync>(db); //ATTEMPT var setupStatus = await setupService.GetOriginalAsync(firstPost.PostId); setupStatus.IsValid.ShouldEqual(true, setupStatus.Errors); setupStatus.Result.Title = Guid.NewGuid().ToString(); var status = await service.UpdateAsync(setupStatus.Result); setupStatus.Result.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); var updatedPost = db.Posts.Include(x => x.Tags).First(); updatedPost.Title.ShouldEqual(setupStatus.Result.Title); updatedPost.Blogger.ShouldNotEqualNull(); CollectionAssert.AreEqual(firstPost.Tags.Select(x => x.TagId), updatedPost.Tags.Select(x => x.TagId)); } }