public void Check11CreatePostOk() { using (var db = new SampleWebAppDb()) { //SETUP var snap = new DbSnapShot(db); var service = new CreateService <Post, DetailPostDto>(db); var setupService = new CreateSetupService <Post, DetailPostDto>(db); //ATTEMPT var dto = setupService.GetDto(); dto.Title = Guid.NewGuid().ToString(); dto.Content = "something to fill it as can't be empty"; dto.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D"); dto.UserChosenTags.FinalSelection = db.Tags.OrderBy(x => x.TagId).Take(2).ToList().Select(x => x.TagId.ToString("D")).ToArray(); var status = service.Create(dto); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); snap.CheckSnapShot(db, 1, 2); var post = db.Posts.Include(x => x.Tags).OrderByDescending(x => x.PostId).First(); post.Title.ShouldEqual(dto.Title); post.BlogId.ShouldEqual(db.Blogs.First().BlogId); CollectionAssert.AreEqual(db.Tags.OrderBy(x => x.TagId).Take(2).Select(x => x.TagId), post.Tags.Select(x => x.TagId)); } }
public void Perf11CreatePostOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateService <Post, DetailPostDto>(db); var setupService = new CreateSetupService <Post, DetailPostDto>(db); //ATTEMPT var dto = setupService.GetDto(); dto.Title = Guid.NewGuid().ToString(); dto.Content = "something to fill it as can't be empty"; dto.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D"); dto.UserChosenTags.FinalSelection = db.Tags.Take(2).ToList().Select(x => x.TagId.ToString("D")).ToArray(); var status = service.Create(dto); dto.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); foreach (var log in dto.LogOfCalls) { Console.WriteLine(log); } } }
public void Test05AddressCreateViaServiceOk() { using (var db = new AdventureWorksLt2012()) { //SETUP var setupService = new CreateSetupService(db); var service = new CreateService(db); var lastCustomer = db.Customers.AsNoTracking().Include(x => x.CustomerAddresses).OrderByDescending(x => x.CustomerID).First(); //ATTEMPT var dto = setupService.GetDto<CrudCustomerAddressDto>() .SetCustomerIdWhenCreatingNewEntry(lastCustomer.CustomerID); dto.AddressType = "Unit Test"; dto.Address.AddressLine1 = "Some street"; dto.Address.AddressLine2 = Guid.NewGuid().ToString("D"); dto.Address.City = "some town"; dto.Address.StateProvince = "a state"; dto.Address.CountryRegion = "the world"; dto.Address.PostalCode = "XXX 111"; var status = service.Create(dto); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); var newLastCustomer = db.Customers.AsNoTracking().Include( x => x.CustomerAddresses.Select( y => y.Address)).OrderByDescending(x => x.CustomerID).First(); newLastCustomer.CustomerAddresses.Count.ShouldEqual(lastCustomer.CustomerAddresses.Count+1); newLastCustomer.CustomerAddresses.OrderByDescending(x => x.AddressID).First().Address.AddressLine2.ShouldEqual(dto.Address.AddressLine2); } }
public void Test05AddressCreateViaServiceOk() { using (var db = new AdventureWorksLt2012()) { //SETUP var setupService = new CreateSetupService(db); var service = new CreateService(db); var lastCustomer = db.Customers.AsNoTracking().Include(x => x.CustomerAddresses).OrderByDescending(x => x.CustomerID).First(); //ATTEMPT var dto = setupService.GetDto <CrudCustomerAddressDto>() .SetCustomerIdWhenCreatingNewEntry(lastCustomer.CustomerID); dto.AddressType = "Unit Test"; dto.Address.AddressLine1 = "Some street"; dto.Address.AddressLine2 = Guid.NewGuid().ToString("D"); dto.Address.City = "some town"; dto.Address.StateProvince = "a state"; dto.Address.CountryRegion = "the world"; dto.Address.PostalCode = "XXX 111"; var status = service.Create(dto); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); var newLastCustomer = db.Customers.AsNoTracking().Include(x => x.CustomerAddresses.Select(y => y.Address)).OrderByDescending(x => x.CustomerID).First(); newLastCustomer.CustomerAddresses.Count.ShouldEqual(lastCustomer.CustomerAddresses.Count + 1); newLastCustomer.CustomerAddresses.OrderByDescending(x => x.AddressID).First().Address.AddressLine2.ShouldEqual(dto.Address.AddressLine2); } }
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"); } }
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"); } }
public void Check10CreateSetupDtoOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateSetupService(db); //ATTEMPT var result = service.GetDto <SimplePostDto>(); //VERIFY result.ShouldNotEqualNull(); } }
public void Check10CreateSetupServiceOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateSetupService <Post, DetailPostDto>(db); //ATTEMPT var dto = service.GetDto(); //VERIFY dto.Bloggers.KeyValueList.Count.ShouldEqual(db.Blogs.Count() + 1); dto.UserChosenTags.AllPossibleOptions.Count.ShouldEqual(db.Tags.Count()); } }
public void Perf10CreateSetupServiceOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateSetupService <Post, DetailPostDto>(db); //ATTEMPT var dto = service.GetDto(); dto.LogSpecificName("End"); //VERIFY foreach (var log in dto.LogOfCalls) { Console.WriteLine(log); } } }
public void FixtureSetup() { GenericServicesConfig.UseDelegateDecompilerWhereNeeded = true; //we create a SaleOrderHeader to use in these tests using (var db = new AdventureWorksLt2012()) { _customerId = db.Customers.OrderBy(x => x.CustomerID).First().CustomerID; _productToUse = db.Products.OrderByDescending(x => x.ListPrice).First(); var dto = new CreateSetupService(db).GetDto <NewOrderDto>(); dto.CustomerID = _customerId; dto.ShipMethod = "Unit Test"; dto.PurchaseOrderNumber = "Unit Test"; dto.AccountNumber = "Unit Test"; var service = new CreateService(db); var status = service.Create(dto); status.ShouldBeValid(); _salesOrderId = dto.SalesOrderID; } }
public void FixtureSetup() { GenericServicesConfig.UseDelegateDecompilerWhereNeeded = true; //we create a SaleOrderHeader to use in these tests using (var db = new AdventureWorksLt2012()) { _customerId = db.Customers.OrderBy(x => x.CustomerID).First().CustomerID; _productToUse = db.Products.OrderByDescending(x => x.ListPrice).First(); var dto = new CreateSetupService(db).GetDto<NewOrderDto>(); dto.CustomerID = _customerId; dto.ShipMethod = "Unit Test"; dto.PurchaseOrderNumber = "Unit Test"; dto.AccountNumber = "Unit Test"; var service = new CreateService(db); var status = service.Create(dto); status.ShouldBeValid(); _salesOrderId = dto.SalesOrderID; } }
public void Check13CreateFailRunsSetupSecondaryDataAgainOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateService <Post, DetailPostDto>(db); var setupService = new CreateSetupService <Post, DetailPostDto>(db); //ATTEMPT var dto = setupService.GetDto(); dto.Title = Guid.NewGuid().ToString(); dto.Content = null; //this will fail dto.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D"); dto.UserChosenTags.FinalSelection = db.Tags.Take(2).ToList().Select(x => x.TagId.ToString("D")).ToArray(); var status = service.Create(dto); //VERIFY status.IsValid.ShouldEqual(false); dto.Bloggers.KeyValueList.Count.ShouldEqual(db.Blogs.Count() + 1); dto.UserChosenTags.AllPossibleOptions.Count.ShouldEqual(db.Tags.Count()); } }
public void Check12CreatePostCopyBackKeyOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateService<Post, DetailPostDto>(db); var setupService = new CreateSetupService<Post, DetailPostDto>(db); //ATTEMPT var dto = setupService.GetDto(); dto.Title = Guid.NewGuid().ToString(); dto.Content = "something to fill it as can't be empty"; dto.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D"); dto.UserChosenTags.FinalSelection = db.Tags.OrderBy(x => x.TagId).Take(2).ToList().Select(x => x.TagId.ToString("D")).ToArray(); var status = service.Create(dto); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); var post = db.Posts.OrderByDescending(x => x.PostId).First(); dto.PostId.ShouldEqual(post.PostId); } }
public void Perf10CreateSetupServiceOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateSetupService<Post, DetailPostDto>(db); //ATTEMPT var dto = service.GetDto(); dto.LogSpecificName("End"); //VERIFY foreach (var log in dto.LogOfCalls) { Console.WriteLine(log); } } }
public void Perf11CreatePostOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateService<Post, DetailPostDto>(db); var setupService = new CreateSetupService<Post, DetailPostDto>(db); //ATTEMPT var dto = setupService.GetDto(); dto.Title = Guid.NewGuid().ToString(); dto.Content = "something to fill it as can't be empty"; dto.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D"); dto.UserChosenTags.FinalSelection = db.Tags.Take(2).ToList().Select(x => x.TagId.ToString("D")).ToArray(); var status = service.Create(dto); dto.LogSpecificName("End"); //VERIFY status.IsValid.ShouldEqual(true, status.Errors); foreach (var log in dto.LogOfCalls) { Console.WriteLine(log); } } }
public void Check10CreateSetupDtoOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateSetupService(db); //ATTEMPT var result = service.GetDto<SimplePostDto>(); //VERIFY result.ShouldNotEqualNull(); } }
public void Check13CreateFailRunsSetupSecondaryDataAgainOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateService<Post, DetailPostDto>(db); var setupService = new CreateSetupService<Post, DetailPostDto>(db); //ATTEMPT var dto = setupService.GetDto(); dto.Title = Guid.NewGuid().ToString(); dto.Content = null; //this will fail dto.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D"); dto.UserChosenTags.FinalSelection = db.Tags.Take(2).ToList().Select(x => x.TagId.ToString("D")).ToArray(); var status = service.Create(dto); //VERIFY status.IsValid.ShouldEqual(false); dto.Bloggers.KeyValueList.Count.ShouldEqual(db.Blogs.Count() + 1); dto.UserChosenTags.AllPossibleOptions.Count.ShouldEqual(db.Tags.Count()); } }
public void Check10CreateSetupServiceOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateSetupService<Post, DetailPostDto>(db); //ATTEMPT var dto = service.GetDto(); //VERIFY dto.Bloggers.KeyValueList.Count.ShouldEqual( db.Blogs.Count()+1); dto.UserChosenTags.AllPossibleOptions.Count.ShouldEqual( db.Tags.Count()); } }