コード例 #1
0
        public async Task CreateRestaurantInfo_Returns_CreatedAtRouteResult()
        {
            //Arrange
            _fixture.MockRestaurantInfoRepository.Setup(x => x.CreateRestaurantInfoAsync(It.IsAny <CreateRestaurantInfoDto>()))
            .ReturnsAsync(_fixture.CreateRestaurantInfoDtoResult);

            var controller = new RestaurantInfoController(_fixture.MockRestaurantInfoRepository.Object);

            //Act
            var result = await controller.CreateRestaurantInfo(_fixture.ValidCreateRestaurantInfoDto, _fixture.ApiVersion);

            //Assert
            var objectResult = result.Should().BeOfType <CreatedAtRouteResult>().Subject;

            objectResult.StatusCode.Should().Be(201);
            objectResult.RouteValues !["id"].Should().Be(1);
コード例 #2
0
        public async Task GetRestaurantInfos_Returns_OkObjectResult()
        {
            //Arrange
            _fixture.MockRestaurantInfoRepository.Setup(x => x.GetRestaurantInfosAsync())
            .ReturnsAsync(_fixture.RestaurantInfos);

            var controller = new RestaurantInfoController(_fixture.MockRestaurantInfoRepository.Object);

            //Act
            var result = await controller.GetRestaurantInfos();

            //Assert
            var okResult = result.Should().BeOfType <OkObjectResult>().Subject;
            var info     = okResult.Value.Should().BeAssignableTo <IEnumerable <GetRestaurantInfoDto> >().Subject;

            okResult.StatusCode.Should().Be(200);
            info.Should().HaveCount(1);
        }
コード例 #3
0
        public async Task GetRestaurantInfo_Returns_OkObjectResult()
        {
            //Arrange
            var id = 1;

            _fixture.MockRestaurantInfoRepository.Setup(x => x.GetRestaurantInfoAsync(It.IsAny <int>()))
            .ReturnsAsync(_fixture.RestaurantInfos.Single(d => d.Id == id));

            var controller = new RestaurantInfoController(_fixture.MockRestaurantInfoRepository.Object);

            //Act
            var result = await controller.GetRestaurantInfo(id);

            //Assert
            var okResult = result.Should().BeOfType <OkObjectResult>().Subject;
            var info     = okResult.Value.Should().BeAssignableTo <GetRestaurantInfoDto>().Subject;

            okResult.StatusCode.Should().Be(200);
            info.Id.Should().Be(id);
            info.Name.Should().Be("Golden Dining");
            info.Email.Should().Be("*****@*****.**");
        }