public async void Check01CreateDataFromDtoAsyncOk() { //SETUP var dto = new SimplePostDtoAsync { PostId = 123, BloggerName = "This should not be copied", Title = "Should copy this title", LastUpdated = new DateTime(2000, 1, 1), Tags = new Collection<Tag> { new Tag { Name = "Should not copy this", Slug = "No" } } }; var status = await dto.CreateDataFromDtoAsync(null, dto); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); status.Result.PostId.ShouldEqual(123); status.Result.Title.ShouldEqual("Should copy this title"); status.Result.Blogger.ShouldEqual(null); status.Result.BlogId.ShouldEqual(0); status.Result.Content.ShouldEqual(null); status.Result.Tags.ShouldEqual(null); }
public async void Check01CreateDataFromDtoAsyncOk() { //SETUP var dto = new SimplePostDtoAsync { PostId = 123, BloggerName = "This should not be copied", Title = "Should copy this title", LastUpdated = new DateTime(2000, 1, 1), Tags = new Collection <Tag> { new Tag { Name = "Should not copy this", Slug = "No" } } }; var status = await dto.CreateDataFromDtoAsync(null, dto); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); status.Result.PostId.ShouldEqual(123); status.Result.Title.ShouldEqual("Should copy this title"); status.Result.Blogger.ShouldEqual(null); status.Result.BlogId.ShouldEqual(0); status.Result.Content.ShouldEqual(null); status.Result.Tags.ShouldEqual(null); }
public async void Check02UpdateDataFromDtoAsyncOk() { //SETUP var dto = new SimplePostDtoAsync { PostId = 123, BloggerName = "This should not be copied", Title = "Should copy this title", LastUpdated = new DateTime(2000, 1, 1), Tags = new Collection <Tag> { new Tag { Name = "Should not copy this", Slug = "No" } } }; //ATTEMPT var newData = new Post { Blogger = new Blog { Name = "Original Blog Name" }, BlogId = 777, Content = "Original Content", Tags = new Collection <Tag> { new Tag { Name = "Original Tag name", Slug = "Yes" } } }; var status = await dto.UpdateDataFromDtoAsync(null, dto, newData); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); newData.PostId.ShouldEqual(123); newData.Title.ShouldEqual("Should copy this title"); newData.Blogger.Name.ShouldEqual("Original Blog Name"); newData.BlogId.ShouldEqual(777); newData.Content.ShouldEqual("Original Content"); newData.Tags.Count.ShouldEqual(1); newData.Tags.First().Name.ShouldEqual("Original Tag name"); }
public async void Check10CreateWithListDtoBad() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateServiceAsync <Post, SimplePostDtoAsync>(db); //ATTEMPT var dto = new SimplePostDtoAsync(); var status = await service.CreateAsync(dto); dto.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(false); status.Errors.Count.ShouldEqual(1); status.Errors[0].ErrorMessage.ShouldEqual("Create of a new Post is not supported in this mode."); } }
public async void Check02UpdateDataFromDtoAsyncOk() { //SETUP var dto = new SimplePostDtoAsync { PostId = 123, BloggerName = "This should not be copied", Title = "Should copy this title", LastUpdated = new DateTime(2000, 1, 1), Tags = new Collection<Tag> { new Tag { Name = "Should not copy this", Slug = "No" } } }; //ATTEMPT var newData = new Post { Blogger = new Blog { Name = "Original Blog Name" }, BlogId = 777, Content = "Original Content", Tags = new Collection<Tag> { new Tag { Name = "Original Tag name", Slug = "Yes" } } }; var status = await dto.UpdateDataFromDtoAsync(null, dto, newData); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); newData.PostId.ShouldEqual(123); newData.Title.ShouldEqual("Should copy this title"); newData.Blogger.Name.ShouldEqual("Original Blog Name"); newData.BlogId.ShouldEqual(777); newData.Content.ShouldEqual("Original Content"); newData.Tags.Count.ShouldEqual(1); newData.Tags.First().Name.ShouldEqual("Original Tag name"); }
public async void Check10CreateWithListDtoBad() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateServiceAsync<Post, SimplePostDtoAsync>(db); //ATTEMPT var dto = new SimplePostDtoAsync(); var status = await service.CreateAsync(dto); dto.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(false); status.Errors.Count.ShouldEqual(1); status.Errors[0].ErrorMessage.ShouldEqual("Create of a new Post is not supported in this mode."); } }