コード例 #1
0
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiVideoClientResponseModel> response = await client.VideoAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].Description.Should().Be("A");
            response[0].Id.Should().Be(1);
            response[0].Title.Should().Be("A");
            response[0].Url.Should().Be("A");
        }
コード例 #2
0
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiUserClientResponseModel> response = await client.UserAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].Email.Should().Be("A");
            response[0].Id.Should().Be(1);
            response[0].Password.Should().Be("A");
            response[0].StripeCustomerId.Should().Be("A");
            response[0].SubscriptionTypeId.Should().Be(1);
        }
コード例 #3
0
        public virtual async void TestGetFound()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            ApiSubscriptionClientResponseModel response = await client.SubscriptionGetAsync(1);

            response.Should().NotBeNull();
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.StripePlanName.Should().Be("A");
        }
コード例 #4
0
        public virtual async void TestBulkInsert()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);
            var        client     = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());

            ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            var model = new ApiUserClientRequestModel();

            model.SetProperties("B", "B", "B", 2);
            var model2 = new ApiUserClientRequestModel();

            model2.SetProperties("C", "C", "C", 3);
            var request = new List <ApiUserClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiUserClientResponseModel> > result = await client.UserBulkInsertAsync(request);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();

            context.Set <User>().ToList()[1].Email.Should().Be("B");
            context.Set <User>().ToList()[1].Password.Should().Be("B");
            context.Set <User>().ToList()[1].StripeCustomerId.Should().Be("B");
            context.Set <User>().ToList()[1].SubscriptionTypeId.Should().Be(2);

            context.Set <User>().ToList()[2].Email.Should().Be("C");
            context.Set <User>().ToList()[2].Password.Should().Be("C");
            context.Set <User>().ToList()[2].StripeCustomerId.Should().Be("C");
            context.Set <User>().ToList()[2].SubscriptionTypeId.Should().Be(3);
        }
コード例 #5
0
        public virtual async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            var mapper = new ApiUserServerModelMapper();
            ApplicationDbContext       context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IUserService               service = testServer.Host.Services.GetService(typeof(IUserService)) as IUserService;
            ApiUserServerResponseModel model   = await service.Get(1);

            ApiUserClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties("B", "B", "B", 2);

            UpdateResponse <ApiUserClientResponseModel> updateResponse = await client.UserUpdateAsync(model.Id, request);

            context.Entry(context.Set <User>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <User>().ToList()[0].Email.Should().Be("B");
            context.Set <User>().ToList()[0].Password.Should().Be("B");
            context.Set <User>().ToList()[0].StripeCustomerId.Should().Be("B");
            context.Set <User>().ToList()[0].SubscriptionTypeId.Should().Be(2);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Email.Should().Be("B");
            updateResponse.Record.Password.Should().Be("B");
            updateResponse.Record.StripeCustomerId.Should().Be("B");
            updateResponse.Record.SubscriptionTypeId.Should().Be(2);
        }
コード例 #6
0
        public virtual async void TestCreate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);
            var        client     = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            var model = new ApiSubscriptionClientRequestModel();

            model.SetProperties("B", "B");
            CreateResponse <ApiSubscriptionClientResponseModel> result = await client.SubscriptionCreateAsync(model);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();
            context.Set <Subscription>().ToList()[1].Name.Should().Be("B");
            context.Set <Subscription>().ToList()[1].StripePlanName.Should().Be("B");

            result.Record.Name.Should().Be("B");
            result.Record.StripePlanName.Should().Be("B");
        }