public async Task Get_CreatedDemand_ReturnsListOfDemandResource() { var result = await _controller.Get(); // Assert Assert.Pass(); var okObjectResult = result as OkObjectResult; Assert.IsNotNull(okObjectResult); }
public void GetDemand() { var mock = new Mock <IRepository <Demand> >(); mock.Setup(repo => repo.GetById(It.IsAny <int>())).Returns(GetByIdTest(1)); var factoryMock = new Mock <IRepositoryFactory>(); factoryMock.Setup(f => f.GetRepository <Demand>()).Returns(mock.Object); _demandController = new DemandController(factoryMock.Object); var json = _demandController.Get(1); var demand = json.Value as Demand; Assert.NotNull(json); Assert.NotNull(demand); Assert.AreEqual(demand.Id, 1); }
public async Task Then_If_Null_Returned_Then_Not_Found_Response_Returned( Guid id, GetCourseDemandQueryResult queryResult, [Frozen] Mock <IMediator> mediator, [Greedy] DemandController controller) { //Arrange queryResult.EmployerDemand = null; mediator.Setup(x => x.Send(It.Is <GetCourseDemandQuery>(c => c.Id.Equals(id)), CancellationToken.None)) .ReturnsAsync(queryResult); //Act var actual = await controller.Get(id) as NotFoundResult; //Assert Assert.IsNotNull(actual); actual.StatusCode.Should().Be((int)HttpStatusCode.NotFound); }
public async Task Then_The_Demand_Is_Returned_From_Mediator( Guid id, GetCourseDemandQueryResult queryResult, [Frozen] Mock <IMediator> mediator, [Greedy] DemandController controller) { //Arrange mediator.Setup(x => x.Send(It.Is <GetCourseDemandQuery>(c => c.Id.Equals(id)), CancellationToken.None)) .ReturnsAsync(queryResult); //Act var actual = await controller.Get(id) as ObjectResult; //Assert Assert.IsNotNull(actual); actual.StatusCode.Should().Be((int)HttpStatusCode.OK); var actualModel = actual.Value as GetCourseDemandResponse; Assert.IsNotNull(actualModel); actualModel.Id.Should().Be(queryResult.EmployerDemand.Id); }