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