Example #1
0
        public void AddShippingAddressesTestMethod()
        {
            controller = new ShippingAddressesController(context);
            ShippingAddress shippingAddress = new ShippingAddress()
            {
                address     = "via pioppi",
                city        = "battipaglia",
                first_name  = "Gerardo",
                last_name   = "Longo",
                country     = "Italy",
                company     = "",
                postal_code = "84091",
                phone       = "33365987",
                province    = "SA"
            };

            IActionResult  actionResult = controller.ShippingAddresses(shippingAddress);
            OkObjectResult result       = actionResult as OkObjectResult;

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

            string          name = "Gerardo";
            ShippingAddress shippingAddressAdded = result.Value as ShippingAddress;

            Assert.AreEqual(shippingAddressAdded.first_name, name);
            controller.Dispose();
        }
Example #2
0
        public void DeleteShippingAddressesNotFoundTestMethod()
        {
            controller = new ShippingAddressesController(context);
            IActionResult          actionResult = controller.ShippingAddresses(10);
            BadRequestObjectResult result       = actionResult as BadRequestObjectResult;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.StatusCode, 400);
            controller.Dispose();
        }
Example #3
0
        public void GetShippingAddressesTestMethod()
        {
            controller = new ShippingAddressesController(context);
            IActionResult  actionResult = controller.ShippingAddresses(0, 1, "Gerardo");
            OkObjectResult result       = actionResult as OkObjectResult;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.StatusCode, 200);
            Assert.AreNotEqual(((List <ShippingAddress>)result.Value).Count, 0);
            controller.Dispose();
        }
Example #4
0
        public void DeleteShippingAddressesNotValidIdTestMethod()
        {
            controller = new ShippingAddressesController(context);
            IActionResult          actionResult = controller.ShippingAddresses(-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();
        }
Example #5
0
        public void DeleteShippingAddressesTestMethod()
        {
            controller = new ShippingAddressesController(context);
            IActionResult  actionResult = controller.ShippingAddresses(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();
        }
Example #6
0
        public void PatchShippingAddressesNotFoundTestMethod()
        {
            controller = new ShippingAddressesController(context);
            ShippingAddress shippingAddress = new ShippingAddress()
            {
                country = "Germany",
            };


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

            Assert.IsNotNull(result);
            Assert.AreEqual(result.StatusCode, 400);
            controller.Dispose();
        }
Example #7
0
        public void PatchShippingAddressesTestMethod()
        {
            controller = new ShippingAddressesController(context);
            ShippingAddress shippingAddress = new ShippingAddress()
            {
                country = "Germany",
            };


            IActionResult   actionResult           = controller.ShippingAddresses(1, shippingAddress);
            OkObjectResult  result                 = actionResult as OkObjectResult;
            ShippingAddress shippingAddressUpdated = result.Value as ShippingAddress;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.StatusCode, 200);
            Assert.AreEqual(shippingAddressUpdated.country, shippingAddress.country);
            controller.Dispose();
        }