Esempio n. 1
0
        public async Task GetAddressByCountryShouldReturnOkIfFoundInDatabase()
        {
            // Arrange
            var country = "Polska";
            var address = new Address()
            {
                Id             = 1,
                Country        = country,
                City           = "Sopot",
                Street         = "Ciasna",
                BuildingNumber = "1",
                FlatNumber     = "69",
                PostalCode     = "80-765"
            };

            mockRepo.Setup(x => x.Address).Returns(_addressRepoMock.Object);
            _addressRepoMock.Setup(x => x.GetAddressByCountry(country)).ReturnsAsync(new[] { address });

            // Act
            var result = await _sut.GetAddressByCountry(country);

            // Assert
            Assert.IsType <OkObjectResult>(result);
            Assert.IsNotType <NotFoundResult>(result);
        }