public IDescriptorConditionDTO MapFrom(IDescriptorCondition descriptorCondition) { IDescriptorConditionDTO dto = null; if (descriptorCondition.IsAnImplementationOf <MatchTagCondition>()) { dto = new MatchConnditionDTO { Tag = ((MatchTagCondition)descriptorCondition).Tag }; } else { if (descriptorCondition.IsAnImplementationOf <NotMatchTagCondition>()) { dto = new NotMatchConnditionDTO { Tag = ((NotMatchTagCondition)descriptorCondition).Tag }; } else { dto = new MatchAllConditionDTO(); } } return(dto); }
protected override void Context() { var entity = new Parameter(); entity.AddTag("tag1"); entity.AddTag("tag2"); _match = new NotMatchTagCondition("tag1"); _doNotMatch = new NotMatchTagCondition("do not match"); _entityCriteria = new EntityDescriptor(entity); }
protected override async Task Because() { _newInContainer = await sut.MapToModel(_inContainerSnapshot, new SnapshotContext()); _newNotInContainer = await sut.MapToModel(_notInContainerSnapshot, new SnapshotContext()); _newMatchAllCondition = await sut.MapToModel(_matchAllConditionSnapshot, new SnapshotContext()); _newNotMatchAllCondition = await sut.MapToModel(_notMatchAllConditionSnapshot, new SnapshotContext()); _newNotMatchCondition = await sut.MapToModel(_notMatchConditionSnapshot, new SnapshotContext()); }
public IDescriptorConditionDTO MapFrom(IDescriptorCondition descriptorCondition) { switch (descriptorCondition) { case InContainerCondition inContainerCondition: return(new DescriptorConditionDTO(inContainerCondition.Tag, TagType.InContainer, AppConstants.InContainer)); case MatchAllCondition _: return(new DescriptorConditionDTO(string.Empty, TagType.MatchAll, AppConstants.MatchAll)); case MatchTagCondition matchTagCondition: return(new DescriptorConditionDTO(matchTagCondition.Tag, TagType.Match, AppConstants.Match)); case NotMatchTagCondition notMatchTagCondition: return(new DescriptorConditionDTO(notMatchTagCondition.Tag, TagType.NotMatch, AppConstants.NotMatch)); case NotInContainerCondition notInContainerCondition: return(new DescriptorConditionDTO(notInContainerCondition.Tag, TagType.NotInContainer, AppConstants.NotInContainer)); default: throw new ArgumentException($"Cannot create descriptor condition for {descriptorCondition.GetType().Name}"); } }
public void ReplaceIn(IDescriptorCondition descriptorCondition) { _allTagReplacer.Each(r => r.ReplaceIn(descriptorCondition)); }
protected override async Task Because() { _result = await sut.MapToModel(_invalid, new SnapshotContext()); }
protected override async Task Context() { await base.Context(); _invalid = A.Fake <IDescriptorCondition>(); }
public void ReplaceIn(IDescriptorCondition descriptorCondition) { descriptorCondition.Replace(_keyword, _replacement); }
protected override async Task Because() { _result = await sut.MapToModel(_invalid); }