Ejemplo n.º 1
0
        public void ShouldBeAbleToGetListOfOrders()
        {
            // arrange
            var mock = new MockRepository();
            var repository = mock.StrictMock<IOrderRepository>();
            const string IdentityToken = "*****@*****.**";
            Expect.Call(repository.GetMyRecent(IdentityToken)).Return(
                new List<Order>
                {
                    new Order(OrderStatus.New)
                        {
                            CreatedDate = DateTime.UtcNow,
                            Id = 1,
                            OrderNumber = "12212",
                            ReceivedDate = null,
                            Retailer = new Retailer("amazon.com"),
                            ReturnedDate = null
                        },
                    new Order(OrderStatus.Received)
                        {
                            CreatedDate = DateTime.UtcNow,
                            Id = 2,
                            OrderNumber = "122122",
                            ReceivedDate = DateTime.UtcNow,
                            Retailer = new Retailer("apple.com"),
                            ReturnedDate = null
                        },
                    new Order(OrderStatus.ReturnRequested)
                        {
                            CreatedDate = DateTime.UtcNow,
                            Id = 3,
                            OrderNumber = "1221227776",
                            ReceivedDate = DateTime.UtcNow,
                            Retailer = new Retailer("apple.com"),
                            ReturnedDate = null
                        }
                });
            var service = new OrderService(repository, new FakeEmailService(), this.logger);
            var request = new GetMyOrdersRequest { IdentityToken = IdentityToken };
            var expected = new List<GetMyOrdersResponse>
                {
                    new GetMyOrdersResponse
                        {
                            CreatedDate = DateTime.UtcNow,
                            Id = 1,
                            OrderNumber = "12212",
                            ReceivedDate = null,
                            RetailerUrl = "amazon.com",
                            ReturnedDate = null,
                            Status = "New"
                        },
                    new GetMyOrdersResponse
                        {
                            CreatedDate = DateTime.UtcNow,
                            Id = 2,
                            OrderNumber = "122122",
                            ReceivedDate = DateTime.UtcNow,
                            RetailerUrl = "apple.com",
                            ReturnedDate = null,
                            Status = "Received"
                        },
                    new GetMyOrdersResponse
                        {
                            CreatedDate = DateTime.UtcNow,
                            Id = 3,
                            OrderNumber = "1221227776",
                            ReceivedDate = DateTime.UtcNow,
                            RetailerUrl = "apple.com",
                            ReturnedDate = null,
                            Status = "ReturnRequested"
                        }
                };

            // act
            mock.ReplayAll();
            var actual = service.GetRecent(request);
            mock.VerifyAll();

            // assert
            Assert.That(actual, Is.Not.Null);
            if (actual != null)
            {
                for (var i = 0; i < expected.Count; i++)
                {
                    Assert.That(actual[i].Id, Is.EqualTo(expected[i].Id));
                    Assert.That(actual[i].CreatedDate, Is.EqualTo(expected[i].CreatedDate).Within(1).Minutes);
                    Assert.That(actual[i].ReceivedDate, Is.EqualTo(expected[i].ReceivedDate).Within(1).Minutes);
                    Assert.That(actual[i].RetailerUrl, Is.EqualTo(expected[i].RetailerUrl));
                    Assert.That(actual[i].OrderNumber, Is.EqualTo(expected[i].OrderNumber));
                    Assert.That(actual[i].TrackingNumber, Is.EqualTo(expected[i].TrackingNumber));
                    Assert.That(actual[i].Status, Is.EqualTo(expected[i].Status));
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// The get history.
 /// </summary>
 /// <param name="request">
 /// The request.
 /// </param>
 /// <returns>
 /// The collection of response messages.
 /// </returns>
 public List<GetMyOrdersResponse> GetHistory(GetMyOrdersRequest request)
 {
     var history = this.orderRepository.GetMyHistory(request.IdentityToken);
     return history.ConvertToMyOrdersResponseCollection();
 }
Ejemplo n.º 3
0
        public ActionResult History(string userEmail)
        {
            this.EnsureUserEmailIsNotChanged(userEmail);
            var request = new GetMyOrdersRequest { IdentityToken = userEmail };
            var response = this.orderService.GetHistory(request);
            var result = response.ConvertToOrderViewModelCollection();

            var jsonNetResult = new JsonNetResult
            {
                Formatting = (Formatting)Newtonsoft.Json.Formatting.Indented,
                Data = result
            };
            return jsonNetResult;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Get recent orders (new or received within 30 days)
 /// </summary>
 /// <param name="request">
 /// The request message.
 /// </param>
 /// <returns>
 /// The response message.
 /// </returns>
 public List<GetMyOrdersResponse> GetRecent(GetMyOrdersRequest request)
 {
     var recentOrders = this.orderRepository.GetMyRecent(request.IdentityToken);
     return recentOrders.ConvertToMyOrdersResponseCollection();
 }