Пример #1
0
        public void ActualTimeServiceRemoveActualTime_UserIsUser_ThrowMethodAccessException()
        {
            // Arrange
            var user = new User(Guid.NewGuid(), Guid.NewGuid().ToString());

            Authorization.SetUser(user);

            IActualTimeService actualTimeService = new ActualTimeService(_mockUnitOfWork.Object);

            // Act

            // Assert
            Assert.ThrowsAsync <MethodAccessException>(() => actualTimeService.RemoveActualTimeAsync(1));
        }
Пример #2
0
        private IActualTimeService GetActualTimeService(int itemId, DateTime timeEnter, DateTime timeExit)
        {
            var mockContext        = new Mock <IUnitOfWork>();
            var expectedActualTime = new ActualTime()
            {
                Id        = itemId,
                TimeEnter = timeEnter,
                TimeExit  = timeExit
            };
            var repMock = new Mock <IActualTimeRepository>();

            repMock.Setup(mock => mock.GetAsync(itemId)).ReturnsAsync(expectedActualTime);

            mockContext
            .Setup(context =>
                   context.ActualTimeRepository)
            .Returns(repMock.Object);
            mockContext.Setup(mock => mock.ActualTimeRepository.GetAsync(itemId)).ReturnsAsync(expectedActualTime);

            IActualTimeService actualTimeService = new ActualTimeService(mockContext.Object);

            return(actualTimeService);
        }