public void TestAddingTypeWithNullStrategyShouldThrowException() { this.strategyHolder = new StrategyHolder(); this.strategyHolder.AddStrategy( typeof(RecyclableGarbageDisposableAttribute), null); }
public void TestAddingNullTypeWithStrategyShouldThrowException() { this.strategyHolder = new StrategyHolder(); this.strategyHolder.AddStrategy( null, new RecyclableGarbageDisposableStrategy()); }
public void Initialize() { this.strategyHolder = new StrategyHolder(); this.mockedStrategy = new Mock <IGarbageDisposalStrategy>(); this.data = new Dictionary <Type, IGarbageDisposalStrategy>(); }
public GarbageProcessor(IProcessingData processingData, IStrategyHolder strategyHolder) { this.ProcessingData = processingData; this.StrategyHolder = new StrategyHolder(); this.InitialiseStrategyHoder(); }
public RecyclingStationController(GarbageFactory garbageFactory, IStrategyHolder strategyHolder, IRecyclingStation recyclingStation) { this.garbageFactory = garbageFactory; this.RecylingStation = recyclingStation; this.strategyHolder = strategyHolder; this.garbageProcessor = new GarbageProcessor(strategyHolder); }
public void TestRemovingNonExistantStrategyShouldThrowException() { this.strategyHolder = new StrategyHolder(); this.strategyHolder.AddStrategy( typeof(RecyclableGarbageDisposableAttribute), new RecyclableGarbageDisposableStrategy()); this.strategyHolder.RemoveStrategy(typeof(BurnableGarbageDisposableAttribute)); }
public void Initialize() { this.strategyHolder = new StrategyHolder(); this.strategyHolder.AddStrategy(typeof(BurnableAttribute), new BurnableStrategy()); this.strategyHolder.AddStrategy(typeof(RecyclableAttribute), new RecyclableStrategy()); this.garbageProcessor = new GarbageProcessor(this.strategyHolder); }
public void TestRemoveStrategyShouldDecreaseCountCorrectly() { this.strategyHolder = new StrategyHolder(); this.strategyHolder.AddStrategy( typeof(RecyclableGarbageDisposableAttribute), new RecyclableGarbageDisposableStrategy()); this.strategyHolder.RemoveStrategy(typeof(RecyclableGarbageDisposableAttribute)); Assert.AreEqual(0, this.strategyHolder.GetDisposalStrategies.Count, "Removing strategy should decrease count by 1!"); }
public void TestAddingSameTypeShouldNotIncreaseCount() { this.strategyHolder = new StrategyHolder(); this.strategyHolder.AddStrategy( typeof(RecyclableGarbageDisposableAttribute), new RecyclableGarbageDisposableStrategy()); this.strategyHolder.AddStrategy( typeof(RecyclableGarbageDisposableAttribute), new BurnableGarbageDisposableStrategy()); }
public Engine(IResourcesDatabase resDatabase) { this.resDatabase = resDatabase; this.strategyholder = new StrategyHolder(); this.garbageProcessor = new GarbageProcessor(this.strategyholder); this.resController = new ResourcesController(this.resDatabase, this.garbageProcessor); this.comExecutor = new CommandExecutor(this.resController); this.consoleReader = new ConsoleReader(); this.consoleWriter = new ConsoleWriter(); this.inputInterpreter = new InputInterpreter(); }
public void TestAddingAStrategyShouldAddItCorrectly() { this.strategyHolder = new StrategyHolder(); this.strategyHolder.AddStrategy( typeof(RecyclableGarbageDisposableAttribute), new RecyclableGarbageDisposableStrategy()); var isContained = this.strategyHolder.GetDisposalStrategies.ContainsKey(typeof(RecyclableGarbageDisposableAttribute)); Assert.IsTrue(isContained, "After adding attribute type-strategy pair strategies should contain it!"); }
public void Initialize() { this.strategyHolder = new StrategyHolder(); var mockStrategy = new Mock <IGarbageDisposalStrategy>(); var mockStrategy2 = new Mock <IGarbageDisposalStrategy>(); this.mockedDisposableAttribute = typeof(MockedDisposableAttribute); this.mockedDisposableAttribute2 = typeof(SecondMockedDisposableAttribute); this.abstractDisposableAttribute = typeof(AbstractDisposableAttribute); this.mockedStrategy = mockStrategy; this.mockedStrategy2 = mockStrategy2; }
public void TestAddingStrategyIncreasesCountCorrectly() { this.strategyHolder = new StrategyHolder(); this.strategyHolder.AddStrategy( typeof(RecyclableGarbageDisposableAttribute), new RecyclableGarbageDisposableStrategy()); Assert.AreEqual( 1, this.strategyHolder.GetDisposalStrategies.Count, "Add Strategy should increase count of strategies correctly!"); }
public Engine( IRecyclingStationRepository repository, IGarbageProcessor garbageProcessor, IStrategyHolder strategyHolder, IInputOutput inputOutput) { this.repository = repository; this.garbageProcessor = garbageProcessor; this.strategyHolder = strategyHolder; this.inputOutput = inputOutput; this.LoadStrategies(); }
public void RemoveStrategyWithInvalidAttributeTypeShouldBeUnsucceful() { // Act this.strategies[typeof(RecyclableStrategyAttribute)] = new RecyclableGarbageDisposalStrategy(); this.strategyHolder = new StrategyHolder(this.strategies); // Act var success = this.strategyHolder.RemoveStrategy(typeof(string)); // Assert Assert.AreEqual(false, success, "Removing strategy with invalid attribute type was unsuccessful!"); }
public void RemoveStrategyWithExisingAttributeTypeShouldBeSuccessful() { // Act this.strategies[typeof(RecyclableStrategyAttribute)] = new RecyclableGarbageDisposalStrategy(); this.strategies[typeof(BurnableStrategyAttribute)] = new BurnableGarbageDisposalStrategy(); this.strategies[typeof(StorableStrategyAttribute)] = new StorableGarbageDisposalStrategy(); this.strategyHolder = new StrategyHolder(this.strategies); // Act var success = this.strategyHolder.RemoveStrategy(typeof(RecyclableStrategyAttribute)); // Assert Assert.AreEqual(true, success, "Existing existing strategy was not removed!"); }
public void TestRemovingStrategyRemovesCorrectStrategy() { this.strategyHolder = new StrategyHolder(); this.strategyHolder.AddStrategy( typeof(RecyclableGarbageDisposableAttribute), new RecyclableGarbageDisposableStrategy()); this.strategyHolder.AddStrategy( typeof(BurnableGarbageDisposableAttribute), new BurnableGarbageDisposableStrategy()); this.strategyHolder.RemoveStrategy(typeof(RecyclableGarbageDisposableAttribute)); var isContained = this.strategyHolder.GetDisposalStrategies.ContainsKey(typeof(RecyclableGarbageDisposableAttribute)); Assert.IsFalse(isContained, "After removing attribute type-strategy pair strategies should not contain it!"); }
public void RemoveStrategyWithExistingAttributeTypesShouldDecreaseStrategiesCount() { // Act this.strategies[typeof(RecyclableStrategyAttribute)] = new RecyclableGarbageDisposalStrategy(); this.strategies[typeof(BurnableStrategyAttribute)] = new BurnableGarbageDisposalStrategy(); this.strategies[typeof(StorableStrategyAttribute)] = new StorableGarbageDisposalStrategy(); this.strategyHolder = new StrategyHolder(this.strategies); // Act var success = this.strategyHolder.RemoveStrategy(typeof(RecyclableStrategyAttribute)); // Assert Assert.AreEqual(2, this.strategyHolder.GetDisposalStrategies.Count, "Removing existing strategies did not decrease strategies count!"); }
public void RemoveStrategyWithNonExistingAttributeTypeShouldNotChangeStrategiesCount() { // Act this.strategies[typeof(RecyclableStrategyAttribute)] = new RecyclableGarbageDisposalStrategy(); this.strategyHolder = new StrategyHolder(this.strategies); var initialStrategiesCount = this.strategyHolder.GetDisposalStrategies.Count; // Act var success = this.strategyHolder.RemoveStrategy(typeof(StorableGarbageDisposalStrategy)); // Assert Assert.AreEqual(initialStrategiesCount, this.strategyHolder.GetDisposalStrategies.Count, "Strategies count changed upon removing a non-existing strategy!"); }
public void GetDisposalStrategiesShouldMatchTheInputStrategies() { // Arrange this.strategies[typeof(RecyclableStrategyAttribute)] = new RecyclableGarbageDisposalStrategy(); this.strategies[typeof(BurnableStrategyAttribute)] = new BurnableGarbageDisposalStrategy(); this.strategies[typeof(StorableStrategyAttribute)] = new StorableGarbageDisposalStrategy(); this.strategyHolder = new StrategyHolder(this.strategies); // Act var fetchedStrategies = this.strategyHolder.GetDisposalStrategies; // Assert CollectionAssert.AreEqual(this.strategies, fetchedStrategies, "Fetched strategies did not match input strategies!"); }
public void TestAddingSameMultipleStrategiesShouldIncreaseCount() { this.strategyHolder = new StrategyHolder(); this.strategyHolder.AddStrategy( typeof(RecyclableGarbageDisposableAttribute), new RecyclableGarbageDisposableStrategy()); this.strategyHolder.AddStrategy( typeof(BurnableGarbageDisposableAttribute), new BurnableGarbageDisposableStrategy()); this.strategyHolder.AddStrategy( typeof(StorableGarbageDisposableAttribute), new StorableGarbageDisposableStrategy()); Assert.AreEqual( 3, this.strategyHolder.GetDisposalStrategies.Count, "Add Strategy should increase count of strategies correctly when types are different!"); }
public void GetDisposalStrategiesCountShouldEqualInputCount() { // Arrange this.strategies[typeof(RecyclableStrategyAttribute)] = new RecyclableGarbageDisposalStrategy(); this.strategies[typeof(BurnableStrategyAttribute)] = new BurnableGarbageDisposalStrategy(); this.strategies[typeof(StorableStrategyAttribute)] = new StorableGarbageDisposalStrategy(); var inputStrategiesCount = this.strategies.Count; this.strategyHolder = new StrategyHolder(this.strategies); // Act var fetchedStrategiesCount = this.strategyHolder.GetDisposalStrategies.Count; // Assert Assert.AreEqual(inputStrategiesCount, fetchedStrategiesCount, "Fetched strategies count did not match input strategies count!"); }
public void SetUp() { this.strategyHolder = new StrategyHolder(); }
public void TestEmptyCtorWorksCorrectly() { this.strategyHolder = new StrategyHolder(); Assert.AreEqual(0, this.strategyHolder.GetDisposalStrategies.Count, "Strategy Holder Constructor should initialize strategies as empty dictionary"); }
public void InitializeFields() { this.strategyHolder = new StrategyHolder(); this.attribute = new DisposableAttribute(); }
public void TestInit() { this.sh = new StrategyHolder(); }
public void TestInitializer() { this.strategyHolder = new StrategyHolder(); }
public void TestInit() { this.strategies = new Dictionary <Type, IGarbageDisposalStrategy>(); this.strategyHolder = new StrategyHolder(this.strategies); }
public GarbageProcessor(IStrategyHolder strategyHolder) { this.StrategyHolder = strategyHolder; }
public GarbageProcessor(IStrategyHolder strategyHolder) { this.StrategyHolder = strategyHolder; this.AddStratagyHolder(); }