示例#1
0
        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));
        }
示例#2
0
        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);
        }
示例#3
0
        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));
        }