Ejemplo n.º 1
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <ITagSetRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <TagSet>(null));
            var service = new TagSetService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.TagSetModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLTagSetMapperMock,
                                            mock.DALMapperMockFactory.DALTagSetMapperMock);

            ApiTagSetResponseModel response = await service.Get(default(string));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <string>()));
        }
Ejemplo n.º 2
0
        public async void ByDataVersion_Not_Exists()
        {
            var mock = new ServiceMockFacade <ITagSetRepository>();

            mock.RepositoryMock.Setup(x => x.ByDataVersion(It.IsAny <byte[]>())).Returns(Task.FromResult <List <TagSet> >(new List <TagSet>()));
            var service = new TagSetService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.TagSetModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLTagSetMapperMock,
                                            mock.DALMapperMockFactory.DALTagSetMapperMock);

            List <ApiTagSetResponseModel> response = await service.ByDataVersion(default(byte[]));

            response.Should().BeEmpty();
            mock.RepositoryMock.Verify(x => x.ByDataVersion(It.IsAny <byte[]>()));
        }
Ejemplo n.º 3
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <ITagSetRepository>();
            var model = new ApiTagSetRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <TagSet>())).Returns(Task.FromResult(new TagSet()));
            var service = new TagSetService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.TagSetModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLTagSetMapperMock,
                                            mock.DALMapperMockFactory.DALTagSetMapperMock);

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

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.TagSetModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiTagSetRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <TagSet>()));
        }
Ejemplo n.º 4
0
        public async void All()
        {
            var mock    = new ServiceMockFacade <ITagSetRepository>();
            var records = new List <TagSet>();

            records.Add(new TagSet());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new TagSetService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.TagSetModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLTagSetMapperMock,
                                            mock.DALMapperMockFactory.DALTagSetMapperMock);

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

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
Ejemplo n.º 5
0
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <ITagSetRepository>();
            var model = new ApiTagSetRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <string>())).Returns(Task.CompletedTask);
            var service = new TagSetService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.TagSetModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLTagSetMapperMock,
                                            mock.DALMapperMockFactory.DALTagSetMapperMock);

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

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