Exemplo n.º 1
0
        public async Task GetAdressByIdShouldReturnOkIfFoundInDatabase()
        {
            // Arrange
            var addressId = 1;

            var address = new Address()
            {
                Id             = addressId,
                Country        = "Polska",
                City           = "Sopot",
                Street         = "Ciasna",
                BuildingNumber = "1",
                FlatNumber     = "69",
                PostalCode     = "80-765"
            };

            mockRepo.Setup(x => x.Address).Returns(_addressRepoMock.Object);
            _addressRepoMock.Setup(x => x.GetAddressById(addressId)).ReturnsAsync(address);

            // Act
            var result = await _sut.GetAdressById(addressId);

            // Assert
            Assert.IsType <OkObjectResult>(result);
            Assert.Equal(1, address.Id);
            Assert.IsNotType <NotFoundResult>(result);
        }