Пример #1
0
        public void ShouldBeSuccessToPaidOrder()
        {
            //Arrange
            var order = FakerOrder.GetSampleWithItems(3);

            order.Close();

            var model = new PaidOrderModel()
            {
                Id = order.Id,
                TotalPaidInCents = order.TotalInCents
            };

            _repositoryMock.Setup(r => r.Get(It.Is <Guid>(id => id == order.Id))).Returns(order);
            _repositoryMock.Setup(r => r.Update(It.Is <Order>(o => o.Id == order.Id))).Returns(order);

            //Act
            var response = _service.PaidOrder(model);

            //Assert
            var output = GlobalMapper.Map <Result <OrderModelOutput> >(response);

            var validateTest = response.Success &&
                               output.Data.Status == EOrderStatus.Paid;

            _repositoryMock.Verify(r => r.Get(It.Is <Guid>(id => id == order.Id)), Times.Once);
            _repositoryMock.Verify(r => r.Update(It.Is <Order>(o => o.Id == order.Id)), Times.Once);

            validateTest.Should().BeTrue();
        }
Пример #2
0
        public void ShouldBeSuccessToBeginOrder()
        {
            //Arrange
            _repositoryMock.Setup(r => r.Insert(It.IsAny <Order>())).Returns(FakerOrder.GetSample());

            //Act
            var response = _service.BeginOrder();

            //Assert
            var output = GlobalMapper.Map <Result <OrderModelOutput> >(response);

            var validateTest = response.Success &&
                               output.Data.Status == EOrderStatus.Pending;

            _repositoryMock.Verify(r => r.Insert(It.IsAny <Order>()), Times.Once);

            validateTest.Should().BeTrue();
        }
        public object CreateUser()
        {
            var form    = this.BindFromForm <CreateUserRequest>();
            var request = this.BindFromBody <CreateUserRequest>();
            var query   = this.BindFromQuery <CreateUserRequest>();

            this.AdditionalInfo.Data.Add("AccountId", "Test");
            this.AdditionalInfo.Data.Add("MerchantId", "Test2");

            this.ValidateRequest(form);
            this.ValidateRequest(request);
            this.ValidateRequest(query);

            var response = new ApiResponse {
                StatusCode = System.Net.HttpStatusCode.OK
            };

            response.Content = GlobalMapper.Map <GetUserResponse>(request);

            return(this.CreateJsonResponse(response));
        }