コード例 #1
0
        public async Task DeleteSchedule_ValidKey_ShouldReturnOkCode()
        {
            //Arrange
            var mockKey = Guid.Parse("BEC05D78-2F6C-4034-8FB9-ACE3417F83E8");
            var data    = FakeData();

            _mockScheduleRepository.Setup(x => x.Get(It.IsAny <Guid>())).Returns(data.FirstOrDefault);
            _mockRoutingRuleScheduleTimingRepository.Setup(x => x.GetRoutingRuleScheduleTiming(It.IsAny <Guid>()))
            .ReturnsAsync(false);
            _scheduleBusiness = new ScheduleBusiness(_mockScheduleRepository.Object, _mockRoutingRuleScheduleTimingRepository.Object, _unitofwork.Object, _mapper);

            //Act
            await _scheduleBusiness.DeleteSchedule(mockKey);

            //Assert
            _mockScheduleRepository.Verify(mock => mock.Delete(It.IsAny <ScheduleTiming>()), Times.Once);
        }
コード例 #2
0
        public async Task DeleteSchedule_NullResult_ShouldReturnInvalidScheduleException()
        {
            //Arrange
            var mockKey = Guid.Parse("BEC05D78-2F6C-4034-8FB9-ACE3417F83E8");

            _scheduleBusiness = new ScheduleBusiness(_mockScheduleRepository.Object, _mockRoutingRuleScheduleTimingRepository.Object, _unitofwork.Object, _mapper);

            Exception expected = new InvalidScheduleException("", 4002);

            try
            {
                //Act
                await _scheduleBusiness.DeleteSchedule(mockKey);
            }
            catch (Exception e)
            {
                Assert.Equal(4002, expected.HResult);
            }
        }
コード例 #3
0
        public async Task DeleteSchedule_ValidKey_ShouldReturnInvalidScheduleException()
        {
            //Arrange
            var mockKey = Guid.Parse("BEC05D78-2F6C-4034-8FB9-ACE3417F83E8");
            var data    = FakeData();

            _mockScheduleRepository.Setup(x => x.Get(It.IsAny <Guid>())).Returns(data.FirstOrDefault);
            _mockRoutingRuleScheduleTimingRepository.Setup(x => x.GetRoutingRuleScheduleTiming(It.IsAny <Guid>()))
            .ReturnsAsync(true);
            _scheduleBusiness = new ScheduleBusiness(_mockScheduleRepository.Object, _mockRoutingRuleScheduleTimingRepository.Object, _unitofwork.Object, _mapper);

            Exception expected = new InvalidScheduleException("", 4004);

            try
            {
                //Act
                await _scheduleBusiness.DeleteSchedule(mockKey);
            }
            catch (Exception e)
            {
                Assert.Equal(4004, expected.HResult);
            }
        }