예제 #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 ApiPostRequestModel();

            createModel.SetProperties(2, 2, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 2, DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), 2, DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), "B", 2, 2, 2, 2, 2, "B", "B", 2);
            CreateResponse <ApiPostResponseModel> createResult = await client.PostCreateAsync(createModel);

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

            ApiPostResponseModel getResponse = await client.PostGetAsync(2);

            getResponse.Should().NotBeNull();

            ActionResponse deleteResult = await client.PostDeleteAsync(2);

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

            ApiPostResponseModel verifyResponse = await client.PostGetAsync(2);

            verifyResponse.Should().BeNull();
        }
예제 #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());
            ApiPostResponseModel response = await client.PostGetAsync(1);

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

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Post>(null));
            var service = new PostService(mock.LoggerMock.Object,
                                          mock.RepositoryMock.Object,
                                          mock.ModelValidatorMockFactory.PostModelValidatorMock.Object,
                                          mock.BOLMapperMockFactory.BOLPostMapperMock,
                                          mock.DALMapperMockFactory.DALPostMapperMock);

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

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