public void GetParcelCost_returns_400(int weight, int height, int width, int depth) { //Given var sut = new ParcelController(mockParcelManager.Object); //When var actual = sut.GetParcelCost(weight, height, width, depth); //Then var result = Assert.IsType <BadRequestObjectResult>(actual); Assert.Equal(400, result.StatusCode); }
public void StartProcess(int weight, int height, int width, int depth, decimal cost) { //Given var sut = new ParcelController(_parcelManager); //When var actual = sut.GetParcelCost(weight, height, width, depth); //Then var result = Assert.IsType <OkObjectResult>(actual); var parcelCost = Assert.IsType <ParcelCost>(result.Value); Assert.Equal(cost, parcelCost.CostOfDelivery); }
public void GetParcelCost_returns_500(int weight, int height, int width, int depth) { //Given mockParcelManager.Setup(m => m.GetCost(It.IsAny <Parcel>())).Throws <Exception>(); var sut = new ParcelController(mockParcelManager.Object); //When var actual = sut.GetParcelCost(weight, height, width, depth); //Then var result = Assert.IsType <StatusCodeResult>(actual); Assert.Equal(500, result.StatusCode); }
public void GetParcelCost_returns_404(int weight, int height, int width, int depth) { //Given mockParcelManager.Setup(m => m.GetCost(It.IsAny <Parcel>())).Returns <ParcelCost>(null); var sut = new ParcelController(mockParcelManager.Object); //When var actual = sut.GetParcelCost(weight, height, width, depth); //Then var result = Assert.IsType <NotFoundResult>(actual); Assert.Equal(404, result.StatusCode); }
public void GetParcelCost_returns_correct_object_state(int weight, int height, int width, int depth) { //Given ParcelCost parcelCost = new ParcelCost(20, "mock"); mockParcelManager.Setup(m => m.GetCost(It.IsAny <Parcel>())).Returns(parcelCost); var sut = new ParcelController(mockParcelManager.Object); //When var actual = sut.GetParcelCost(weight, height, width, depth); //Then var result = Assert.IsType <OkObjectResult>(actual); Assert.Equal(200, result.StatusCode); Assert.IsType <ParcelCost>(result.Value); }