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"); }
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"); }
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"); }
public ActionResult CreateCamera([FromBody] Camera camera) { try { _cameraService.CreateCamera(camera); return(Ok()); } catch (Exception e) { return(BadRequest(e.Message)); } }