public void TestAddingGettingStrategyToStrategyHolder() { StrategyHolder holder = new StrategyHolder(); BurnableDisposalStrategy burnStrategy = new BurnableDisposalStrategy(); RecyclableDisposalStrategy recStrategy = new RecyclableDisposalStrategy(); StorableDisposalStrategy storeStrategy = new StorableDisposalStrategy(); holder.AddStrategy( typeof(BurnableDisposableAttribute), burnStrategy); holder.AddStrategy( typeof(RecyclableDisposableAttribute), recStrategy); holder.AddStrategy( typeof(StorableDisposableAttribute), storeStrategy); Assert.AreEqual(burnStrategy, holder.GetDisposalStrategy(typeof(BurnableDisposableAttribute))); Assert.AreEqual(recStrategy, holder.GetDisposalStrategy(typeof(RecyclableDisposableAttribute))); Assert.AreEqual(storeStrategy, holder.GetDisposalStrategy(typeof(StorableDisposableAttribute))); }
public void TestRemoveStrategy() { StrategyHolder holder = new StrategyHolder(); BurnableDisposalStrategy burnStrategy = new BurnableDisposalStrategy(); RecyclableDisposalStrategy recStrategy = new RecyclableDisposalStrategy(); StorableDisposalStrategy storeStrategy = new StorableDisposalStrategy(); holder.AddStrategy( typeof(BurnableDisposableAttribute), burnStrategy); holder.AddStrategy( typeof(RecyclableDisposableAttribute), recStrategy); holder.AddStrategy( typeof(StorableDisposableAttribute), storeStrategy); holder.RemoveStrategy(typeof(BurnableDisposableAttribute)); holder.GetDisposalStrategy(typeof(BurnableDisposableAttribute)); }
public void TestStrategyNotFoundThrowsKeyNotFoundException() { StrategyHolder holder = new StrategyHolder(); holder.GetDisposalStrategy(typeof(BurnableDisposableAttribute)); }