public async Task Then_The_AccountLegalEntity_Is_Added_To_The_Repository_And_Committed() { //Arrange var expectedAccountLegalEntity = new AccountLegalEntity { Id = Guid.NewGuid(), ReservationLimit = 1, AccountId = 1234, LegalEntityId = 543, AccountLegalEntityId = 5677, AgreementSigned = true, AccountLegalEntityName = "Test" }; _dataContext.Setup(x => x.AccountLegalEntities) .ReturnsDbSet(new List <AccountLegalEntity>()); _dataContext.Setup(x => x.Database) .Returns(_dataFacade.Object); _accountLegalEntityRepository = new Data.Repository.AccountLegalEntityRepository(_dataContext.Object, Mock.Of <ILogger <Data.Repository.AccountLegalEntityRepository> >()); //Act await _accountLegalEntityRepository.Add(expectedAccountLegalEntity); //Assert _dataContext.Verify(x => x.SaveChanges(), Times.Once); _dbContextTransaction.Verify(x => x.Commit(), Times.Once); }
public async Task Then_The_Item_Is_Not_Saved_If_It_Already_Exists() { //Arrange var expectedAccountLegalEntity = new AccountLegalEntity { Id = Guid.NewGuid(), ReservationLimit = 1, AccountId = 1234, LegalEntityId = 543, AccountLegalEntityId = 5677, AgreementSigned = true, AccountLegalEntityName = "Test" }; _dataContext.Setup(x => x.AccountLegalEntities) .ReturnsDbSet(new List <AccountLegalEntity> { expectedAccountLegalEntity }); _dataContext.Setup(x => x.Database) .Returns(_dataFacade.Object); _accountLegalEntityRepository = new Data.Repository.AccountLegalEntityRepository(_dataContext.Object, Mock.Of <ILogger <Data.Repository.AccountLegalEntityRepository> >()); //Act await _accountLegalEntityRepository.Add(expectedAccountLegalEntity); //Assert _dataContext.Verify(x => x.SaveChanges(), Times.Never); }
public void Arrange() { _dbAccountLegalEntity = new AccountLegalEntity { Id = Guid.NewGuid(), AccountId = 8376234, AgreementSigned = false, LegalEntityId = 4, }; _updatedAccountLegalEntity = new AccountLegalEntity { Id = Guid.NewGuid(), AccountId = 8376234, AgreementSigned = false, LegalEntityId = 4, }; _dbContextTransaction = new Mock <IDbContextTransaction>(); _dbContext = new Mock <DbContext>(); _dataContext = new Mock <IReservationsDataContext>(); _dataFacade = new Mock <DatabaseFacade>(_dbContext.Object); _dataFacade.Setup(x => x.BeginTransaction()).Returns(_dbContextTransaction.Object); _dataContext.Setup(x => x.Database) .Returns(_dataFacade.Object); _dataContext.Setup(x => x.AccountLegalEntities).ReturnsDbSet(new List <AccountLegalEntity> { _dbAccountLegalEntity }); _accountLegalEntityRepository = new Data.Repository.AccountLegalEntityRepository(_dataContext.Object, Mock.Of <ILogger <Data.Repository.AccountLegalEntityRepository> >()); }