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 <ApiLocationClientResponseModel> response = await client.LocationAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].GpsLat.Should().Be(1);
            response[0].GpsLong.Should().Be(1);
            response[0].LocationId.Should().Be(1);
            response[0].LocationName.Should().Be("A");
        }
Пример #2
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;

            ApiFollowingClientResponseModel response = await client.FollowingGetAsync(1);

            response.Should().NotBeNull();
            response.DateFollowed.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Muted.Should().Be("A");
            response.UserId.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;

            ApiMessageClientResponseModel response = await client.MessageGetAsync(1);

            response.Should().NotBeNull();
            response.Content.Should().Be("A");
            response.MessageId.Should().Be(1);
            response.SenderUserId.Should().Be(1);
        }
        public virtual async void TestByTaggedUserIdFound()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiDirectTweetClientResponseModel> response = await client.ByDirectTweetByTaggedUserId(1);

            response.Should().NotBeEmpty();
            response[0].Content.Should().Be("A");
            response[0].Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response[0].TaggedUserId.Should().Be(1);
            response[0].Time.Should().Be(TimeSpan.Parse("01:00:00"));
            response[0].TweetId.Should().Be(1);
        }
Пример #5
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 <ApiRetweetClientResponseModel> response = await client.RetweetAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response[0].Id.Should().Be(1);
            response[0].RetwitterUserId.Should().Be(1);
            response[0].Time.Should().Be(TimeSpan.Parse("01:00:00"));
            response[0].TweetTweetId.Should().Be(1);
        }
        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 ApiMessengerClientRequestModel();

            model.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 1, TimeSpan.Parse("02:00:00"), 1, 1);
            var model2 = new ApiMessengerClientRequestModel();

            model2.SetProperties(DateTime.Parse("1/1/1989 12:00:00 AM"), 3, 1, TimeSpan.Parse("03:00:00"), 1, 1);
            var request = new List <ApiMessengerClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiMessengerClientResponseModel> > result = await client.MessengerBulkInsertAsync(request);

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

            context.Set <Messenger>().ToList()[1].Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Messenger>().ToList()[1].FromUserId.Should().Be(2);
            context.Set <Messenger>().ToList()[1].MessageId.Should().Be(1);
            context.Set <Messenger>().ToList()[1].Time.Should().Be(TimeSpan.Parse("02:00:00"));
            context.Set <Messenger>().ToList()[1].ToUserId.Should().Be(1);
            context.Set <Messenger>().ToList()[1].UserId.Should().Be(1);

            context.Set <Messenger>().ToList()[2].Date.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM"));
            context.Set <Messenger>().ToList()[2].FromUserId.Should().Be(3);
            context.Set <Messenger>().ToList()[2].MessageId.Should().Be(1);
            context.Set <Messenger>().ToList()[2].Time.Should().Be(TimeSpan.Parse("03:00:00"));
            context.Set <Messenger>().ToList()[2].ToUserId.Should().Be(1);
            context.Set <Messenger>().ToList()[2].UserId.Should().Be(1);
        }
        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 ApiFollowerClientRequestModel();

            model.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B");
            var model2 = new ApiFollowerClientRequestModel();

            model2.SetProperties("C", DateTime.Parse("1/1/1989 12:00:00 AM"), 1, 1, "C", "C");
            var request = new List <ApiFollowerClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiFollowerClientResponseModel> > result = await client.FollowerBulkInsertAsync(request);

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

            context.Set <Follower>().ToList()[1].Blocked.Should().Be("B");
            context.Set <Follower>().ToList()[1].DateFollowed.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Follower>().ToList()[1].FollowedUserId.Should().Be(1);
            context.Set <Follower>().ToList()[1].FollowingUserId.Should().Be(1);
            context.Set <Follower>().ToList()[1].FollowRequestStatu.Should().Be("B");
            context.Set <Follower>().ToList()[1].Muted.Should().Be("B");

            context.Set <Follower>().ToList()[2].Blocked.Should().Be("C");
            context.Set <Follower>().ToList()[2].DateFollowed.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM"));
            context.Set <Follower>().ToList()[2].FollowedUserId.Should().Be(1);
            context.Set <Follower>().ToList()[2].FollowingUserId.Should().Be(1);
            context.Set <Follower>().ToList()[2].FollowRequestStatu.Should().Be("C");
            context.Set <Follower>().ToList()[2].Muted.Should().Be("C");
        }
        public virtual async void TestByFollowingUserIdFound()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiFollowerClientResponseModel> response = await client.ByFollowerByFollowingUserId(1);

            response.Should().NotBeEmpty();
            response[0].Blocked.Should().Be("A");
            response[0].DateFollowed.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response[0].FollowedUserId.Should().Be(1);
            response[0].FollowingUserId.Should().Be(1);
            response[0].FollowRequestStatu.Should().Be("A");
            response[0].Id.Should().Be(1);
            response[0].Muted.Should().Be("A");
        }
        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 ApiMessengerServerModelMapper();
            ApplicationDbContext            context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IMessengerService               service = testServer.Host.Services.GetService(typeof(IMessengerService)) as IMessengerService;
            ApiMessengerServerResponseModel model   = await service.Get(1);

            ApiMessengerClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 1, TimeSpan.Parse("02:00:00"), 1, 1);

            UpdateResponse <ApiMessengerClientResponseModel> updateResponse = await client.MessengerUpdateAsync(model.Id, request);

            context.Entry(context.Set <Messenger>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Messenger>().ToList()[0].Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Messenger>().ToList()[0].FromUserId.Should().Be(2);
            context.Set <Messenger>().ToList()[0].MessageId.Should().Be(1);
            context.Set <Messenger>().ToList()[0].Time.Should().Be(TimeSpan.Parse("02:00:00"));
            context.Set <Messenger>().ToList()[0].ToUserId.Should().Be(1);
            context.Set <Messenger>().ToList()[0].UserId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.FromUserId.Should().Be(2);
            updateResponse.Record.MessageId.Should().Be(1);
            updateResponse.Record.Time.Should().Be(TimeSpan.Parse("02:00:00"));
            updateResponse.Record.ToUserId.Should().Be(1);
            updateResponse.Record.UserId.Should().Be(1);
        }
Пример #10
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 ApiFollowingClientRequestModel();

            model.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), "B");
            CreateResponse <ApiFollowingClientResponseModel> result = await client.FollowingCreateAsync(model);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();
            context.Set <Following>().ToList()[1].DateFollowed.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Following>().ToList()[1].Muted.Should().Be("B");

            result.Record.DateFollowed.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            result.Record.Muted.Should().Be("B");
        }
Пример #11
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 ApiMessageClientRequestModel();

            model.SetProperties("B", 1);
            CreateResponse <ApiMessageClientResponseModel> result = await client.MessageCreateAsync(model);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();
            context.Set <Message>().ToList()[1].Content.Should().Be("B");
            context.Set <Message>().ToList()[1].SenderUserId.Should().Be(1);

            result.Record.Content.Should().Be("B");
            result.Record.SenderUserId.Should().Be(1);
        }