public void ParseShouldFailWhenInvalidEnumerationValue() { // Arrange string name = "some invalid enumeration string value"; // Act Action action = () => { DriverWait.Parse(name); }; // Assert action.Should().Throw <InvalidEnumerationException>(); }
public void ParseShouldReturnCorrectValue() { // Arrange string name = DriverWait.Yes.ToString(); // Act Action action = () => { DriverWait.Parse(name); }; // Assert action.Should().Throw <InvalidEnumerationException>(); }
public async Task <Result> Handle(UpdateTeamCommand command, CancellationToken cancellationToken) { Result result; try { var team = await _teamReadRepository.GetAsync(command.Id); if (team.Version != command.Version) { throw new CommandVersionException(); } team.ChangeName(new Name(command.Name)); team.SetImage(command.Image); team.SetDescription((Description)command.Description); if (Guid.TryParse(command.Layout, out Guid layoutId) && layoutId != default(Guid)) { var layout = new Layout(layoutId); team.SetLayout(layout); } team.SetFilterContent(command.FilterContent); team.ChangeDriverWait(DriverWait.Parse(command.DriverWait)); team.ClearMembers(); foreach (var operatorId in command.Members) { var member = new Member(operatorId); team.AddMember(member); } team.SetVersion(_versionProvider.Generate()); await _teamWriteRepository.UpdateAsync(team); result = Result.Ok(team.Version); } catch (EntityNotFoundDbException) { result = Result.Fail(new List <Failure>() { new HandlerFault() { Code = HandlerFaultCode.NotFound.Name, Message = HandlerFailures.TeamNotFound, Target = "id" } }); } catch (CommandVersionException) { result = Result.Fail(new List <Failure>() { new HandlerFault() { Code = HandlerFaultCode.NotMet.Name, Message = HandlerFailures.NotMet, Target = "version" } }); } catch (UniqueKeyException) { result = Result.Fail(new List <Failure>() { new HandlerFault() { Code = HandlerFaultCode.Conflict.Name, Message = HandlerFailures.ConflictTeam, Target = "name" } }); } catch { result = Result.Fail(CustomFailures.UpdateTeamFailure); } return(result); }