Beispiel #1
0
        public void PutTimeRegistration_IncorrectId_NotFound()
        {
            //Arrange
            var controller       = new TimeRegistrationsController(_context);
            var timeRegistration = new TimeRegistration();

            timeRegistration.TimeRegistrationId = -1000000;
            timeRegistration.Date       = DateTime.Now.AddDays(10);
            timeRegistration.Duration   = 5;
            timeRegistration.WorkTypeId = 1;

            //Act
            var result = controller.PutTimeRegistration(timeRegistration.TimeRegistrationId, timeRegistration).Result;

            //Assert
            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
Beispiel #2
0
        public void PutTimeRegistration_IncorrectData_BadRequestResult()
        {
            //Arrange
            var controller           = new TimeRegistrationsController(_context);
            var fakeTimeRegistration = new TimeRegistration();

            fakeTimeRegistration.Date       = DateTime.Now.AddDays(10);
            fakeTimeRegistration.Duration   = 5;
            fakeTimeRegistration.WorkTypeId = 1;

            var realTimeRegistrationId = _context.TimeRegistrations.First().TimeRegistrationId;

            //Act
            var result = controller.PutTimeRegistration(realTimeRegistrationId, fakeTimeRegistration).Result;

            //Assert
            Assert.IsInstanceOfType(result, typeof(BadRequestResult));
        }
Beispiel #3
0
        public void PutTimeRegistration_OK_NoContent()
        {
            //Arrange
            var controller = new TimeRegistrationsController(_context);

            var timeRegistration = _context.TimeRegistrations.First();

            timeRegistration.Date       = DateTime.Now.AddDays(10);
            timeRegistration.Duration   = 5;
            timeRegistration.WorkTypeId = 1;

            //Act
            var result = controller.PutTimeRegistration(timeRegistration.TimeRegistrationId, timeRegistration).Result;

            var updatedTimeRegistration =
                _context.TimeRegistrations.First(r => r.TimeRegistrationId == timeRegistration.TimeRegistrationId);

            //Assert
            Assert.IsInstanceOfType(result, typeof(NoContentResult));
            Assert.IsTrue(timeRegistration.Date == updatedTimeRegistration.Date);
            Assert.IsTrue(timeRegistration.Duration == updatedTimeRegistration.Duration);
            Assert.IsTrue(timeRegistration.WorkTypeId == updatedTimeRegistration.WorkTypeId);
        }