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 ApiCompositePrimaryKeyRequestModel();

            createModel.SetProperties(2);
            CreateResponse <ApiCompositePrimaryKeyResponseModel> createResult = await client.CompositePrimaryKeyCreateAsync(createModel);

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

            ApiCompositePrimaryKeyResponseModel getResponse = await client.CompositePrimaryKeyGetAsync(2);

            getResponse.Should().NotBeNull();

            ActionResponse deleteResult = await client.CompositePrimaryKeyDeleteAsync(2);

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

            ApiCompositePrimaryKeyResponseModel verifyResponse = await client.CompositePrimaryKeyGetAsync(2);

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

            var client = new ApiClient(testServer.CreateClient());
            ApiCompositePrimaryKeyResponseModel response = await client.CompositePrimaryKeyGetAsync(1);

            response.Should().NotBeNull();
        }
Exemplo n.º 3
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <ICompositePrimaryKeyRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <CompositePrimaryKey>(null));
            var service = new CompositePrimaryKeyService(mock.LoggerMock.Object,
                                                         mock.RepositoryMock.Object,
                                                         mock.ModelValidatorMockFactory.CompositePrimaryKeyModelValidatorMock.Object,
                                                         mock.BOLMapperMockFactory.BOLCompositePrimaryKeyMapperMock,
                                                         mock.DALMapperMockFactory.DALCompositePrimaryKeyMapperMock);

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

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