public void Init() { blocks = new IBlock[9, 10]; blueprint = new Blueprint(blocks); mockBlock = new Mock <IBlock>(); mockShipComponent = new Mock <IShipComponent>(); mockBlockFactories = new Mock <IList <IFactory <IBlock> > >(); Mock <IFactory <IBlock> > mockBlockFactory = new Mock <IFactory <IBlock> >(); mockBlockFactory.Setup(b => b.Create()).Returns(mockBlock.Object); mockBlockFactories.SetupGet(m => m[0]).Returns(mockBlockFactory.Object); mockShipComponentFactory = new Mock <IFactory <IShipComponent, IConstBlock> >(); mockEmptyShipComponentFactory = new Mock <IFactory <IShipComponent, IConstBlock> >(); blueprintBuilder = new BlueprintBuilder(blueprint, mockBlockFactories.Object, mockShipComponentFactory.Object, mockEmptyShipComponentFactory.Object); doubleEdgedPipes = new List <DoubleEdgedPipe>(); oneEdgedPipes = new List <ConnectingPipe>(); mockBlockRestrictor = new Mock <IBlockRestrictor>(); mockBlueprintBuilderObserver = new Mock <IBlueprintBuilderObserver>(); blueprintBuilder.AttachObserver(mockBlueprintBuilderObserver.Object); mockBlock.SetupGet(x => x.PipesWithBothEdges).Returns(doubleEdgedPipes); mockBlock.SetupGet(x => x.PipesWithOneEdge).Returns(oneEdgedPipes); mockBlock.Setup(block => block.AddPipe(It.IsAny <ConnectingPipe>())).Callback <ConnectingPipe>(p => oneEdgedPipes.Add(p)); mockBlock.Setup(block => block.AddPipe(It.IsAny <DoubleEdgedPipe>())).Callback <DoubleEdgedPipe>(p => doubleEdgedPipes.Add(p)); mockBlock.Setup(block => block.DeletePipe(It.IsAny <ConnectingPipe>())).Callback <ConnectingPipe>(p => oneEdgedPipes.Remove(p)); mockBlock.Setup(block => block.DeletePipe(It.IsAny <DoubleEdgedPipe>())).Callback <DoubleEdgedPipe>(p => doubleEdgedPipes.Remove(p)); }
public void CheckThatBlueprintMatrixDimensionsAreAssignedCorrectly() { var dimensions = new Coordinate(4, 5); var blueprintBuilder = new BlueprintBuilder(dimensions); Assert.AreEqual(4, blueprintBuilder.Dimensions.Y); Assert.AreEqual(5, blueprintBuilder.Dimensions.X); }
public void CheckThatBlockFactoryIsAssignedWhenUsingSimpleConstructor() { var dimensions = new Coordinate(4, 5); var blueprintBuilder = new BlueprintBuilder(dimensions); var position = new Coordinate(1, 2); Assert.IsTrue(blueprintBuilder.CreateBlock(position)); }