Exemplo n.º 1
0
        public void EnsureGettingOperationByIdNotFound()
        {
            Guid operationId = new Guid("22345678-1234-1234-1234-123412341234");

            //mock
            Context context = ContextMocker.GetContextMock();

            ContextMocker.SeedOperations(context);

            OperationService service = new OperationService(context);

            Assert.ThrowsAsync <KeyNotFoundException>(() => (service.GetOperationById(operationId)));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <OperationDTO> > GetOperationById(Guid id)
        {
            try
            {
                Operation operation = await _service.GetOperationById(id);

                return(operation.ToDTO());
            }
            catch (KeyNotFoundException e)
            {
                return(NotFound(e.Message));
            }
        }
Exemplo n.º 3
0
        public async void EnsureGettingOpperationByIdFound()
        {
            //mock
            Context context = ContextMocker.GetContextMock();

            ContextMocker.SeedOperations(context);

            Guid      expectedId          = new Guid("12345678-1234-1234-1234-123412341234");
            string    expectedDescription = "Triturar";
            TimeSpan  expectedDuration    = new TimeSpan(0, 20, 10);
            string    expectedTool        = "broca 20mm";
            TimeSpan  expectedSetupTime   = new TimeSpan(0, 0, 20);
            Operation expected            = new Operation(expectedId, expectedDescription, expectedDuration, expectedTool, expectedSetupTime);

            OperationService service = new OperationService(context);
            Operation        result  = await service.GetOperationById(expectedId);

            Assert.True(expected.Equals(result));
        }