Beispiel #1
0
        public async Task GetAddressWithLandlordShouldReturnOkIfFoundInDatabase()
        {
            // Arrange
            var addressId = 1;

            var address = new Address()
            {
                Id             = addressId,
                Country        = "Polska",
                City           = "Sopot",
                Street         = "Ciasna",
                BuildingNumber = "1",
                FlatNumber     = "69",
                PostalCode     = "80-765",
                Landlord       = new Landlord()
                {
                    Id          = 1,
                    Name        = "Janusz",
                    Surname     = "Kiełbasa",
                    IsCompany   = false,
                    IsVATPayer  = false,
                    PhoneNumber = "948387397",
                    BankAccount = "67843186627845100000123456"
                }
            };

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

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

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