コード例 #1
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);
    }
コード例 #2
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());
        });
    }