private static async Task InitializeDatabaseAsync() { using (var context = new OrderManagementContext2()) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var emma = new Customer { Id = 1, FirstName = "Emma", LastName = "Johnson" }; var marc = new Customer { Id = 2, FirstName = "Marc", LastName = "Milston" }; var camera = new Order { Id = 1, Description = "Camera", DeliveryAddress = "Address 1", Price = 550 }; var wallet = new Order { Id = 2, Description = "Wallet", DeliveryAddress = "Address 2", Price = 10 }; var customerRepository = new CustomerRepository(context); var orderRepository = new OrderRepository(context); customerRepository.Add(emma); customerRepository.Add(marc); orderRepository.Add(camera); orderRepository.Add(wallet); await orderRepository.UnitOfWork.SaveChangesAndDispatchDomainEventsAsync(); } }
private void InitializeDatabase() { _context.Database.EnsureDeleted(); _context.Database.EnsureCreated(); var emma = new Customer { Id = 1, FirstName = "Emma", LastName = "Johnson" }; var marc = new Customer { Id = 2, FirstName = "Marc", LastName = "Milston" }; _customerRepository.Add(emma); _customerRepository.Add(marc); var camera = new Order { Id = 1, Description = "Camera", DeliveryAddress = "Address 1", Price = 550 }; var wallet = new Order { Id = 2, Description = "Wallet", DeliveryAddress = "Address 2", Price = 10 }; _orderRepository.Add(camera); _orderRepository.Add(wallet); _unitOfWork.Commit(); }
public void OrderShouldbeCreated() { var response = orderRepository.Add(order); // assert Assert.IsNotNull(response.Id); }
private void InitOrders(OrderRepository orderRepo, CarRepository carsRepo, LocationRepository locRepo) { var date = DateTime.Now; orderRepo.Add(new Order { CarID = 2, DateStart = date.AddDays(2), DateEnd = date.AddDays(5), PointStartID = 1, PointEndID = 2 }); orderRepo.Add(new Order { CarID = 3, DateStart = date.AddDays(3), DateEnd = date.AddDays(5), PointStartID = 2, PointEndID = 2 }); orderRepo.Add(new Order { CarID = 4, DateStart = date.AddDays(4), DateEnd = date.AddDays(5), PointStartID = 2, PointEndID = 2 }); }
private void InitializeDatabase() { using (var context = new OrderManagementContext()) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var emma = new Customer { Id = 1, FirstName = "Emma", LastName = "Johnson" }; var marc = new Customer { Id = 2, FirstName = "Marc", LastName = "Milston" }; var camera = new Order { Id = 1, Description = "Camera", DeliveryAddress = "Address 1", Price = 550 }; var wallet = new Order { Id = 2, Description = "Wallet", DeliveryAddress = "Address 2", Price = 10 }; var customerRepository = new CustomerRepository(context); customerRepository.Add(emma); customerRepository.Add(marc); customerRepository.SaveChanges(); var orderRepository = new OrderRepository(context); orderRepository.Add(camera); orderRepository.Add(wallet); orderRepository.SaveChanges(); } }
public ActionResult Checkout(CheckoutModel model) { ValidateModel(model); var cart = new Cart(GetCart()); var emailModel = new CartOrderFromEmailSendModel() { Cart = cart, UserData = model }; var message = RenderViewToString(this.ControllerContext, "/Views/Cart/_PartialNewOrderFromEmailSend.cshtml", emailModel, true); var entity = new Order() { Adress = model.Adress, Email = model.Email, Phone = model.Phone, TypeProgressOrder = (int)Entity.Enumerable.TypeProgressOrder.SimplePrice, UserName = model.Name, Products = cart.Lines.Select(i => new OrderProduct() { Product = new Product() { Id = i.Product.Id }, Quantity = i.Quantity }).ToList(), DateOrder = DateTime.Now }; MailerMessage mailerMessage = new MailerMessage(); mailerMessage.Body = message; mailerMessage.Subject = "Заказ с сайта Пирамида строй"; mailerMessage.To = _feedBackEmailRepository.GetAll().Select(i => i.Email).ToList(); mailerMessage.SenderName = "Pyramid"; if (mailerMessage.To.Count > 0) { Mailer.Send(mailerMessage); } GetCart().Clear(); bool flagErr = false; try { _orederRepository.Add(entity); } catch (Exception) { flagErr = true; } ViewBag.IsAddedOrder = !flagErr; ViewBag.MetaTitle = "Подтверждение заказа"; return(View("ResultCheckout", cart)); }
public static void SeedData() { // For some reason EF doesn't like this // if a command runs that doesn't update a row // EF will completely error out and stop all transactionsg //_context.Database.ExecuteSqlRaw("ALTER INDEX IX_Toppings_ToppingType on dbo.Toppings SET ( IGNORE_DUP_KEY = ON )"); //_context.Database.ExecuteSqlRaw("ALTER INDEX IX_Crusts_CrustType on dbo.Crusts SET ( IGNORE_DUP_KEY = ON )"); //_context.Database.ExecuteSqlRaw("ALTER INDEX IX_Stores_Name on dbo.Stores SET ( IGNORE_DUP_KEY = ON )"); //_context.Database.ExecuteSqlRaw("ALTER INDEX IX_Sizes_SizeType on dbo.Sizes SET ( IGNORE_DUP_KEY = ON )"); //_context.Database.ExecuteSqlRaw("ALTER INDEX IX_Customers_Name on dbo.Customers SET ( IGNORE_DUP_KEY = ON )"); OrderRepository orderRepository = new OrderRepository(DbContextSingleton.Instance.Context); Customer cust = new Customer("Nick"); AStore store = new NewYorkStore(); store.Name = "Test New York Store"; Order order = new Order(); order.Store = store; order.Customer = cust; APizza pizza = new CustomPizza(); pizza.Crust = new DeepDishCrust(); pizza.Size = new SmallSize(); pizza.Toppings = new List <Topping>(); pizza.Toppings.Add(new BaconTopping()); pizza.Toppings.Add(new PepperoniTopping()); order.Pizzas = new List <APizza>() { pizza, new VeganPizza(), new MeatPizza() }; orderRepository.Add(order); pizza.Size = new LargeSize(); pizza.Toppings = new List <Topping>(); pizza.Toppings.Add(new BaconTopping()); pizza.Toppings.Add(new OnionTopping()); order.Store.Name = "Test Store 2"; orderRepository.Add(order); /* * public Store Store { get; set; } * public Customer Customer { get; set; } * public List<Pizza> Pizzas { get; set; } * public decimal TotalPrice { get; set; } * public DateTime OrderTime { get; set; } * */ }
public async Task List_Only_Current_Month_Orders() { var options = new DbContextOptionsBuilder <CashbackContext>() .UseInMemoryDatabase(databaseName: $"Teste_OrderService{Guid.NewGuid()}") .Options; var retailerCpf = new Cpf("408.477.340-99"); var orderReferenceDate = DateTime.Now; using (var context = new CashbackContext(options)) { var retailerRepository = new RetailerRepository(context); await retailerRepository.Add(new Domain.Retailers.Retailer(new Domain.Dtos.Retailers.CreateRetailerDto() { CPF = retailerCpf.Value, Name = "Test name", Email = "*****@*****.**", Password = "******" })); var retailer = await retailerRepository.Find(retailerCpf); var orderRepository = new OrderRepository(context); await orderRepository.Add(new Order("ABC", 20, orderReferenceDate.AddMonths(-5), retailer)); await orderRepository.Add(new Order("DEF", 30, orderReferenceDate, retailer)); await orderRepository.Add(new Order("GHI", 40, orderReferenceDate.AddMonths(5), retailer)); } using (var context = new CashbackContext(options)) { var retailerRepository = new RetailerRepository(context); var orderRepository = new OrderRepository(context); var orderService = new OrderService( retailerRepository, orderRepository, new CashbackService(), new Mock <ILogger <OrderService> >().Object); var orders = await orderService.ListCurrentMonth(retailerCpf.Value); Assert.Single(orders); Assert.Equal("DEF", orders.First().Code); Assert.Equal(30, orders.First().Value); Assert.Equal(OrderStatus.Validating, orders.First().Status); Assert.Equal(orderReferenceDate, orders.First().ReferenceDate); Assert.Equal(10, orders.First().CashbackPercent); Assert.Equal(3, orders.First().CashbackValue); } }
public void Orders_Repository_Add_ShouldBeOk() { //Action var orderRegistered = _repository.Add(_order); //Verify orderRegistered.Should().NotBeNull(); orderRegistered.Id.Should().NotBe(0); var expectedCustomer = _ctx.Orders.Find(orderRegistered.Id); expectedCustomer.Should().NotBeNull(); }
public void Add_WhenCalled_ReturnsObjWithId() { // Act var obj = _repository.Add(new Order() { Id = 0, Price = 1234, CreatedDate = DateTime.Now }); // Assert Assert.IsType <Order>(obj); Assert.True(obj.Id > 0); }
public void AddTest() { Order order = new Order { Id = "0", AcceptanceDate = new DateTime(2020, 01, 05), Client = new Customer(), DeliveringDate = new DateTime(), Entries = new List <Entry>(), Status = Status.IN_PROGRESS }; OrderRepository.Add(order); Assert.IsNotNull(OrderRepository.Get("0")); }
public void adding_an_order_should_succeed_v2() { //Arrange IOrderRepository orderRepository = new OrderRepository(); var fixture = new Fixture(); var cart = fixture.Create <Cart>(); var product = fixture.Create <Product>(); var user = fixture.Create <User>(); cart.AddProduct(product); var order = new Order(user, cart); //Stub - klasa tworząca dane testowe //Act orderRepository.Add(order); //Assert var expectedOrder = orderRepository.Get(order.Id); expectedOrder.ShouldBeEquivalentTo(order); var orders = orderRepository.Browse(order.UserId); orders.Should().NotBeEmpty(); orders.Should().ContainSingle(); orders.Should().Contain(o => o.Id == order.Id); }
public async Task <IActionResult> Create(Order order) { try { order.CreatedAt = DateTime.Now; _repo.Add(order); if (await _repo.SaveChangesAsync()) { return(Created($"/api/order/{order.Id}", order)); } } catch (System.Exception ex) { return(this.StatusCode ( StatusCodes.Status500InternalServerError, "Erro ao inserir as informações no banco de dados\n" + ex.InnerException )); } return(BadRequest()); }
public void AddNewTest() { var orderExp = new Order { OrderDate = null }; var details = new List <OrderInfo>(); var quesoCabrales = new OrderInfo { ProductId = 11, ProductName = "Queso Cabrales", Quantity = 12, UnitPrice = 14.0000m }; details.Add(quesoCabrales); var singaporean = new OrderInfo { ProductId = 42, ProductName = "Singaporean Hokkien Fried Mee", Quantity = 10, UnitPrice = 9.8000m }; details.Add(singaporean); orderExp.OrderDetails = details; var orderReal = repository.Add(orderExp); Assert.AreEqual(orderExp, orderReal); }
public String AddBooking() { String idParam = Request.Params["pcid"]; String useridParam = Request.Params["userid"]; String date = Request.Params["date"]; String time = Request.Params["time"]; String duration = Request.Params["duration"]; int pcid = int.Parse(idParam); int userid = int.Parse(useridParam); DateTime newDate = DateTime.ParseExact(date + " " + time, "dd/MM/yyyy HH:mm", null); int intDuration = int.Parse(duration); OrderService orderService = new OrderService(); OrderStatus orderStatus = orderService.isCanOrder(pcid, newDate, intDuration, userid); if (orderStatus.status == OrderStatusCode.FAIL) { return orderStatus.message; } Order order = new Order(); order.PCID = pcid; order.UserID = userid; order.StartTime = newDate; order.Duration = intDuration; order.OrderStatus = 0; // tru balance IRepository<Order> repository = new OrderRepository(); repository.Add(order); return "true"; }
public async Task <ActionResult> CreateOrder(CarOrderViewModel carOrderViewModel) { var user = await TheUserManager.FindByNameAsync(HttpContext.User.Identity.Name); if (user == null) { throw new Exception("user doesnt exist"); } var order = new Order { CarId = carOrderViewModel.CarId, Driver = carOrderViewModel.Driver, PassportId = carOrderViewModel.PassportId, ReturnDate = carOrderViewModel.ReturnDate, Status = Status.NotPaid, ApplicationUserId = user.Id }; orderRepository.Add(order); user.Orders.Add(order); //await TheUserManager.UpdateAsync(user); orderRepository.SaveChanges(); return(RedirectToAction("MyOrders")); }
public void CanAddOrder() { var repo = new OrderRepository(); DateTime orderDate = new DateTime(2015, 05, 03); Order orderToAdd = new Order() { OrderNumber = 3, CustomerName = "Wise", State = "OH", TaxRate = 6.25M, ProductType = "Wood", Area = 100.00M, CostPerSquareFoot = 5.15M, LaborCostPerSquareFoot = 4.75M, MaterialCost = 515.00M, LaborCost = 475.00M, Tax = 61.88M, Total = 1051.88M }; //public void OverwriteFile(List<Order> orders, DateTime orderDate) var ordersList = repo.LoadOrders(orderDate); repo.Add(orderToAdd, orderDate); //repo.OverwriteFile(ordersList, orderDate); Assert.AreEqual(3, ordersList[ordersList.Count - 1].OrderNumber); Assert.AreEqual("Wise", ordersList[ordersList.Count - 1].CustomerName); }
public Result <dynamic> Add(string orderNo, int memberId, int orderFee) { try { OrderRepository.Add(new OrderModel() { OrderNo = orderNo, MemberId = memberId, OrderFee = orderFee, OrderStatus = 0, NotifyTime = DateTime.Now, CreateTime = DateTime.Now }); } catch (Exception ex) { return(new Result <dynamic>() { Code = ResultCode.Error, Message = "生成订单失败" }); } return(new Result <dynamic>() { Code = ResultCode.Success, Message = "生成订单成功" }); }
public void Add_100_OrderItem() { var dbContextScopeFactory = new DbContextScopeFactory(); var ambientDbContextLocator = new AmbientDbContextLocator(); var orderFactory = new OrderFactory(); using (var dbContextScope = dbContextScopeFactory.Create()) { var personRepository = new PersonRepository(ambientDbContextLocator); var orderRepository = new OrderRepository(ambientDbContextLocator); var person = personRepository.GetByName("ding.p"); var order = orderFactory.CreateOrder(person); orderRepository.Add(order); for (int i = 0; i < 100; i++) { var orderItem = order.CreateItem("A-" + i); order.OrderLine.Add(orderItem); } dbContextScope.SaveChanges(); } }
public void OrderRepositoryRemoveItemDeleteIt() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); var orderRepository = new OrderRepository(unitOfWork); var customer = customerRepository.Get(new Guid("0CD6618A-9C8E-4D79-9C6B-4AA69CF18AE6")); var order = OrderFactory.CreateOrder( customer, "shipping name", "shipping city", "shipping address", "shipping zip code"); order.GenerateNewIdentity(); orderRepository.Add(order); orderRepository.UnitOfWork.Commit(); //Act orderRepository.Remove(order); unitOfWork.Commit(); }
public void Get_Returns_Order_When_Found() { var databaseName = Guid.NewGuid().ToString(); using (var context = DbContextFactory.CreateInstance(databaseName)) { //Arrange var productRepository = new ProductRepository(context); var articleRepository = new ArticleRepository(context); var customerRepository = new CustomerRepository(context); var orderRepository = new OrderRepository(context); var orderLineRepository = new OrderLineRepository(context); var product = ProductFactory.CreateValidEntity(); productRepository.Add(product); var article = ArticleFactory.CreateValidEntity(product); articleRepository.Add(article); var customer = CustomerFactory.CreateValidEntity(); customerRepository.Add(customer); var order = OrderFactory.CreateValidEntity(customer); orderRepository.Add(order); var orderLineToAdd = OrderLineFactory.CreateValidEntity(order, article); orderLineRepository.Add(orderLineToAdd); context.SaveChanges(); //Act var orderLine = orderLineRepository.Get(orderLineToAdd.Id); //Assert Assert.IsNotNull(orderLine); } }
public void Add_Returns_1_When_Adding_Valid_Order() { var databaseName = Guid.NewGuid().ToString(); using (var context = DbContextFactory.CreateInstance(databaseName)) { //Arrange var productRepository = new ProductRepository(context); var articleRepository = new ArticleRepository(context); var customerRepository = new CustomerRepository(context); var orderRepository = new OrderRepository(context); var orderLineRepository = new OrderLineRepository(context); //Act var product = ProductFactory.CreateValidEntity(); productRepository.Add(product); var article = ArticleFactory.CreateValidEntity(product); articleRepository.Add(article); var customer = CustomerFactory.CreateValidEntity(); customerRepository.Add(customer); var order = OrderFactory.CreateValidEntity(customer); orderRepository.Add(order); var orderLine = OrderLineFactory.CreateValidEntity(order, article); orderLineRepository.Add(orderLine); var result = context.SaveChanges(); //Assert Assert.AreEqual(5, result); //Because we added five entities } }
public ActionResult SiparisiOnayla(Order item) { if (item.RequiredDate < DateTime.Now) { ViewBag.Tarih = "Geçmiş bir tarih seçemezsiniz"; return(View()); } else if ((item.RequiredDate - DateTime.Now).Value.Days <= 2) { ViewBag.Tarih = "2 gün veya daha az sürede bir gönderim maalesef yapamayız"; return(View()); } item.AppUserID = (Session["member"] as AppUser).ID; orep.Add(item); Cart sepet = Session["scart"] as Cart; string gonderilecekMesaj = null; foreach (CartItem urun in sepet.Sepetim) { OrderDetail od = new OrderDetail(); od.OrderID = item.ID; od.ProductID = urun.ID; od.TotalPrice = urun.SubTotal; od.Quantity = urun.Amount; odrep.Add(od); gonderilecekMesaj += $"Urun:{urun.Name}, Adedi:{urun.Amount}, Toplam Fiyatı:{urun.SubTotal}\n"; } gonderilecekMesaj += $"Ödemeniz gereken toplam tutar {sepet.TotalPrice}"; Session.Remove("scart"); TempData["satıs"] = "Siparişiniz bize ulaşmıştır. Detaylı liste mail adresinize gönderildi..."; MailSender.Send((Session["member"] as AppUser).Email, body: gonderilecekMesaj, subject: "Sipariş Detay!"); return(RedirectToAction("Index")); }
public ActionResult Insert(EditableOrder value) { OrderRepository.Add(value); var data = OrderRepository.GetAllRecords(); return(Json(data, JsonRequestBehavior.AllowGet)); }
public void AddOrderLine() { var order = new Order { Id = Guid.NewGuid(), OrderNo = "PO_0005" }; order.OrderLines = new List<OrderLine> { new OrderLine { Id = Guid.NewGuid(), OrderId = order.Id, ProductId = new Guid("85C2B3A5-117B-8BD2-AA78-39D8D7E7B218") } }; var uowManager = IocManager.Instance.Resolve<IUnitOfWorkManager>(); using (var uow = uowManager.Begin()) { var repository = new OrderRepository(); repository.Add(order); //repository.Context.SaveChanges(); uow.Complete(); } }
public int Add(Order order) { var books = _bookRepository.GetAllAvailable(); var orderBooks = books.Where(x => order.OrderBooks.Any(y => y.BookId == x.Id)).ToList(); var orderDto = new OrderDto() { BuyerId = order.BuyerId, Comment = order.Comment, OrderDateTime = order.OrderDateTime, OrderStatusId = order.OrderStatusId, SellerId = order.SellerId, SummaryPrice = orderBooks.Sum(x => x.Price * order.OrderBooks.FirstOrDefault(y => y.BookId == x.Id).Count) }; var orderId = _orderRepository.Add(orderDto); foreach (var orderBook in order.OrderBooks) { _orderRepository.AddOrderBook(orderId, orderBook.BookId, orderBook.Count); var goodDto = _goodRepository.GetGoodByBookId(orderBook.BookId); goodDto.Count = goodDto.Count - orderBook.Count; _goodRepository.UpdateGood(goodDto); } return(orderId); }
public ActionResult SiparisVer(Order item) { if (TempData["Kullanici"] == null) { return(RedirectToAction("Login", "Home")); } AppUser kullanici = TempData["Kullanici"] as AppUser; item.AppUserID = kullanici.ID; ord_repo.Add(item); int sonSiparisID = ord_repo.GetLastAdded(); Cart sepet = Session["scart"] as Cart; foreach (CartItem urun in sepet.Sepetim) { OrderDetail od = new OrderDetail(); od.OrderID = sonSiparisID; od.ProductID = urun.ID; od.TotalPrice = urun.SubTotal; od.Quantity = urun.Amount; detail_repo.Add(od); } return(RedirectToAction("ShoppingList")); }
public void GetAll_Returns_10_Orders() { var databaseName = Guid.NewGuid().ToString(); using (var context = DbContextFactory.CreateInstance(databaseName)) { //Arrange var customerRepository = new CustomerRepository(context); var orderRepository = new OrderRepository(context); for (int i = 0; i < 10; i++) { var customer = CustomerFactory.CreateValidEntity(); customerRepository.Add(customer); var orderToAdd = OrderFactory.CreateValidEntity(customer); orderRepository.Add(orderToAdd); } context.SaveChanges(); //Act var orders = orderRepository.GetAll(); //Assert Assert.AreEqual(10, orders.Count()); } }
public async Task <IActionResult> Checkout(Order order) { User u = HttpContext.Session.GetJson <User>("User"); order.UserID = u.ID; order.Time = DateTime.Now; order.Status = false; foreach (var value in cart.Lines) { order.OrderDetail.Add(new OrderDetail() { OrderID = 0, BookID = value.Book.ID, Price = (int)value.Book.Price, Quantity = value.Quantity }); await bookRepo.SetQuantity(value.Book.ID, value.Quantity); } int result = await orderRepo.Add(order); if (result > 0) { cart.Clear(); TempData["Message"] = new[] { "success", "Đặt hàng thành công" }; return(Redirect("/Account")); } else { TempData["Message"] = new[] { "danger", "Lỗi đặt hàng" }; return(View(order)); } }
/// <inheritdoc/> public IOrder Create(int accountId, NewOrder @params) { #region Check arguments if (@params is null) { throw new ArgumentNullException(nameof(@params)); } #endregion // create order var order = OrderRepository.Create(); // fill params OnCreateParams(order, @params, accountId); // save order order = OrderRepository.Add(order); // create authorization OnCreateAuth(order, @params); order.Identifier = ComputerIdentifier(@params.Identifiers.ToArray(), IDENTIFIER_HASH); // update order order = OrderRepository.Update(order); Logger.Info("Order {id} created", order.Id); return(order); }
public void adding_an_order_should_succeed_v2() { //Arrange IOrderRepository orderRepository = new OrderRepository(); var fixture = new Fixture(); var user = fixture.Create <User>(); var cart = fixture.Create <Cart>(); var product = fixture.Create <Product>(); cart.AddProduct(product); var order = new Order(user, cart); //Act orderRepository.Add(order); //Assert var expectedOrder = orderRepository.Get(order.Id); expectedOrder.ShouldBeEquivalentTo(order); var orders = orderRepository.Browse(order.UserId); orders.Should().NotBeEmpty(); orders.Should().ContainSingle(); orders.Should().Contain(o => o.Id == order.Id); //Assert.Contains(orders, o => o.Id == order.Id); // czy na pewno Browse ma ten sam element jakim jest order }
public Order Create(Order order) { order.Guid = Guid.NewGuid(); order.PackageWidth = OrderCalculator.GetPackageWidth(order); return(OrderRepository.Add(order)); }
public String AddBookingForMobile(String idParam, String username, String password, String date, String time, String duration) { UserService userService = new UserService(); int userid = userService.findAnUserByName(username).UserID; int pcid = int.Parse(idParam); DateTime newDate = DateTime.ParseExact(date + " " + time, "dd/MM/yyyy HH:mm", null); int intDuration = int.Parse(duration); OrderService orderService = new OrderService(); OrderStatus orderStatus = orderService.isCanOrder(pcid, newDate, intDuration, userid); if (orderStatus.status == OrderStatusCode.FAIL) { return orderStatus.message; } Order order = new Order(); order.PCID = pcid; order.UserID = userid; order.StartTime = newDate; order.Duration = intDuration; order.OrderStatus = 0; // tru balance IRepository<Order> repository = new OrderRepository(); repository.Add(order); return "true"; }
public void adding_an_order_should_succeed() { //Arrange IOrderRepository orderRepository = new OrderRepository(); var cart = new Cart(); cart.AddProduct(new Product("test", "test", 1)); var order = new Order(new User("test", "test"), cart); //Stub - klasa tworząca dane testowe //Act orderRepository.Add(order); //Assert var expectedOrder = orderRepository.Get(order.Id); Assert.Equal(expectedOrder, order); var orders = orderRepository.Browse(order.UserId); Assert.NotEmpty(orders); Assert.Single(orders); Assert.Contains(orders, o => o.Id == order.Id); }
/// <summary> ///A test for ValidateAciXml ///</summary> private int CreateOrder(int formId) { base.InitDbContext(); IOrderRepository orderRepository = new OrderRepository(this.DbFactory); ICommitProvider commitProvider = new CommitProvider(this.DbFactory); int rand = new Random().Next(0, 100000); var loanAndContactInfo = new OrderLoanAndContactInfo { Contacts = new List<OrderContact>() { new OrderContact { ContactRoleId = 2, Email = String.Format("mial{0}@mail.com", rand), Name = "Name" + rand, Phone = "123" + rand } }, LoanPurposeTypeId = 4, GFEDate = DateTime.Now.AddDays(100), GFEAmount = 9999.99, }; var generalInfo = new OrderGeneralInfo { BorrowerFirstName = "Test" + rand, BorrowerLastName = "Test" + rand, LoanNumber = "100" + rand, PropertyAddress = new Address { City = "New York", County = "Test", State = "NY", ZIP = "12345", Street = "Wallstreet" } }; var appraisalInfo = new OrderAppraisalInfo { PropertyTypeId = 3, OccupancyTypeId = 1, AppraisalTypeId = 1, Rush = true, SecondDuplicateAppraisal = true, LoanType = LoanType.Conventional, NumberUnits = 7, AppraisalType = AppraisalType.Appraisal, AppraisalForm = formId, ReviewForm = 0 }; Order order = new Order { OrderPublicId = "000" + rand, AppraiserOrderDeliveryType = 3, CreationDate = DateTime.Now, LoanAndContactInfo = loanAndContactInfo, AppraisalInfo = appraisalInfo, CreatedByClientUserId = 1, OrderStatusId = OrderStatus.PendingAssignment.ToString(), DueDate = DateTime.Now.AddDays(10), Latitude = 43, Longitude = -73, GeneralInfo = generalInfo }; orderRepository.Add(order); commitProvider.Commit(); return order.Id; }
public void OrderRepositoryAddNewItemSaveItem() { //Arrange var unitOfWork = new MainBCUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); var orderRepository = new OrderRepository(unitOfWork); var customer = customerRepository.Get(new Guid("0CD6618A-9C8E-4D79-9C6B-4AA69CF18AE6")); var order = OrderFactory.CreateOrder(customer, "shipping name", "shipping city", "shipping address", "shipping zip code"); order.GenerateNewIdentity(); //Act orderRepository.Add(order); unitOfWork.Commit(); }
public void AddOrder() { var order = new Order { OrderNo = "PO_0004" }; var uowManager = IocManager.Instance.Resolve<IUnitOfWorkManager>(); using (var uow = uowManager.Begin()) { var repository = new OrderRepository(); repository.Add(order); //throw new System.Exception("Error"); uow.Complete(); } }
public static void CreateOrder() { var radOrder = new Random(DateTime.Now.Millisecond); var orderRepository = new OrderRepository(); var date = DateTime.Now.AddDays(radOrder.Next(10)); var order = new Order { City = "Sławno", OrderNumber = String.Format("{0}/{1}/{2}", radOrder.Next(10, 99), radOrder.Next(10, 99), radOrder.Next(1000, 9999)), RecipientId = radOrder.Next(1, 10), CountryCode = "PL", HouseNumber = "10", OrderStatus = eOrderStatus.New, PostalCode = "76-100", SendDate = date, CreateDate = date.AddDays(-1), Street = "Warszkowo", }; order.Positions = CreateOrderPosition(); orderRepository.Add(order); }
public void OrderRepositoryAddNewItemSaveItem() { //Arrange var unitOfWork = new MainBCUnitOfWork(); IOrderRepository orderRepository = new OrderRepository(unitOfWork); var customerId = new Guid("0CD6618A-9C8E-4D79-9C6B-4AA69CF18AE6"); var order = OrderFactory.CreateOrder(customerId, "shipping name", "shipping city", "shipping address", "shipping zip code"); order.Id = IdentityGenerator.NewSequentialGuid(); //Act orderRepository.Add(order); orderRepository.UnitOfWork.Commit(); //Assert var result = orderRepository.Get(order.Id); Assert.IsNotNull(result); Assert.IsTrue(result.Id == order.Id); }