Ejemplo n.º 1
0
        public void TestEmptyCtorShouldWorkCorrectly()
        {
            this.garbageProcessor = new GarbageProcessor();
            var isValid = this.garbageProcessor.StrategyHolder != null;

            Assert.IsTrue(isValid, "Ctor with parameter strategy holder should initialize strategy holder!");
        }
 public RecyclingStationController(GarbageFactory garbageFactory, IStrategyHolder strategyHolder, IRecyclingStation recyclingStation)
 {
     this.garbageFactory   = garbageFactory;
     this.RecylingStation  = recyclingStation;
     this.strategyHolder   = strategyHolder;
     this.garbageProcessor = new GarbageProcessor(strategyHolder);
 }
Ejemplo n.º 3
0
 public CommandHandler(IRecyclingStation recyclingStation, IGarbageProcessor garbageProcessor)
 {
     this.RecyclingStation      = recyclingStation;
     this.GarbageProcessor      = garbageProcessor;
     this.managementRequirement = null;
     this.InitializeStrategies();
 }
Ejemplo n.º 4
0
        public void Initialize()
        {
            this.mockedStrategyHolder = new Mock <IStrategyHolder>();
            Dictionary <Type, IGarbageDisposalStrategy> strategies = new Dictionary <Type, IGarbageDisposalStrategy>();

            var mockStrategy     = new Mock <IGarbageDisposalStrategy>();
            var mockStrategy2    = new Mock <IGarbageDisposalStrategy>();
            var mockProcessData  = new Mock <IProcessingData>();
            var mockProcessData2 = new Mock <IProcessingData>();

            this.mockedDisposableAttribute  = typeof(MockedDisposableAttribute);
            this.mockedDisposableAttribute2 = typeof(SecondMockedDisposableAttribute);
            mockProcessData.Setup(x => x.CapitalBalance).Returns(10d);
            mockProcessData.Setup(x => x.EnergyBalance).Returns(20d);
            mockProcessData2.Setup(x => x.CapitalBalance).Returns(-50d);
            mockProcessData2.Setup(x => x.EnergyBalance).Returns(-100d);
            mockStrategy.Setup(x => x.ProcessGarbage(It.IsAny <IWaste>())).Returns(mockProcessData.Object);
            mockStrategy2.Setup(x => x.ProcessGarbage(It.IsAny <IWaste>())).Returns(mockProcessData2.Object);

            this.mockedProcessData  = mockProcessData;
            this.mockedProcessData2 = mockProcessData2;
            this.mockedStrategy     = mockStrategy;
            this.mockedStrategy2    = mockStrategy2;

            strategies.Add(this.mockedDisposableAttribute, this.mockedStrategy.Object);
            strategies.Add(this.mockedDisposableAttribute2, this.mockedStrategy2.Object);

            this.mockedStrategyHolder.Setup(x => x.GetDisposalStrategies)
            .Returns(strategies);
            this.garbageProcessor = new GarbageProcessor(this.mockedStrategyHolder.Object);
        }
        public void CheckGarbageProcessorInitializationWithAGivenStrategyHolder()
        {
            IStrategyHolder testStrategy = new StrategyHolder();

            testStrategy.AddStrategy(typeof(RecyclableGarbage), new RecyclableStrategy());
            this.garbageProcessor = new GarbageProcessor(testStrategy);
            Assert.AreEqual(1, this.garbageProcessor.StrategyHolder.GetDisposalStrategies.Count);
        }
Ejemplo n.º 6
0
        public void TestInit()
        {
            this.gp = new GarbageProcessor();
            var type     = typeof(FakeAttribute);
            var strategy = new FakeStrategy();

            this.gp.StrategyHolder.AddStrategy(type, strategy);
        }
        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 GarbageProcessorShouldThrowErrorIfNoStrategyIsPresentForGivenType()
        {
            IStrategyHolder testStrategy = new StrategyHolder();

            testStrategy.AddStrategy(typeof(RecyclableGarbage), new RecyclableStrategy());
            this.garbageProcessor = new GarbageProcessor(testStrategy);
            IWaste          burnableWasteTestObject = new BurnableGarbage("RecyclMePls", 10, 10);
            IProcessingData tempData = this.garbageProcessor.ProcessWaste(burnableWasteTestObject);
        }
        public void GivingNullGarbageToProcessShouldThrowError()
        {
            IStrategyHolder testStrategy = new StrategyHolder();

            testStrategy.AddStrategy(typeof(RecyclableGarbage), new RecyclableStrategy());
            this.garbageProcessor = new GarbageProcessor(testStrategy);
            IWaste          burnableWasteTestObject = null;
            IProcessingData tempData = this.garbageProcessor.ProcessWaste(burnableWasteTestObject);
        }
Ejemplo n.º 10
0
    public RecyclingManager(IGarbageProcessor garbageProcessor, IWasteFactory wasteFactory)
    {
        this.garbageProcessor = garbageProcessor;
        this.wasteFactory     = wasteFactory;
        this.energyBalance    = 0;
        this.capitalBalance   = 0;

        this.energyRequired  = 0;
        this.capitalRequired = 0;
        this.restrictedType  = null;
    }
 public RecyclingManager(
     IGarbageFactory garbageFactory,
     IGarbageProcessor garbageProcessor,
     IRecyclingManagementRequirement recyclingManagementRequirement,
     IStoredData storedData)
 {
     this.garbageFactory   = garbageFactory;
     this.garbageProcessor = garbageProcessor;
     this.recyclingManagementRequirement = recyclingManagementRequirement;
     this.storedData = storedData;
 }
