public async Task CreateStockType_Returns_CreatedAtRouteResult() { //Arrange _fixture.MockStockTypeRepository.Setup(x => x.CreateStockTypeAsync(It.IsAny <CreateStockTypeDto>())) .ReturnsAsync(_fixture.CreateStockTypeDtoResult); var controller = new StockTypeController(_fixture.MockStockTypeRepository.Object); //Act var result = await controller.CreateStockType(_fixture.ValidCreateStockTypeDto, _fixture.ApiVersion); //Assert var objectResult = result.Should().BeOfType <CreatedAtRouteResult>().Subject; objectResult.StatusCode.Should().Be(201); objectResult.RouteValues !["id"].Should().Be(3);
public async Task GetStockTypes_Returns_OkObjectResult() { //Arrange _fixture.MockStockTypeRepository.Setup(x => x.GetStockTypesAsync()) .ReturnsAsync(_fixture.StockTypes); var controller = new StockTypeController(_fixture.MockStockTypeRepository.Object); //Act var result = await controller.GetStockTypes(); //Assert var okResult = result.Should().BeOfType <OkObjectResult>().Subject; var stockTypes = okResult.Value.Should().BeAssignableTo <IEnumerable <GetStockTypeDto> >().Subject; okResult.StatusCode.Should().Be(200); stockTypes.Should().HaveCount(2); }
public async Task GetStockType_Returns_OkObjectResult() { //Arrange var id = 2; _fixture.MockStockTypeRepository.Setup(x => x.GetStockTypeAsync(It.IsAny <int>())) .ReturnsAsync(_fixture.StockTypes.Single(d => d.Id == id)); var controller = new StockTypeController(_fixture.MockStockTypeRepository.Object); //Act var result = await controller.GetStockType(id); //Assert var okResult = result.Should().BeOfType <OkObjectResult>().Subject; var stockType = okResult.Value.Should().BeAssignableTo <GetStockTypeDto>().Subject; okResult.StatusCode.Should().Be(200); stockType.Id.Should().Be(id); stockType.Type.Should().Be("Beverage"); stockType.Description.Should().Be("beverage items"); }