Beispiel #1
0
        public async void Delete_ErrorsOccurred_ShouldReturnErrorResponse()
        {
            var mock          = new ServiceMockFacade <ITeacherSkillService, ITeacherSkillRepository>();
            var model         = new ApiTeacherSkillServerRequestModel();
            var validatorMock = new Mock <IApiTeacherSkillServerRequestModelValidator>();

            validatorMock.Setup(x => x.ValidateDeleteAsync(It.IsAny <int>())).Returns(Task.FromResult(new FluentValidation.Results.ValidationResult(new List <ValidationFailure>()
            {
                new ValidationFailure("text", "test")
            })));
            var service = new TeacherSkillService(mock.LoggerMock.Object,
                                                  mock.MediatorMock.Object,
                                                  mock.RepositoryMock.Object,
                                                  validatorMock.Object,
                                                  mock.DALMapperMockFactory.DALTeacherSkillMapperMock,
                                                  mock.DALMapperMockFactory.DALRateMapperMock,
                                                  mock.DALMapperMockFactory.DALTeacherTeacherSkillMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            response.Success.Should().BeFalse();
            validatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <TeacherSkillDeletedNotification>(), It.IsAny <CancellationToken>()), Times.Never());
        }
Beispiel #2
0
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <ITeacherSkillRepository>();
            var model = new ApiTeacherSkillRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new TeacherSkillService(mock.LoggerMock.Object,
                                                  mock.RepositoryMock.Object,
                                                  mock.ModelValidatorMockFactory.TeacherSkillModelValidatorMock.Object,
                                                  mock.BOLMapperMockFactory.BOLTeacherSkillMapperMock,
                                                  mock.DALMapperMockFactory.DALTeacherSkillMapperMock,
                                                  mock.BOLMapperMockFactory.BOLRateMapperMock,
                                                  mock.DALMapperMockFactory.DALRateMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>()));
            mock.ModelValidatorMockFactory.TeacherSkillModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
        }
Beispiel #3
0
        public async void Delete_NoErrorsOccurred_ShouldReturnResponse()
        {
            var mock  = new ServiceMockFacade <ITeacherSkillService, ITeacherSkillRepository>();
            var model = new ApiTeacherSkillServerRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new TeacherSkillService(mock.LoggerMock.Object,
                                                  mock.MediatorMock.Object,
                                                  mock.RepositoryMock.Object,
                                                  mock.ModelValidatorMockFactory.TeacherSkillModelValidatorMock.Object,
                                                  mock.DALMapperMockFactory.DALTeacherSkillMapperMock,
                                                  mock.DALMapperMockFactory.DALRateMapperMock,
                                                  mock.DALMapperMockFactory.DALTeacherTeacherSkillMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            response.Success.Should().BeTrue();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>()));
            mock.ModelValidatorMockFactory.TeacherSkillModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <TeacherSkillDeletedNotification>(), It.IsAny <CancellationToken>()));
        }