Ejemplo n.º 12
0
 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 GarbageProcessorProperlyProcessingBurnableGarbageWithBurnableStrategy()
        {
            IStrategyHolder testStrategy = new StrategyHolder();

            testStrategy.AddStrategy(typeof(BurnableGarbage), new BurnableStrategy());
            this.garbageProcessor = new GarbageProcessor(testStrategy);
            IWaste          burnableWasteTestObject = new BurnableGarbage("BurnItUp", 10, 10);
            IProcessingData tempData = this.garbageProcessor.ProcessWaste(burnableWasteTestObject);

            Assert.AreEqual(0, tempData.CapitalBalance);
            Assert.AreEqual(80, tempData.EnergyBalance);
        }
Ejemplo n.º 14
0
        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 InitilizeComponents()
        {
            Mock <IStrategyHolder> strategyHolderMock = new Mock <IStrategyHolder>();

            strategyHolderMock.Setup(m => m.GetDisposalStrategies)
            .Returns(new Dictionary <Type, IGarbageDisposalStrategy>
            {
                { typeof(RecyclableAttribute), new RecyclableGrabageDisposalStrategy() },
                { typeof(BurnableAttribute), new BurnableGarbageDisposalStrategy() },
                { typeof(StorableAttribute), new StorableGarbageDisposalStrategy() }
            });

            this.garbageProcessor = new GarbageProcessor(strategyHolderMock.Object);
        }
Ejemplo n.º 16
0
        public override string Execute(string[] args, IGarbageProcessor garbageProcessor)
        {
            string name        = args[0];
            double weight      = double.Parse(args[1]);
            double volumePerKg = double.Parse(args[2]);
            string waste       = args[3];
            Type   wasteType   = Type.GetType(wasteNameSpace + waste);

            object[] par =
            {
                name,
                weight,
                volumePerKg
            };
            ConstructorInfo constructor = wasteType.GetConstructor(BindingFlags.Instance | BindingFlags.Public,
                                                                   null, new [] { typeof(string), typeof(double), typeof(double) }, null);
            IWaste garbage = (Recyclable)constructor.Invoke(par);
            var    attr    = garbage.GetType().CustomAttributes;


            garbageProcessor.ProcessWaste(garbage);
            strategyHolder.AddStrategy(wasteType, new RecyclableGarbageStrategy());
            return($"“{weight} kg of {name} successfully processed!");
        }
Ejemplo n.º 17
0
 public void Initialize()
 {
     this.waste     = new BurnableGarbage("Paper", 58, 10);
     this.processor = new GarbageProcessor(MyMock.GetMockedStratagyHolder());
 }
Ejemplo n.º 18
0
 public RecyclingManager(IGarbageProcessor garbageProcessor, IGarbageFactory garbageFactory)
 {
     this.garbageProcessor = garbageProcessor;
     this.garbageFactory   = garbageFactory;
 }
Ejemplo n.º 19
0
 public StatusCommand(IGarbageProcessor garbageProcessor)
 {
     this.garbageProcessor = garbageProcessor;
 }
 public RecyclingManager(IGarbageProcessor garbageProcessor, IWasteFactory wasteFactory)
 {
     this.garbageProcessor = garbageProcessor;
     this.wasteFactory     = wasteFactory;
 }
Ejemplo n.º 21
0
 public abstract string Execute(string[] args, IGarbageProcessor garbageProcessor);
Ejemplo n.º 22
0
 public CommandInterpreter(IGarbageFactory garbageFactory, IGarbageProcessor garbageProcessor, IProcessingData processingData)
 {
     this.garbageFactory   = garbageFactory;
     this.garbageProcessor = garbageProcessor;
     this.processingData   = processingData;
 }
Ejemplo n.º 23
0
 public CommandInterpreter(IRepository repo, IWasteFactory wasteFactory, IGarbageProcessor processor)
 {
     this.repo         = repo;
     this.wasteFactory = wasteFactory;
     this.processor    = processor;
 }
Ejemplo n.º 24
0
 public ResourcesController(IResourcesDatabase database, IGarbageProcessor garbageProcessor)
 {
     this.database              = database;
     this.garbageProcessor      = garbageProcessor;
     this.ManagementRequirement = null;
 }
 public RecyclingStationManager(IGarbageProcessor garbageProcessor)
 {
     this.garbageProcessor = garbageProcessor;
     this.processingData   = new ProcessingData();
 }
 public CommandHandler(IGarbageProcessor garbageProcessor, IBalanceManager balanceManager)
 {
     this.GarbageProcessor = garbageProcessor;
     this.BalanceManager   = balanceManager;
     this.InitializeStrategies();
 }
Ejemplo n.º 27
0
 public override string Execute(string[] args, IGarbageProcessor garbageProcessor)
 {
     Environment.Exit(0);
     return("");
 }
 public void InitializeTest()
 {
     this.garbageProcessor = new GarbageProcessor();
 }
Ejemplo n.º 29
0
 public void TestProcessingWasteWithnullParameterhouldThrowException()
 {
     this.garbageProcessor = new GarbageProcessor();
     this.garbageProcessor.ProcessWaste(null);
 }
Ejemplo n.º 30
0
 public CommandInterpreter(IRecyclingStation rs, IGarbageProcessor gp, IGarbageFactory gf)
 {
     this.rs = rs;
     this.gp = gp;
     this.gf = gf;
 }