public async Task EstateManagementRepository_GetEstate_EstateNotFound_ErrorThrown(TestDatabaseType testDatabaseType) { EstateReportingContext context = await EstateManagementRepositoryTests.GetContext(Guid.NewGuid().ToString("N"), testDatabaseType); var dbContextFactory = this.GetMockDbContextFactory(); Mock <IModelFactory> modelFactory = new Mock <IModelFactory>(); dbContextFactory.Setup(d => d.GetContext(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(context); modelFactory.Setup(m => m.ConvertFrom(It.IsAny <Estate>(), It.IsAny <List <EstateOperator> >(), It.IsAny <List <EstateSecurityUser> >())) .Returns(new Models.Estate.Estate()); EstateManagementRepository estateManagementRepository = new EstateManagementRepository(dbContextFactory.Object, modelFactory.Object); Should.Throw <NotFoundException>(async() => { await estateManagementRepository.GetEstate(TestData.EstateId, CancellationToken.None); }); }
public async Task EstateManagementRepository_GetEstate_EstateRetrieved(TestDatabaseType testDatabaseType) { EstateReportingContext context = await EstateManagementRepositoryTests.GetContext(Guid.NewGuid().ToString("N"), testDatabaseType); context.Estates.Add(TestData.EstateEntity); context.EstateOperators.Add(TestData.EstateOperatorEntity); context.EstateSecurityUsers.Add(TestData.EstateSecurityUserEntity); await context.SaveChangesAsync(); var dbContextFactory = this.GetMockDbContextFactory(); Mock <IModelFactory> modelFactory = new Mock <IModelFactory>(); dbContextFactory.Setup(d => d.GetContext(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(context); modelFactory.Setup(m => m.ConvertFrom(It.IsAny <Estate>(), It.IsAny <List <EstateOperator> >(), It.IsAny <List <EstateSecurityUser> >())) .Returns(new Models.Estate.Estate()); EstateManagementRepository estateManagementRepository = new EstateManagementRepository(dbContextFactory.Object, modelFactory.Object); Models.Estate.Estate estateModel = await estateManagementRepository.GetEstate(TestData.EstateId, CancellationToken.None); estateModel.ShouldNotBeNull(); }