示例#1
0
        public async Task GetAddressWithTenantShouldReturnOkIfFoundInDatabase()
        {
            // Arrange
            var addressId = 1;

            var address = new Address()
            {
                Id             = addressId,
                Country        = "Polska",
                City           = "Sopot",
                Street         = "Ciasna",
                BuildingNumber = "1",
                FlatNumber     = "69",
                PostalCode     = "80-765",
                Tenant         = new Tenant()
                {
                    Id            = 1,
                    NIP           = "9876500011",
                    PESEL         = "09876500011",
                    IsCompany     = true,
                    CompanyName   = "Szlachta nie Pracuje",
                    PhonePrefix   = "0048",
                    PhoneNumber   = "888031303",
                    Name          = "Janusz",
                    Surname       = "Nowak",
                    DisplayOnWeb  = true,
                    AddressId     = 1,
                    AspNetUsersId = 69
                }
            };

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

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

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