예제 #1
0
        public async void Get()
        {
            var mock   = new ServiceMockFacade <IPersonRepository>();
            var record = new Person();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new PersonService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.PersonModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLPersonMapperMock,
                                            mock.DALMapperMockFactory.DALPersonMapperMock,
                                            mock.BOLMapperMockFactory.BOLBusinessEntityContactMapperMock,
                                            mock.DALMapperMockFactory.DALBusinessEntityContactMapperMock,
                                            mock.BOLMapperMockFactory.BOLEmailAddressMapperMock,
                                            mock.DALMapperMockFactory.DALEmailAddressMapperMock,
                                            mock.BOLMapperMockFactory.BOLPasswordMapperMock,
                                            mock.DALMapperMockFactory.DALPasswordMapperMock,
                                            mock.BOLMapperMockFactory.BOLPersonPhoneMapperMock,
                                            mock.DALMapperMockFactory.DALPersonPhoneMapperMock);

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

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
예제 #2
0
        public async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            var createModel = new ApiPersonRequestModel();

            createModel.SetProperties("B");
            CreateResponse <ApiPersonResponseModel> createResult = await client.PersonCreateAsync(createModel);

            createResult.Success.Should().BeTrue();

            ApiPersonResponseModel getResponse = await client.PersonGetAsync(2);

            getResponse.Should().NotBeNull();

            ActionResponse deleteResult = await client.PersonDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();

            ApiPersonResponseModel verifyResponse = await client.PersonGetAsync(2);

            verifyResponse.Should().BeNull();
        }
예제 #3
0
        public async void TestGet()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());
            ApiPersonResponseModel response = await client.PersonGetAsync(1);

            response.Should().NotBeNull();
        }
예제 #4
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IPersonRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Person>(null));
            var service = new PersonService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.PersonModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLPersonMapperMock,
                                            mock.DALMapperMockFactory.DALPersonMapperMock);

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

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
예제 #5
0
        public async void TestGet()
        {
            ApiPersonResponseModel response = await this.Client.PersonGetAsync(1);

            response.Should().NotBeNull();
        }