コード例 #1
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IVEventRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <VEvent>(null));
            var service = new VEventService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.VEventModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLVEventMapperMock,
                                            mock.DALMapperMockFactory.DALVEventMapperMock);

            ApiVEventResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
コード例 #2
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IVEventRepository>();
            var model = new ApiVEventRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <VEvent>())).Returns(Task.FromResult(new VEvent()));
            var service = new VEventService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.VEventModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLVEventMapperMock,
                                            mock.DALMapperMockFactory.DALVEventMapperMock);

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

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.VEventModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiVEventRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <VEvent>()));
        }
コード例 #3
0
        public async void All()
        {
            var mock    = new ServiceMockFacade <IVEventRepository>();
            var records = new List <VEvent>();

            records.Add(new VEvent());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new VEventService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.VEventModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLVEventMapperMock,
                                            mock.DALMapperMockFactory.DALVEventMapperMock);

            List <ApiVEventResponseModel> response = await service.All();

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
コード例 #4
0
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <IVEventRepository>();
            var model = new ApiVEventRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new VEventService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.VEventModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLVEventMapperMock,
                                            mock.DALMapperMockFactory.DALVEventMapperMock);

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

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>()));
            mock.ModelValidatorMockFactory.VEventModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
        }