コード例 #1
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");
            var model2 = new ApiUserClientRequestModel();

            model2.SetProperties("C", "C");
            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].Password.Should().Be("B");
            context.Set <User>().ToList()[1].Username.Should().Be("B");

            context.Set <User>().ToList()[2].Password.Should().Be("C");
            context.Set <User>().ToList()[2].Username.Should().Be("C");
        }
コード例 #2
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 ApiUserClientRequestModel();

            model.SetProperties("B", "B", "B", 2);
            CreateResponse <ApiUserClientResponseModel> result = await client.UserCreateAsync(model);

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

            result.Record.Email.Should().Be("B");
            result.Record.Password.Should().Be("B");
            result.Record.StripeCustomerId.Should().Be("B");
            result.Record.SubscriptionTypeId.Should().Be(2);
        }
コード例 #3
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");

            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].Password.Should().Be("B");
            context.Set <User>().ToList()[0].Username.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Password.Should().Be("B");
            updateResponse.Record.Username.Should().Be("B");
        }
コード例 #4
0
        public virtual ApiUserClientRequestModel MapServerResponseToClientRequest(
            ApiUserServerResponseModel response)
        {
            var request = new ApiUserClientRequestModel();

            request.SetProperties(
                response.Password,
                response.Username);
            return(request);
        }
コード例 #5
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", DateTime.Parse("1/1/1988 12:00:00 AM"), "B", "B", "B", "B", "B", 1, "B", "B", "B", "B", "B");
            var model2 = new ApiUserClientRequestModel();

            model2.SetProperties("C", DateTime.Parse("1/1/1989 12:00:00 AM"), "C", "C", "C", "C", "C", 1, "C", "C", "C", "C", "C");
            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].BioImgUrl.Should().Be("B");
            context.Set <User>().ToList()[1].Birthday.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <User>().ToList()[1].ContentDescription.Should().Be("B");
            context.Set <User>().ToList()[1].Email.Should().Be("B");
            context.Set <User>().ToList()[1].FullName.Should().Be("B");
            context.Set <User>().ToList()[1].HeaderImgUrl.Should().Be("B");
            context.Set <User>().ToList()[1].Interest.Should().Be("B");
            context.Set <User>().ToList()[1].LocationLocationId.Should().Be(1);
            context.Set <User>().ToList()[1].Password.Should().Be("B");
            context.Set <User>().ToList()[1].PhoneNumber.Should().Be("B");
            context.Set <User>().ToList()[1].Privacy.Should().Be("B");
            context.Set <User>().ToList()[1].Username.Should().Be("B");
            context.Set <User>().ToList()[1].Website.Should().Be("B");

            context.Set <User>().ToList()[2].BioImgUrl.Should().Be("C");
            context.Set <User>().ToList()[2].Birthday.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM"));
            context.Set <User>().ToList()[2].ContentDescription.Should().Be("C");
            context.Set <User>().ToList()[2].Email.Should().Be("C");
            context.Set <User>().ToList()[2].FullName.Should().Be("C");
            context.Set <User>().ToList()[2].HeaderImgUrl.Should().Be("C");
            context.Set <User>().ToList()[2].Interest.Should().Be("C");
            context.Set <User>().ToList()[2].LocationLocationId.Should().Be(1);
            context.Set <User>().ToList()[2].Password.Should().Be("C");
            context.Set <User>().ToList()[2].PhoneNumber.Should().Be("C");
            context.Set <User>().ToList()[2].Privacy.Should().Be("C");
            context.Set <User>().ToList()[2].Username.Should().Be("C");
            context.Set <User>().ToList()[2].Website.Should().Be("C");
        }
