Exemplo n.º 1
0
        public void AddBillingAddressesTestMethod()
        {
            controller = new BillingAddressesController(context);
            BillingAddress billingAddress = new BillingAddress()
            {
                address     = "via pioppi",
                city        = "battipaglia",
                first_name  = "Gerardo",
                last_name   = "Longo",
                country     = "Italy",
                company     = "",
                postal_code = "84091",
                phone       = "33365987",
                province    = "SA",
                email       = "*****@*****.**",
                fiscal_code = "LNGGRD89A17A717B",
                vat_code    = "LNGGRD89A17A717B",
            };

            IActionResult  actionResult = controller.BillingAddresses(billingAddress);
            OkObjectResult result       = actionResult as OkObjectResult;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.StatusCode, 200);

            string         name = "Gerardo";
            BillingAddress billingAddressAdded = result.Value as BillingAddress;

            Assert.AreEqual(billingAddressAdded.first_name, name);
            controller.Dispose();
        }
Exemplo n.º 2
0
        public void DeleteBillingAddressesNotFoundTestMethod()
        {
            controller = new BillingAddressesController(context);
            IActionResult          actionResult = controller.BillingAddresses(10);
            BadRequestObjectResult result       = actionResult as BadRequestObjectResult;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.StatusCode, 400);
            controller.Dispose();
        }
Exemplo n.º 3
0
        public void GetBillingAddressesTestMethod()
        {
            controller = new BillingAddressesController(context);
            IActionResult  actionResult = controller.BillingAddresses(0, 1, "Gerardo");
            OkObjectResult result       = actionResult as OkObjectResult;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.StatusCode, 200);
            Assert.AreNotEqual(((List <BillingAddress>)result.Value).Count, 0);
            controller.Dispose();
        }
Exemplo n.º 4
0
        public void DeleteBillingAddressesNotValidIdTestMethod()
        {
            controller = new BillingAddressesController(context);
            IActionResult          actionResult = controller.BillingAddresses(-10);
            BadRequestObjectResult result       = actionResult as BadRequestObjectResult;
            string resultValue = "Not a valid shipping address id";

            Assert.IsNotNull(result);
            Assert.AreEqual(result.StatusCode, 400);
            Assert.AreEqual(result.Value, resultValue);
            controller.Dispose();
        }
Exemplo n.º 5
0
        public void DeleteBillingAddressesTestMethod()
        {
            controller = new BillingAddressesController(context);
            IActionResult  actionResult = controller.BillingAddresses(1);
            OkObjectResult result       = actionResult as OkObjectResult;
            string         resultValue  = "operation successful";

            Assert.IsNotNull(result);
            Assert.AreEqual(result.StatusCode, 200);
            Assert.AreEqual(result.Value, resultValue);
            controller.Dispose();
        }
Exemplo n.º 6
0
        public void PatchBillingAddressesNotFoundTestMethod()
        {
            controller = new BillingAddressesController(context);
            BillingAddress shippingAddress = new BillingAddress()
            {
                country = "Germany",
            };


            IActionResult          actionResult = controller.BillingAddresses(34, shippingAddress);
            BadRequestObjectResult result       = actionResult as BadRequestObjectResult;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.StatusCode, 400);
            controller.Dispose();
        }
Exemplo n.º 7
0
        public void PatchBillingAddressesTestMethod()
        {
            controller = new BillingAddressesController(context);
            BillingAddress billingAddress = new BillingAddress()
            {
                country = "Germany",
            };


            IActionResult  actionResult          = controller.BillingAddresses(5, billingAddress);
            OkObjectResult result                = actionResult as OkObjectResult;
            BillingAddress billingAddressUpdated = result.Value as BillingAddress;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.StatusCode, 200);
            Assert.AreEqual(billingAddressUpdated.country, billingAddress.country);
            controller.Dispose();
        }