コード例 #1
0
        public async void CreateBuilding_CreatesAndAddsBuilding_OKResult()
        {
            var mockBuildingRepo = new Mock <IRepositoryAsync <Building> >();
            var controller       = new BuildingController(null, mockBuildingRepo.Object);

            // Act
            var result = await controller.CreateBuilding("Test");

            // Assert
            var OkResult = Assert.IsType <OkResult>(result);
        }
コード例 #2
0
        public async void CreateBuilding_NullBuildingName_OKResult()
        {
            var mockBuildingRepo = new Mock <IRepositoryAsync <Building> >();
            var controller       = new BuildingController(null, mockBuildingRepo.Object);

            // Act
            var result = await controller.CreateBuilding(null);

            // can't test this with errors cause nothing throws errors in the try block yet
            // Assert
            var OkResult = Assert.IsType <OkResult>(result);
        }
コード例 #3
0
        public async Task CreateBuilding_BadModel_BadRequest()
        {
            //Arrange
            var controller = new BuildingController(facade.Object);

            controller.ModelState.AddModelError("Key", "ErrorMessage");

            //Act
            var result = await controller.CreateBuilding(model);

            //Assert
            Assert.NotNull(result);
            Assert.IsType <InvalidModelStateResult>(result);
        }
コード例 #4
0
 public void Create()
 {
     foreach (var zone in zones)
     {
         for (int x = 0; x < zone.xLength; x++)
         {
             for (int y = 0; y < zone.yLength; y++)
             {
                 GridCoordinates position = new GridCoordinates(x, y) + zone.position;
                 if (Random.Range(0f, 1f) < filledPart && grid.GridCoordinatesExist(position))
                 {
                     GameObject itemPref = itemsRandomized[Random.Range(0, itemsRandomized.Length)];
                     GameObject item     =
                         buildingController.CreateBuilding(itemPref, position);
                     if (item != null)
                     {
                         grid.PutObjectOnGrid(item.GetComponent <GridObject>());
                     }
                 }
             }
         }
     }
 }