public async void Should_return_Throw_and_return_BadRequest_with_created_Queue() { //Arrange var expectedResult = new Queue() { QueueId = 1 }; QueueRepositoryMock .Setup(l => l.Add(expectedResult)).Throws(new Exception()); UnitofWorkMock .Setup(m => m.Queue) .Returns(QueueRepositoryMock.Object); //Act var result = await _uut.Post(expectedResult); //Assert QueueRepositoryMock.VerifyAll(); var ErrorResult = Assert.IsType <BadRequestObjectResult>(result); Assert.Equal(400, ErrorResult.StatusCode); }
public async void Should_return_CreatedAtActionResult_with_created_Queue() { //Arrange var expectedResult = new Queue() { QueueId = 1 }; QueueRepositoryMock .Setup(l => l.Add(expectedResult)).Verifiable(); UnitofWorkMock .Setup(m => m.Queue) .Returns(QueueRepositoryMock.Object); //Act var result = await _uut.Post(expectedResult); //Assert QueueRepositoryMock.VerifyAll(); var response = Assert.IsType <OkObjectResult>(result); Assert.Same(expectedResult, response.Value); }