コード例 #6
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", 2, 2, DateTime.Parse("1/1/1988 12:00:00 AM"), "B", 2, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), "B", 2, 2, 2, "B");
            var model2 = new ApiUserClientRequestModel();

            model2.SetProperties("C", 3, 3, DateTime.Parse("1/1/1989 12:00:00 AM"), "C", 3, "C", DateTime.Parse("1/1/1989 12:00:00 AM"), "C", 3, 3, 3, "C");
            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].AboutMe.Should().Be("B");
            context.Set <User>().ToList()[1].AccountId.Should().Be(2);
            context.Set <User>().ToList()[1].Age.Should().Be(2);
            context.Set <User>().ToList()[1].CreationDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <User>().ToList()[1].DisplayName.Should().Be("B");
            context.Set <User>().ToList()[1].DownVote.Should().Be(2);
            context.Set <User>().ToList()[1].EmailHash.Should().Be("B");
            context.Set <User>().ToList()[1].LastAccessDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <User>().ToList()[1].Location.Should().Be("B");
            context.Set <User>().ToList()[1].Reputation.Should().Be(2);
            context.Set <User>().ToList()[1].UpVote.Should().Be(2);
            context.Set <User>().ToList()[1].View.Should().Be(2);
            context.Set <User>().ToList()[1].WebsiteUrl.Should().Be("B");

            context.Set <User>().ToList()[2].AboutMe.Should().Be("C");
            context.Set <User>().ToList()[2].AccountId.Should().Be(3);
            context.Set <User>().ToList()[2].Age.Should().Be(3);
            context.Set <User>().ToList()[2].CreationDate.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM"));
            context.Set <User>().ToList()[2].DisplayName.Should().Be("C");
            context.Set <User>().ToList()[2].DownVote.Should().Be(3);
            context.Set <User>().ToList()[2].EmailHash.Should().Be("C");
            context.Set <User>().ToList()[2].LastAccessDate.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM"));
            context.Set <User>().ToList()[2].Location.Should().Be("C");
            context.Set <User>().ToList()[2].Reputation.Should().Be(3);
            context.Set <User>().ToList()[2].UpVote.Should().Be(3);
            context.Set <User>().ToList()[2].View.Should().Be(3);
            context.Set <User>().ToList()[2].WebsiteUrl.Should().Be("C");
        }
コード例 #7
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", DateTime.Parse("1/1/1988 12:00:00 AM"), "B", "B", "B", "B", "B", 1, "B", "B", "B", "B", "B");

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

            context.Entry(context.Set <User>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.UserId.Should().Be(1);
            context.Set <User>().ToList()[0].BioImgUrl.Should().Be("B");
            context.Set <User>().ToList()[0].Birthday.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <User>().ToList()[0].ContentDescription.Should().Be("B");
            context.Set <User>().ToList()[0].Email.Should().Be("B");
            context.Set <User>().ToList()[0].FullName.Should().Be("B");
            context.Set <User>().ToList()[0].HeaderImgUrl.Should().Be("B");
            context.Set <User>().ToList()[0].Interest.Should().Be("B");
            context.Set <User>().ToList()[0].LocationLocationId.Should().Be(1);
            context.Set <User>().ToList()[0].Password.Should().Be("B");
            context.Set <User>().ToList()[0].PhoneNumber.Should().Be("B");
            context.Set <User>().ToList()[0].Privacy.Should().Be("B");
            context.Set <User>().ToList()[0].Username.Should().Be("B");
            context.Set <User>().ToList()[0].Website.Should().Be("B");

            updateResponse.Record.UserId.Should().Be(1);
            updateResponse.Record.BioImgUrl.Should().Be("B");
            updateResponse.Record.Birthday.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.ContentDescription.Should().Be("B");
            updateResponse.Record.Email.Should().Be("B");
            updateResponse.Record.FullName.Should().Be("B");
            updateResponse.Record.HeaderImgUrl.Should().Be("B");
            updateResponse.Record.Interest.Should().Be("B");
            updateResponse.Record.LocationLocationId.Should().Be(1);
            updateResponse.Record.Password.Should().Be("B");
            updateResponse.Record.PhoneNumber.Should().Be("B");
            updateResponse.Record.Privacy.Should().Be("B");
            updateResponse.Record.Username.Should().Be("B");
            updateResponse.Record.Website.Should().Be("B");
        }
コード例 #8
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", 2, 2, DateTime.Parse("1/1/1988 12:00:00 AM"), "B", 2, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), "B", 2, 2, 2, "B");

            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].AboutMe.Should().Be("B");
            context.Set <User>().ToList()[0].AccountId.Should().Be(2);
            context.Set <User>().ToList()[0].Age.Should().Be(2);
            context.Set <User>().ToList()[0].CreationDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <User>().ToList()[0].DisplayName.Should().Be("B");
            context.Set <User>().ToList()[0].DownVote.Should().Be(2);
            context.Set <User>().ToList()[0].EmailHash.Should().Be("B");
            context.Set <User>().ToList()[0].LastAccessDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <User>().ToList()[0].Location.Should().Be("B");
            context.Set <User>().ToList()[0].Reputation.Should().Be(2);
            context.Set <User>().ToList()[0].UpVote.Should().Be(2);
            context.Set <User>().ToList()[0].View.Should().Be(2);
            context.Set <User>().ToList()[0].WebsiteUrl.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.AboutMe.Should().Be("B");
            updateResponse.Record.AccountId.Should().Be(2);
            updateResponse.Record.Age.Should().Be(2);
            updateResponse.Record.CreationDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.DisplayName.Should().Be("B");
            updateResponse.Record.DownVote.Should().Be(2);
            updateResponse.Record.EmailHash.Should().Be("B");
            updateResponse.Record.LastAccessDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.Location.Should().Be("B");
            updateResponse.Record.Reputation.Should().Be(2);
            updateResponse.Record.UpVote.Should().Be(2);
            updateResponse.Record.View.Should().Be(2);
            updateResponse.Record.WebsiteUrl.Should().Be("B");
        }
