示例#1
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IVotesRepository>();
            var model = new ApiVotesRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Votes>())).Returns(Task.FromResult(new Votes()));
            var service = new VotesService(mock.LoggerMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.VotesModelValidatorMock.Object,
                                           mock.BOLMapperMockFactory.BOLVotesMapperMock,
                                           mock.DALMapperMockFactory.DALVotesMapperMock);

            CreateResponse <ApiVotesResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.VotesModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiVotesRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Votes>()));
        }