public static IEnumerable<Card> GetLeadableCards(this PlayerBase player, DealView dealInProgress) { var validator = new LeadValidator(dealInProgress); return player .CardList .Where(c => validator .Validate(new Play(c, player)) .IsValid) .OrderBy(c => c.Suit) .ThenBy(c => c.Rank); }
public void ValidLeadWithEmptyContextTest() { var validator = new LeadValidator(_validatorFactory.Object,_loggingClient.Object); _testLeadEntity.Context = null; bool expectedValue = false; var isValid = validator.ValidLead(_testLeadEntity); Assert.AreEqual(expectedValue, isValid); }
public void ValidLeadWithEmptyContextKeysTest() { var validator = new LeadValidator(_validatorFactory.Object,_loggingClient.Object); activityId = null; identityId = null; sessionId = null; quotedProductId = null; bool expectedValue = false; var isValid = validator.ValidLead(_testLeadEntity); Assert.AreEqual(expectedValue, isValid); }
public void InvalidLeadTest() { var validator = new LeadValidator(_validatorFactory.Object, _loggingClient.Object); _testLeadEntity.Context = new IContext[] { new DefaultContext ( LMS.Modules.LeadEntity.Interface.Constants.ContextKeys.ActivityGuidKey, Guid.NewGuid().ToString() ) , new DefaultContext ( LMS.Modules.LeadEntity.Interface.Constants.ContextKeys.SessionGuidKey, Guid.NewGuid().ToString() ) , new DefaultContext ( LMS.Modules.LeadEntity.Interface.Constants.ContextKeys.IdentityGuidKey, Guid.NewGuid().ToString() ) , new DefaultContext ( LMS.Modules.LeadEntity.Interface.Constants.ContextKeys.QuotedProductKey, Guid.NewGuid().ToString() ) }; //activityId = "ActivityGUID"; //identityId = "IdentityGUID"; //sessionId = "SessionGUID"; //quotedProductId = "QuotedProduct"; bool expectedValue = false; ////var activityGuidValue = _testLeadEntity.Context.SingleOrDefault(item => item.Id == _testLeadEntity..Interface.Constants.ContextKeys.ActivityGuidKey)?.Value; var isValid = validator.ValidLead(_testLeadEntity); Assert.AreEqual(expectedValue, isValid); }
public IActionResult Put(int id, [FromBody] Lead leadParam) { try { //validate var validator = new LeadValidator(); var results = validator.Validate(leadParam); if (results.IsValid) { _leadRepository.Update(leadParam); return(Ok()); } else { return(BadRequest("Invalid input")); } } catch (ApplicationException ex) { return(BadRequest(ex.Message)); } }
public IActionResult Post([FromBody] Lead lead) { try { //validate var validator = new LeadValidator(); var results = validator.Validate(lead); if (results.IsValid) { lead.DateCreated = DateTime.Today; _leadRepository.Insert(lead); return(Created(string.Empty, lead)); //Intentionally not writing url in response } else { return(BadRequest("Invalid input")); } } catch (ApplicationException ex) { return(BadRequest(ex.Message)); } }
public void MockedParamLeadvalidatorConstructorNullLoggerClientTest() { var validator = new LeadValidator(null, null); }