示例#1
0
        public void ShouldNotBeAbleToRemoveOrderInStateOtherThanNew()
        {
            // arrange
            var mock = new MockRepository();
            var repository = mock.StrictMock<IOrderRepository>();
            const string IdentityToken = "*****@*****.**";
            const int OrderId = 2;
            Expect.Call(repository.RemoveOrder(IdentityToken, OrderId)).Throw(new ArgumentException());
            var service = new OrderService(repository, new FakeEmailService(), this.logger);
            var request = new RemoveOrderRequest { IdentityToken = IdentityToken, Id = OrderId };

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

            // assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.MessageType, Is.EqualTo(MessageType.Error));
        }
示例#2
0
        public ActionResult Remove(int orderId, string userEmail)
        {
            this.EnsureUserEmailIsNotChanged(userEmail);

            var request = new RemoveOrderRequest
                {
                    IdentityToken = userEmail,
                    Id = orderId
                };
            var response = this.orderService.RemoveOrder(request);
            var result = response.ConvertToOrderViewModel();

            var jsonNetResult = new JsonNetResult
            {
                Formatting = (Formatting)Newtonsoft.Json.Formatting.Indented,
                Data = result
            };
            return jsonNetResult;
        }
示例#3
0
        public void ShouldBeAbleToRemoveOrder()
        {
            // arrange
            var mock = new MockRepository();
            var repository = mock.StrictMock<IOrderRepository>();
            const string IdentityToken = "*****@*****.**";
            const int OrderId = 1;
            Expect.Call(repository.RemoveOrder(IdentityToken, OrderId)).Return(new Order { Id = 1 });
            var service = new OrderService(repository, new FakeEmailService(), this.logger);
            var request = new RemoveOrderRequest { IdentityToken = IdentityToken, Id = OrderId };

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

            // assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.MessageType, Is.EqualTo(MessageType.Success));
        }
示例#4
0
        /// <summary>
        /// Remove order.
        /// </summary>
        /// <param name="request">
        /// Remove order request.
        /// </param>
        /// <returns>
        /// Remove order response.
        /// </returns>
        public RemoveOrderResponse RemoveOrder(RemoveOrderRequest request)
        {
            var response = new RemoveOrderResponse();

            try
            {
                var order = this.orderRepository.RemoveOrder(request.IdentityToken, request.Id);
                response = order.ConvertToRemoveOrderResponse();
                response.Message = CommonResources.OrderRemoveSuccessMessage;
            }
            catch (Exception ex)
            {
                response.Id = request.Id;
                response.MessageType = MessageType.Error;
                response.ErrorCode = ex.Message;
                this.Logger.Error(CommonResources.OrderRemoveErrorMessage, ex);
            }

            return response;
        }