コード例 #1
0
        public async Task GetRestaurantInfo_WhenCalledWithEmptyPostCode_ReturnsNul()
        {
            //Arrange the resources
            SetupMocks();
            var service = new RestaurantInfoService(logger, restaurant, cache);

            //Act on the functionality
            var response = await service.GetRestaurantInfo(null);

            //Assert the result against the expected
            Assert.Null(response);
        }
コード例 #2
0
        public async Task GetRestaurantInfoAsync_Returns_Null()
        {
            //Arrange
            var id      = 10;
            var service = new RestaurantInfoService(_myRestaurantContext);

            //Act
            var result = await service.GetRestaurantInfoAsync(d => d.Id == id);

            //Assert
            result.Should().BeNull();
        }
コード例 #3
0
        public async Task GetRestaurantInfosAsync_Returns_RestaurantInfos()
        {
            //Arrange
            var service = new RestaurantInfoService(_myRestaurantContext);

            //Act
            var result = await service.GetRestaurantInfosAsync();

            //Assert
            result.Should().BeAssignableTo <IEnumerable <RestaurantInfo> >();
            result.Should().HaveCount(1);
        }
コード例 #4
0
        public async Task GetRestaurantInfo_WhenCalled_ReturnsNameOfRestaurant()
        {
            //Arrange the resources
            SetupMocks();
            var    service = new RestaurantInfoService(logger, restaurant, cache);
            string initial = "sw1A";

            //Act on the functionality
            var response = await service.GetRestaurantInfo(initial);

            //Assert the result against the expected
            Assert.True(response.Datas.Exists(x => x.Name != null));
        }
コード例 #5
0
        public async Task GetRestaurantInfo_WhenCalled_ReturnResponse()
        {
            //Arrange the resources
            SetupMocks();
            var    service = new RestaurantInfoService(logger, restaurant, cache);
            string initial = "sw1A";

            //Act on the functionality
            var response = await service.GetRestaurantInfo(initial);

            //Assert the result against the expected
            Assert.NotNull(response);
        }
コード例 #6
0
        public async Task GetRestaurantInfoAsync_Returns_RestaurantInfo()
        {
            //Arrange
            var id      = 1;
            var service = new RestaurantInfoService(_myRestaurantContext);

            //Act
            var result = await service.GetRestaurantInfoAsync(d => d.Id == id);

            //Assert
            result.Should().BeAssignableTo <RestaurantInfo>();
            result !.Id.Should().Be(id);
            result.Name.Should().Be("Golden Dining");
        }
コード例 #7
0
        public async Task DeleteRestaurantInfoAsync_Successfully_Deleted()
        {
            //Arrange
            var id      = 1;
            var service = new RestaurantInfoService(_myRestaurantContext);

            //Act
            var dbRestaurantInfo = await service.GetRestaurantInfoAsync(d => d.Id == id);

            await service.DeleteRestaurantInfoAsync(dbRestaurantInfo !);

            var result = await service.GetRestaurantInfoAsync(d => d.Id == id);

            //Assert
            result.Should().BeNull();
        }
コード例 #8
0
        public async Task AddRestaurantInfoAsync_Returns_New_RestaurantInfo()
        {
            //Arrange
            var service = new RestaurantInfoService(_myRestaurantContext);

            //Act
            var result = await service.AddRestaurantInfoAsync(new RestaurantInfo
            {
                Name     = "Golden Dining",
                Address  = "Kandy Road, Kaithady",
                City     = "Jaffna",
                Country  = "Sri Lanka",
                LandLine = "+9423454545",
                Mobile   = "+94567876786",
                Email    = "*****@*****.**"
            });

            //Assert
            result.Should().BeAssignableTo <RestaurantInfo>();
            result.Name.Should().Be("Golden Dining");
            result.LandLine.Should().Be("+9423454545");
        }
コード例 #9
0
        public async Task UpdateRestaurantInfoAsync_Successfully_Updated()
        {
            //Arrange
            var id      = 1;
            var service = new RestaurantInfoService(_myRestaurantContext);

            //Act
            var dbRestaurantInfo = await service.GetRestaurantInfoAsync(d => d.Id == id);

            dbRestaurantInfo !.LandLine = "+9423656565";
            dbRestaurantInfo.Mobile     = "+9423989898";
            dbRestaurantInfo.Email      = "*****@*****.**";

            await service.UpdateRestaurantInfoAsync(dbRestaurantInfo);

            var result = await service.GetRestaurantInfoAsync(d => d.Id == id);

            //Assert
            result.Should().BeAssignableTo <RestaurantInfo>();
            result !.Id.Should().Be(id);
            result.LandLine.Should().Be("+9423656565");
            result.Mobile.Should().Be("+9423989898");
            result.Email.Should().Be("*****@*****.**");
        }