Пример #1
0
    public IEnumerable <result> Process(IEnumerable inputs)
    {
        foreach (input i in inputs)
        {
            var strategy = strategies.GetStrategyForType(i.GetType());

            yield return(strategy.Execute(i));
        }
    }
Пример #2
0
    public void SetCollectionShouldMapTypesToImplementations()
    {
        var    strategyCollection = new StrategyCollection <IInlineElementConverter>(new List <IInlineElementConverter>());
        var    mockConverter      = new FakeConverterWithAttribute();
        object dummyObject        = new Object();

        strategyCollection.SetCollection(new List <IInlineElementConverter>()
        {
            mockConverter
        });

        var strategy = strategyCollection.GetStrategyForType(dummyObject.GetType());

        Assert.IsType(mockConverter.GetType(), strategy);
    }
Пример #3
0
    void GetStrategyShouldThrowExceptionWhenTypeIsNotFound()
    {
        var    strategyCollection = new StrategyCollection <IInlineElementConverter>(new List <IInlineElementConverter>());
        var    mockConverter      = new FakeConverterWithAttribute();
        object dummyObject        = new Object();

        strategyCollection.SetCollection(new List <IInlineElementConverter>()
        {
            mockConverter
        });

        Assert.Throws <StrategyNotFoundException>(() =>
        {
            var strategy = strategyCollection.GetStrategyForType(mockConverter.GetType());
        });
    }