public void Deletee_ReturnsDeleteView() { //Arrange //Act var result = controller.Delete(1) as ViewResult; //Assert Ticket t = (Ticket)result.Model; Assert.AreEqual("Delete", result.ViewName); Assert.AreEqual(1, t.TicketNumber); }
public void TicketDeleteTest() { var ac = new TicketController(); var r = ac.Delete(1) as ViewResult; Assert.IsNotNull(r); }
public void AddItem_When_InputCorrect_Than_CountIncrease() { //Arrange var correctItem = new TicketDTO { Number = "TestAdd2", Price = 1000 }; var initialCount = _context.Tickets.ToList().Count; //Act _ticketController.Post(correctItem).Wait(); var afterCount = _context.Tickets.ToList().Count; //Assert Assert.IsFalse(initialCount == afterCount); //Reset _ticketController.Delete(_context.Tickets.Last().Id).Wait(); }
public async Task GivenTicketController_WhenDeleteIsCalledWithNewId_ThenReturnNotFound() { var id = ObjectId.GenerateNewId().ToString(); var result = await _controller.Delete(id); var notFoundResult = result as NotFoundResult; notFoundResult.Should().NotBeNull(); notFoundResult.StatusCode.Should().Be(404); A.CallTo(() => _mediator.Send(A <DeleteTicketByIdCommand> ._, default)).MustHaveHappenedOnceExactly(); }
public void Controller_StatusCode500_When_ServiceReturnFalse() { //Arrange var mock = new Mock <ITicketService>(); mock.Setup(service => service.DeleteObjectAsync(It.IsAny <int>())).Returns(Task.FromResult(false)); var controller = new TicketController(mock.Object); //Act var result = controller.Delete(It.IsAny <int>()).Result as StatusCodeResult; //Assert Assert.AreEqual(new StatusCodeResult(500).StatusCode, result.StatusCode); }
public void DeleteTicket() { // Arrange TicketController controller = new TicketController(); var actResult = controller.Delete(1); // Act var result = actResult as OkNegotiatedContentResult <bool>; // Assert Assert.IsNotNull(result); Assert.IsTrue(result.Content == true); }
public async void Delete_Errors() { TicketControllerMockFacade mock = new TicketControllerMockFacade(); var mockResult = new Mock <ActionResponse>(); mockResult.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.FromResult <ActionResponse>(mockResult.Object)); TicketController controller = new TicketController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.Delete(default(int)); response.Should().BeOfType <ObjectResult>(); (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); mock.ServiceMock.Verify(x => x.Delete(It.IsAny <int>())); }
public void Delete_Unsuccessful() { var testData = new TicketDto { Username = "******", Description = "lorem ipsum", DownloadUrl = "test.pl", Severity = 3, Sha256Checksum = "testtest123", Solved = false }; var ticketServiceMock = new Mock <ITicketService>(); var fileManagerServiceMock = new Mock <IFileManagerService>(); ticketServiceMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.FromResult(false)); var objectUnderTest = new TicketController(ticketServiceMock.Object, fileManagerServiceMock.Object); var result = objectUnderTest.Delete(1).Result; Assert.IsInstanceOfType(result.Result, typeof(NotFoundResult)); Assert.IsNotNull(result); }
// Delete Ticket public void DeleteTicket(int id) { ticketC.Delete(id); }
public void ControllerDelete_WithIdOnly_GetsTicketDetailsInMgr() { _controller.Delete(459); mgr.Received(1).GetTicket(459); }