예제 #1
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <ILinkTypesRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <LinkTypes>(null));
            var service = new LinkTypesService(mock.LoggerMock.Object,
                                               mock.RepositoryMock.Object,
                                               mock.ModelValidatorMockFactory.LinkTypesModelValidatorMock.Object,
                                               mock.BOLMapperMockFactory.BOLLinkTypesMapperMock,
                                               mock.DALMapperMockFactory.DALLinkTypesMapperMock);

            ApiLinkTypesResponseModel 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 <ILinkTypesRepository>();
            var model = new ApiLinkTypesRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <LinkTypes>())).Returns(Task.FromResult(new LinkTypes()));
            var service = new LinkTypesService(mock.LoggerMock.Object,
                                               mock.RepositoryMock.Object,
                                               mock.ModelValidatorMockFactory.LinkTypesModelValidatorMock.Object,
                                               mock.BOLMapperMockFactory.BOLLinkTypesMapperMock,
                                               mock.DALMapperMockFactory.DALLinkTypesMapperMock);

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

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.LinkTypesModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiLinkTypesRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <LinkTypes>()));
        }
예제 #3
0
        public async void All()
        {
            var mock    = new ServiceMockFacade <ILinkTypesRepository>();
            var records = new List <LinkTypes>();

            records.Add(new LinkTypes());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new LinkTypesService(mock.LoggerMock.Object,
                                               mock.RepositoryMock.Object,
                                               mock.ModelValidatorMockFactory.LinkTypesModelValidatorMock.Object,
                                               mock.BOLMapperMockFactory.BOLLinkTypesMapperMock,
                                               mock.DALMapperMockFactory.DALLinkTypesMapperMock);

            List <ApiLinkTypesResponseModel> 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 <ILinkTypesRepository>();
            var model = new ApiLinkTypesRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new LinkTypesService(mock.LoggerMock.Object,
                                               mock.RepositoryMock.Object,
                                               mock.ModelValidatorMockFactory.LinkTypesModelValidatorMock.Object,
                                               mock.BOLMapperMockFactory.BOLLinkTypesMapperMock,
                                               mock.DALMapperMockFactory.DALLinkTypesMapperMock);

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

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