public async Task SuccessToAddLogIfMandatoryFieldsAreFilled() { await _logRepoMock.InsertLog(Arg.Any <UserLog>()); await _logService.AddLog(TimeSpan.FromMinutes(10), UserActionTypes.GetAnagrams, "oskaras"); await _logRepoMock.Received().InsertLog(Arg.Any <UserLog>()); }
public Task AddLog(TimeSpan timeElapsed, UserActionTypes actionType, string searchPhrase = null) { if (actionType == UserActionTypes.GetAnagrams && (string.IsNullOrEmpty(searchPhrase) || TimeSpan.Zero == timeElapsed)) { throw new Exception("Cannot add UserLog, because UserLog is empty"); } else if (actionType != UserActionTypes.GetAnagrams && TimeSpan.Zero == timeElapsed) { throw new Exception("Cannot add UserLog, because UserLog is empty"); } var log = new UserLog(GetUserIp(), searchPhrase, timeElapsed, actionType.ToString()); return(_userLogRepository.InsertLog(log)); }