Exemple #1
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 ApiVoteTypeRequestModel();

            createModel.SetProperties("B");
            CreateResponse <ApiVoteTypeResponseModel> createResult = await client.VoteTypeCreateAsync(createModel);

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

            ApiVoteTypeResponseModel getResponse = await client.VoteTypeGetAsync(2);

            getResponse.Should().NotBeNull();

            ActionResponse deleteResult = await client.VoteTypeDeleteAsync(2);

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

            ApiVoteTypeResponseModel verifyResponse = await client.VoteTypeGetAsync(2);

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

            var client = new ApiClient(testServer.CreateClient());
            ApiVoteTypeResponseModel response = await client.VoteTypeGetAsync(1);

            response.Should().NotBeNull();
        }
Exemple #3
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IVoteTypeRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <VoteType>(null));
            var service = new VoteTypeService(mock.LoggerMock.Object,
                                              mock.RepositoryMock.Object,
                                              mock.ModelValidatorMockFactory.VoteTypeModelValidatorMock.Object,
                                              mock.BOLMapperMockFactory.BOLVoteTypeMapperMock,
                                              mock.DALMapperMockFactory.DALVoteTypeMapperMock);

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

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }