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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }