public void ShouldNotEndTaskWhenSubModuleFails() { MemoryLogger logger; ProducerModule module; IBuildingModule buildingModule; IBuildingTypeModule buildingTypeModule; IWorkerModule workerModule; IStackModule stackModule; IIngredientModule ingredientModule; IProductModule productModule; ITaskModule taskModule; MockedSchedulerModule schedulerModule; buildingModule = new MockedBuildingModule(false, new Building() { BuildingID = 1, BuildingTypeID = BuildingTypeIDs.Sawmill }); buildingTypeModule = new MockedBuildingTypeModule(false, new BuildingType() { BuildingTypeID = BuildingTypeIDs.Sawmill, IsFactory = true }); workerModule = new MockedWorkerModule(false, new Worker() { WorkerID = 1, PlanetID = 1 }); stackModule = new MockedStackModule(true); ingredientModule = new MockedIngredientModule(false); productModule = new MockedProductModule(false, new Product() { ProductID = 1, BuildingTypeID = BuildingTypeIDs.Sawmill, Duration = 4, Quantity = 2 }); taskModule = new MockedTaskModule(false); logger = new MemoryLogger(); module = new ProducerModule(logger, taskModule, workerModule, buildingModule, buildingTypeModule, stackModule, ingredientModule, productModule); schedulerModule = new MockedSchedulerModule(false, module); Assert.ThrowsException <PIOInternalErrorException>(() => module.EndProduce(1)); Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName))); stackModule = new MockedStackModule(false); ingredientModule = new MockedIngredientModule(false); productModule = new MockedProductModule(true, new Product() { ProductID = 1, BuildingTypeID = BuildingTypeIDs.Sawmill, Duration = 4, Quantity = 2 }); taskModule = new MockedTaskModule(false); logger = new MemoryLogger(); module = new ProducerModule(logger, taskModule, workerModule, buildingModule, buildingTypeModule, stackModule, ingredientModule, productModule); schedulerModule = new MockedSchedulerModule(false, module); Assert.ThrowsException <PIOInternalErrorException>(() => module.EndProduce(1)); Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName))); }
public void ShouldEndTaskWhenBuildingHasNoProduct() { ProducerModule module; IBuildingModule buildingModule; IBuildingTypeModule buildingTypeModule; IWorkerModule workerModule; IStackModule stackModule; IIngredientModule ingredientModule; IProductModule productModule; ITaskModule taskModule; MockedSchedulerModule schedulerModule; buildingModule = new MockedBuildingModule(false, new Building() { BuildingID = 1, BuildingTypeID = BuildingTypeIDs.Sawmill }); buildingTypeModule = new MockedBuildingTypeModule(false, new BuildingType() { BuildingTypeID = BuildingTypeIDs.Sawmill, IsFactory = true }); workerModule = new MockedWorkerModule(false, new Worker() { WorkerID = 1, PlanetID = 1 }); stackModule = new MockedStackModule(false, new Stack() { StackID = 0, BuildingID = 1, ResourceTypeID = ResourceTypeIDs.Plank, Quantity = 10 }, new Stack() { StackID = 1, BuildingID = 1, ResourceTypeID = ResourceTypeIDs.Wood, Quantity = 10 }, new Stack() { StackID = 2, BuildingID = 1, ResourceTypeID = ResourceTypeIDs.Stone, Quantity = 10 }, new Stack() { StackID = 3, BuildingID = 1, ResourceTypeID = ResourceTypeIDs.Coal, Quantity = 10 } ); ingredientModule = new MockedIngredientModule(false, new Ingredient() { IngredientID = 0, BuildingTypeID = BuildingTypeIDs.Sawmill, ResourceTypeID = ResourceTypeIDs.Wood, Quantity = 5 }, new Ingredient() { IngredientID = 1, BuildingTypeID = BuildingTypeIDs.Sawmill, ResourceTypeID = ResourceTypeIDs.Stone, Quantity = 10 }, new Ingredient() { IngredientID = 3, BuildingTypeID = BuildingTypeIDs.Sawmill, ResourceTypeID = ResourceTypeIDs.Coal, Quantity = 6 } ); productModule = new MockedProductModule(false); taskModule = new MockedTaskModule(false); module = new ProducerModule(NullLogger.Instance, taskModule, workerModule, buildingModule, buildingTypeModule, stackModule, ingredientModule, productModule); schedulerModule = new MockedSchedulerModule(false, module); module.EndProduce(1); }