Beispiel #1
0
        public async Task Purchase_Domains_In_Goddady()
        {
            var request = new DomainPurchaseDto();

            request.Request        = new DomainPurchase();
            request.Request.period = 10;
            request.Request.domain = "edgarleonardo.com";
            request.XShopperId     = "";
            /// Result to compare with
            var domainResponse = new DomainPurchaseResponse {
                Currency  = "USD",
                ItemCount = 1,
                OrderId   = 1,
                Total     = 1
            };
            var domainInterface = _mocker.GetMock <IServicesDomains>();

            /// Setting the mocking behavior expected
            domainInterface.Setup(p => p.PurchaseDomain(request.Request, request.XShopperId)).
            Returns(Task.FromResult <DomainPurchaseResponse>(domainResponse));

            var controller = new DomainsController(domainInterface.Object);
            var result     = await controller.Post(request);

            Assert.Equal(result.ItemCount, domainResponse.ItemCount);
        }
Beispiel #2
0
        public async Task <DomainPurchaseResponse> Post([FromBody] DomainPurchaseDto obj)
        {
            if (obj == null || obj.Request == null || string.IsNullOrEmpty(obj.Request.domain) || !ModelState.IsValid)
            {
                return(null);
            }
            var domainPurchaseResponse = await _servicesDomain.PurchaseDomain(obj.Request, obj.XShopperId);

            return(domainPurchaseResponse);
        }