public void PressiusTestObject_ShouldPermutateWithStaticGenerator() { var addedParameterDefinitions = new List <IParameterDefinition> { new ValidLocation() }; var pressiusTestObjectList = Permutor.Generate <PressiusTestObject>( new PressiusTestObjectObjectDefinition(), addedParameterDefinitions).ToList(); pressiusTestObjectList.ShouldNotBeNull(); pressiusTestObjectList.ToList().Count.ShouldBeGreaterThan(0); var objectList = pressiusTestObjectList.ToList(); var integerParams = new IntegerParameter(); var stringParams = new StringParameter(); var validLocation = new ValidLocation(); var id = 1; objectList.ForEach(obj => { _output.WriteLine("Obj: {0} {1} {2}", obj.Id, obj.Name, obj.Address); obj.Id.ShouldBe(id); validLocation.InputCatalogues.ShouldContain(obj.Address); stringParams.InputCatalogues.ShouldContain(obj.Name); id++; }); }
public void OneLocationIsFoundReturnsNoError() { // Arrange var locationResult = new Mock <Location>(); var expectedResult = ValidationResult.Success; var locationId = "good location"; var locationPersistence = new Mock <IAsyncQueryHandler <LocationRetrievalByIdQuery, Location> >(); locationPersistence .Setup(persistence => persistence.Handle(It.Is <LocationRetrievalByIdQuery>(o => o.LocationId == "good location"))) .Returns(Task.FromResult(locationResult.Object)); var serviceProvider = new Mock <IServiceProvider>(); serviceProvider.Setup(context => context.GetService(It.IsAny <Type>())) .Returns(locationPersistence.Object); var sut = new ValidLocation(); // Act var result = sut.GetValidationResult( locationId, new ValidationContext(new object(), serviceProvider.Object, new Dictionary <object, object>())); // Assert Assert.Equal(expectedResult, result); }
public void NullLocationIdSuppliedReturnsError() { // Arrange object locationId = null; var expectedResult = nameof(SystemValidationErrors.Required); var locationPersistence = new Mock <IAsyncQueryHandler <LocationRetrievalByIdQuery, Location> >(); locationPersistence .Setup(persistence => persistence.Handle(It.Is <LocationRetrievalByIdQuery>(o => o.LocationId == string.Empty))) .Returns(Task.FromResult <Location>(null)); var serviceProvider = new Mock <IServiceProvider>(); serviceProvider.Setup(context => context.GetService(It.IsAny <Type>())) .Returns(locationPersistence.Object); var sut = new ValidLocation(); // Act var result = sut.GetValidationResult(locationId, new ValidationContext(new object(), serviceProvider.Object, new Dictionary <object, object>())); // Assert Assert.Equal(expectedResult, result.ErrorMessage); }
public void PressiusTestObject_WithValidLocationAndIntegerGuid_ShouldPermutateWithCustomValues() { var pressius = new Permutor(); var pressiusTestObjectList = pressius .AddParameterDefinition(new ValidLocation()) .AddParameterDefinition(new IntegerGuid()) .AddObjectDefinition(new PressiusTestObjectObjectDefinitionWithIntegerGuid()) .GeneratePermutation <PressiusTestObject>(); pressiusTestObjectList.ShouldNotBeNull(); pressiusTestObjectList.ToList().Count.ShouldBeGreaterThan(0); var objectList = pressiusTestObjectList.ToList(); var integerGuid = new IntegerGuid(); var stringParams = new StringParameter(); var validLocation = new ValidLocation(); objectList.ForEach(obj => { _output.WriteLine("Obj: {0} {1} {2}", obj.Id, obj.Name, obj.Address); integerGuid.InputCatalogues.ShouldContain(obj.Id); validLocation.InputCatalogues.ShouldContain(obj.Address); stringParams.InputCatalogues.ShouldContain(obj.Name); }); }
private void Validate() { bool hasVisa = false; bool allVisaMidsAreValid = true; bool visaIsSynced = true; bool visaIsPartiallySynced = false; bool hasMasterCardMids = false; bool hasMasterCardLocations = false; bool allMasterCardMidsAreValid = true; bool allMasterCardLocationsAreValid = true; bool masterCardIsSynced = true; bool masterCardIsPartiallySynced = false; bool hasAmex = false; bool allAmexMidsAreValid = true; bool amexIsSynced = true; bool amexIsPartiallySynced = false; if (Merchant.Payments != null) { foreach (Payment p in Merchant.Payments) { switch (p.Processor) { case PaymentProcessor.Visa: { hasVisa = IsPaymentContainsVisaMids(p); allVisaMidsAreValid &= (p.PaymentMids != null && hasVisa) ? AreVisaMidsValid(p) : false; visaIsSynced &= p.SyncedWithCommerce; visaIsPartiallySynced |= p.SyncedWithCommerce; break; } case PaymentProcessor.MasterCard: { bool midsFound = IsPaymentContainsMasterCardMids(p); bool locationsFound = IsPaymentContainsMasterCardLocations(p); hasMasterCardMids |= midsFound; hasMasterCardLocations |= locationsFound; if (midsFound) { allMasterCardMidsAreValid &= (p.PaymentMids != null && midsFound) ? AreMasterCardMidsValid(p) : false; } else if (locationsFound) { allMasterCardLocationsAreValid &= (p.PaymentMids != null && locationsFound) ? AreMasterCardLocationsValid(p) : false; } else { allMasterCardLocationsAreValid = false; allMasterCardMidsAreValid = false; } masterCardIsSynced &= p.SyncedWithCommerce; masterCardIsPartiallySynced |= p.SyncedWithCommerce; break; } case PaymentProcessor.Amex: { hasAmex = IsPaymentContainsAmexMids(p); allAmexMidsAreValid &= (p.PaymentMids != null && hasAmex) ? AreAmexMidsValid(p) : false; amexIsSynced &= p.SyncedWithCommerce; amexIsPartiallySynced |= p.SyncedWithCommerce; break; } } } } Visa.Valid = (hasVisa && allVisaMidsAreValid); Visa.Synced = (hasVisa && visaIsSynced); Visa.PartiallySynced = (hasVisa && visaIsPartiallySynced); MasterCard.Valid = (hasMasterCardMids && hasMasterCardLocations && allMasterCardMidsAreValid && allMasterCardLocationsAreValid); MasterCard.Synced = (hasMasterCardMids && hasMasterCardLocations && masterCardIsSynced); MasterCard.PartiallySynced = (hasMasterCardMids && hasMasterCardLocations && masterCardIsPartiallySynced); Amex.Valid = (hasAmex && allAmexMidsAreValid); Amex.Synced = (hasAmex && amexIsSynced); Amex.PartiallySynced = (hasAmex && amexIsPartiallySynced); ValidLocation = (Merchant.Location != null && Merchant.Location.Latitude != 0 && Merchant.Location.Longitude != 0); Merchant.ExtendedAttributes["ValidLocation"] = ValidLocation.ToString().ToLower(); }
public void Execute(Bitmap Image) { CurrState.Execute(Image); if (CurrState == States[0]) //SS { Val = ValidLocation.FALSE; CSearchState Curr = CurrState as CSearchState; if (Curr.TargetFoundCycle >= Curr.MaxCycles) { (States[1] as CTrackState).CurrX = Curr.CurrX; (States[1] as CTrackState).CurrY = Curr.CurrY; CurrState = States[1]; Curr.TargetFoundCycle = 0; } } else //TS { if (CurrState.Validity == ValidLocation.FALSE) { CurrState = States[0]; Val = ValidLocation.FALSE; } else { Val = ValidLocation.TRUE; } } }
public CState() { Validity = ValidLocation.FALSE; CurrX = 0; CurrY = 0; }