public async Task ExistingPerson_Update_Updated() { //Arrange const string updatedValue = "Updated"; var unitOfWork = await CompositeKeyRepositoryArranger.TryGetUnitOfWorkRepositoryAsync().ConfigureAwait(false); var person = await CreateAndCommitPersonAsync(unitOfWork).ConfigureAwait(false); var existingEntityId = new object[] { person.Key1, person.Key2, person.Key3 }; //Act var updateOpRes = await unitOfWork.Repository.TryUpdateAsync(existingEntityId, p => { p.FirstName = updatedValue; p.LastName = updatedValue; }).ConfigureAwait(false); //Assert Assert.IsTrue(updateOpRes, updateOpRes.ErrorMessage); var getOpRes = await unitOfWork.Repository.TryGetSingleAsync(existingEntityId) .ConfigureAwait(false); Assert.AreEqual(getOpRes.Value.FirstName, updatedValue); Assert.AreEqual(getOpRes.Value.LastName, updatedValue); }
public async Task NonExistingPerson_Add_Added() { //Arrange var unitOfWork = await CompositeKeyRepositoryArranger.TryGetUnitOfWorkRepositoryAsync().ConfigureAwait(false); var person = CompositeKeyRepositoryArranger.CreatePerson(); //Act var addOpRes = await unitOfWork.Repository.TryAddAsync(person).ConfigureAwait(false); var saveOpRes = await unitOfWork.TryCommitChangesAsync().ConfigureAwait(false); //Assert Assert.IsTrue(addOpRes, addOpRes.ErrorMessage); Assert.IsTrue(saveOpRes, saveOpRes.ErrorMessage); }
public async Task ExistingPerson_Remove_Removed() { //Arrange var unitOfWork = await CompositeKeyRepositoryArranger.TryGetUnitOfWorkRepositoryAsync().ConfigureAwait(false); var person = await CreateAndCommitPersonAsync(unitOfWork).ConfigureAwait(false); var existingEntityId = new object[] { person.Key1, person.Key2, person.Key3 }; //Act var removeOpRes = await unitOfWork.Repository.TryRemoveAsync(existingEntityId) .ConfigureAwait(false); var commitOpRes = await unitOfWork.TryCommitChangesAsync().ConfigureAwait(false); //Assert Assert.IsTrue(commitOpRes, commitOpRes.ErrorMessage); Assert.IsTrue(removeOpRes, removeOpRes.ErrorMessage); var getOpRes = await unitOfWork.Repository.TryGetSingleAsync(existingEntityId) .ConfigureAwait(false); Assert.IsFalse(getOpRes); }
public async Task ExistingPerson_Get_ReturnedExistingPerson() { //Arrange var unitOfWork = await CompositeKeyRepositoryArranger .TryGetUnitOfWorkRepositoryAsync() .ConfigureAwait(false); var person = CompositeKeyRepositoryArranger.CreatePerson(); var addOpRes = await unitOfWork.Repository.TryAddAsync(person); Assert.IsTrue(addOpRes, addOpRes.ErrorMessage); var commitOpRes = await unitOfWork.TryCommitChangesAsync().ConfigureAwait(false); Assert.IsTrue(commitOpRes, commitOpRes.ErrorMessage); //Act var getOpRes = await unitOfWork.Repository.TryGetSingleAsync( new object[] { person.Key1, person.Key2, person.Key3 }) .ConfigureAwait(false); //Assert Assert.IsTrue(getOpRes, getOpRes.ErrorMessage); Assert.AreEqual(getOpRes.Value, person); }