コード例 #1
0
ファイル: ServiceTests.cs プロジェクト: dariuskrtn/SafePlace
        public void CameraServiceTest_GetCameraFromDictionary_ReturnsRightCamera()
        {
            ICameraService cameraService = new CameraService();
            Camera         camera0       = cameraService.CreateCamera();
            Camera         camera1       = cameraService.CreateCamera();
            Camera         camera2       = cameraService.CreateCamera();
            Camera         camera3       = cameraService.CreateCamera();

            Assert.IsNotNull(camera0, "Failed to create camera instance");
            Assert.IsNotNull(camera1, "Failed to create camera instance");
            Assert.IsNotNull(camera2, "Failed to create camera instance");
            Assert.IsNotNull(camera3, "Failed to create camera instance");

            Assert.AreEqual(cameraService.GetCamera(camera2.Guid), camera2, "Wrong Camera returned");
        }
コード例 #2
0
ファイル: ServiceTests.cs プロジェクト: dariuskrtn/SafePlace
        public void CameraServiceTest_CreateNewCameraWithPosition_PositionsAreSetCorretly()
        {
            ICameraService cameraService = new CameraService();
            Camera         camera        = cameraService.CreateCamera(true, 2, 5);

            Assert.AreEqual <int>(camera.PositionX, 2, " Camera posisitionX is set to " + camera.PositionX + " instead of 2");
            Assert.AreEqual <int>(camera.PositionY, 5, " Camera posisitionY is set to " + camera.PositionX + " instead of 5");
        }
コード例 #3
0
ファイル: ServiceTests.cs プロジェクト: dariuskrtn/SafePlace
        public void CameraServiceTest_CreateAndAddToDictionaryNewCamera_CameraIsInTheDictionary()
        {
            ICameraService cameraService = new CameraService();
            Camera         camera        = cameraService.CreateCamera();

            Assert.IsNotNull(camera, "Failed to create camera instance");
            CollectionAssert.Contains(cameraService.GetAllCameras().ToList(), camera, "Camera was created but not added to dictionary");
        }
コード例 #4
0
 public ActionResult CreateCamera([FromBody] Camera camera)
 {
     try
     {
         _cameraService.CreateCamera(camera);
         return(Ok());
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }