Exemplo n.º 1
0
        public async Task Get_Should_Return_Order_If_Id_Is_Valid_And_Order_Exist()
        {
            var order = new Business.Order
            {
                Id = 101,
                QuantityByItemId = new Dictionary <long, int>()
                {
                    { 1, 2 }, { 3, 4 }
                }
            };

            repositoryMock
            .Setup(repo => repo.GetById(order.Id))
            .ReturnsAsync(order)
            .Verifiable();

            var response = await client.GetAsync($"/orders/{order.Id}");

            Assert.True(response.IsSuccessStatusCode);

            var responseOrder = JsonConvert.DeserializeObject <Transport.Order>(await response.Content.ReadAsStringAsync());

            Transport.Order modelOrder = Mapping.Instance.Map <Transport.Order>(order);
            Assert.Equal(modelOrder.ToString(), responseOrder.ToString());

            repositoryMock.Verify();
        }
Exemplo n.º 2
0
 public static Models.Order ConvertToDal(Business.Order model)
 {
     return(new Models.Order
     {
         Id = model.Id,
         TotalAmount = model.TotalAmount,
         CilentId = model.CilentId,
         Cilent = ClientDAO.ConvertToDal(model.Cilent),
         Billet = BilletDAO.ConvertToDal(model.Billet)
     });
 }
Exemplo n.º 3
0
 public static Shared.Order ConvertToEndPoint(Business.Order model)
 {
     return(new Shared.Order
     {
         Id = model.Id,
         TotalAmount = model.TotalAmount,
         CilentId = model.CilentId,
         Cilent = ClientDAO.ConvertToEndPoint(model.Cilent),
         Billet = BilletDAO.ConvertToEndPoint(model.Billet)
     });
 }
Exemplo n.º 4
0
 /// <summary>
 /// converts an order object into a order entity
 /// </summary>
 /// <param name="order">order object to be converted</param>
 /// <returns>oder entity</returns>
 public static Entities.Orders MapOrder(Business.Order order)
 {
     return(new Entities.Orders
     {
         Id = order.Id,
         LocationId = order.LocationId,
         CustomerId = order.CustomerId,
         OrderDate = order.Time,
         TotalCost = order.TotalPrice,
         ProductOrder = order.ProductOrders.Select(MapProductOrder).ToList(),
     });
 }
Exemplo n.º 5
0
        public void TestOrders_Groceries()
        {
            BillingSystem.Business.User user = new User()
            {
                Doj = new DateTime(2012, 1, 1),
                FirstName = "Darpan",
                LastName = "Sinha",
                IsAffiliate = false,
                IsEmployee = true
            };

            BillingSystem.Business.Order order = new Business.Order();

            order.User = user;

            order.Items = new List<IItem>();

            order.Items.Add(new BillingSystem.Business.ITems() { ItemType = BillingSystem.Domain.ItemType.Groceries, Price = 1000, Quantity = 1 });

            order.Create();
        }
Exemplo n.º 6
0
        public async Task Put_Return_Order_Id_If_It_Was_Created()
        {
            var newOrder = new Business.Order()
            {
                Id = 100
            };

            repositoryMock
            .Setup(repo => repo.Create())
            .ReturnsAsync(newOrder)
            .Verifiable();

            var response = await client.PutAsync($"/orders", null);

            var responceId =
                JsonConvert.DeserializeObject <long>(await response.Content.ReadAsStringAsync());

            Assert.True(response.IsSuccessStatusCode);
            Assert.Equal(newOrder.Id, responceId);

            repositoryMock.Verify();
        }
Exemplo n.º 7
0
        public void TestOrders()
        {
            //shd give 5% dis of doj = 50
            //5$ dis = 950 = 45
            BillingSystem.Business.User user = new User()
            {
                Doj = new DateTime(2008, 1, 1),
                FirstName = "Darpan",
                LastName = "Sinha",
                IsAffiliate = false,
                IsEmployee = false
            };

            BillingSystem.Business.Order order = new Business.Order();

            order.User = user;

            order.Items = new List<IItem>();

            order.Items.Add(new BillingSystem.Business.ITems() { ItemType = BillingSystem.Domain.ItemType.Others, Price = 1000, Quantity = 1 });

            order.Create();
        }
Exemplo n.º 8
0
 internal Order(Business.Order i)
 {
     OrderId     = i.OrderId;
     Description = i.Description;
     Quantity    = i.Quantity;
 }