コード例 #9
0
        public void MapClientRequestToResponse()
        {
            var mapper = new ApiUserModelMapper();
            var model  = new ApiUserClientRequestModel();

            model.SetProperties("A", "A");
            ApiUserClientResponseModel response = mapper.MapClientRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.Password.Should().Be("A");
            response.Username.Should().Be("A");
        }
コード例 #10
0
        public virtual ApiUserClientRequestModel MapServerResponseToClientRequest(
            ApiUserServerResponseModel response)
        {
            var request = new ApiUserClientRequestModel();

            request.SetProperties(
                response.Email,
                response.Password,
                response.StripeCustomerId,
                response.SubscriptionTypeId);
            return(request);
        }
コード例 #11
0
        public void MapClientRequestToResponse()
        {
            var mapper = new ApiUserModelMapper();
            var model  = new ApiUserClientRequestModel();

            model.SetProperties("A", "A", "A", 1);
            ApiUserClientResponseModel response = mapper.MapClientRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.Email.Should().Be("A");
            response.Password.Should().Be("A");
            response.StripeCustomerId.Should().Be("A");
            response.SubscriptionTypeId.Should().Be(1);
        }
コード例 #12
0
        public virtual ApiUserClientRequestModel MapServerResponseToClientRequest(
            ApiUserServerResponseModel response)
        {
            var request = new ApiUserClientRequestModel();

            request.SetProperties(
                response.AboutMe,
                response.AccountId,
                response.Age,
                response.CreationDate,
                response.DisplayName,
                response.DownVote,
                response.EmailHash,
                response.LastAccessDate,
                response.Location,
                response.Reputation,
                response.UpVote,
                response.View,
                response.WebsiteUrl);
            return(request);
        }
コード例 #13
0
        public virtual ApiUserClientRequestModel MapServerResponseToClientRequest(
            ApiUserServerResponseModel response)
        {
            var request = new ApiUserClientRequestModel();

            request.SetProperties(
                response.BioImgUrl,
                response.Birthday,
                response.ContentDescription,
                response.Email,
                response.FullName,
                response.HeaderImgUrl,
                response.Interest,
                response.LocationLocationId,
                response.Password,
                response.PhoneNumber,
                response.Privacy,
                response.Username,
                response.Website);
            return(request);
        }
コード例 #14
0
        public void MapClientRequestToResponse()
        {
            var mapper = new ApiUserModelMapper();
            var model  = new ApiUserClientRequestModel();

            model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A", "A", "A", "A", 1, "A", "A", "A", "A", "A");
            ApiUserClientResponseModel response = mapper.MapClientRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.BioImgUrl.Should().Be("A");
            response.Birthday.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ContentDescription.Should().Be("A");
            response.Email.Should().Be("A");
            response.FullName.Should().Be("A");
            response.HeaderImgUrl.Should().Be("A");
            response.Interest.Should().Be("A");
            response.LocationLocationId.Should().Be(1);
            response.Password.Should().Be("A");
            response.PhoneNumber.Should().Be("A");
            response.Privacy.Should().Be("A");
            response.Username.Should().Be("A");
            response.Website.Should().Be("A");
        }
コード例 #15
0
        public void MapClientRequestToResponse()
        {
            var mapper = new ApiUserModelMapper();
            var model  = new ApiUserClientRequestModel();

            model.SetProperties("A", 1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", 1, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", 1, 1, 1, "A");
            ApiUserClientResponseModel response = mapper.MapClientRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.AboutMe.Should().Be("A");
            response.AccountId.Should().Be(1);
            response.Age.Should().Be(1);
            response.CreationDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.DisplayName.Should().Be("A");
            response.DownVote.Should().Be(1);
            response.EmailHash.Should().Be("A");
            response.LastAccessDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Location.Should().Be("A");
            response.Reputation.Should().Be(1);
            response.UpVote.Should().Be(1);
            response.View.Should().Be(1);
            response.WebsiteUrl.Should().Be("A");
        }