public async Task SaveFormDataFragmentAsyncThrowsNotFoundExceptionIfEntityDoesNotExistTest() { var mockDataFragmentService = new Mock<IDataFragmentService>(); var mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(x => x.Repository<FormDataEntity>().GetAsync(It.IsAny<Expression<Func<FormDataEntity, bool>>>())) .Returns(() => Task.FromResult<FormDataEntity>(null)); var persistenceService = new FormsPersistenceFragmentService(mockUnitOfWork.Object, mockDataFragmentService.Object); await persistenceService.SaveFormDataFragmentAsync(It.IsAny<Guid>(), It.IsAny<string>(), It.IsAny<KeyValuePair<string, string>>(), It.IsAny<string>()); }
public async Task SaveFormDataFragmentAsyncCallsCorrectDataFragmentServiceMethodTest() { var entity = new FormDataEntity { SerializedFormData = "SerializedObject" }; var mockDataFragmentService = new Mock<IDataFragmentService>(); var mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(x => x.Repository<FormDataEntity>().GetAsync(It.IsAny<Expression<Func<FormDataEntity, bool>>>())) .Returns(() => Task.FromResult(entity)); var persistenceService = new FormsPersistenceFragmentService(mockUnitOfWork.Object, mockDataFragmentService.Object); await persistenceService.SaveFormDataFragmentAsync(It.IsAny<Guid>(), It.IsAny<string>(), It.IsAny<KeyValuePair<string, string>>(), It.IsAny<string>()); mockDataFragmentService.Verify(m => m.UpdateFragment(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<KeyValuePair<string, string>>())); }