예제 #1
0
        public void MapServerResponseToRequest()
        {
            var mapper = new ApiRetweetServerModelMapper();
            var model  = new ApiRetweetServerResponseModel();

            model.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("01:00:00"), 1);
            ApiRetweetServerRequestModel response = mapper.MapServerResponseToRequest(model);

            response.Should().NotBeNull();
            response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.RetwitterUserId.Should().Be(1);
            response.Time.Should().Be(TimeSpan.Parse("01:00:00"));
            response.TweetTweetId.Should().Be(1);
        }
예제 #2
0
        public void CreatePatch()
        {
            var mapper = new ApiRetweetServerModelMapper();
            var model  = new ApiRetweetServerRequestModel();

            model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("01:00:00"), 1);

            JsonPatchDocument <ApiRetweetServerRequestModel> patch = mapper.CreatePatch(model);
            var response = new ApiRetweetServerRequestModel();

            patch.ApplyTo(response);
            response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.RetwitterUserId.Should().Be(1);
            response.Time.Should().Be(TimeSpan.Parse("01:00:00"));
            response.TweetTweetId.Should().Be(1);
        }
예제 #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 ApiRetweetServerModelMapper();
            ApplicationDbContext          context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IRetweetService               service = testServer.Host.Services.GetService(typeof(IRetweetService)) as IRetweetService;
            ApiRetweetServerResponseModel model   = await service.Get(1);

            ApiRetweetClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

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

            UpdateResponse <ApiRetweetClientResponseModel> updateResponse = await client.RetweetUpdateAsync(model.Id, request);

            context.Entry(context.Set <Retweet>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Retweet>().ToList()[0].Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Retweet>().ToList()[0].RetwitterUserId.Should().Be(1);
            context.Set <Retweet>().ToList()[0].Time.Should().Be(TimeSpan.Parse("02:00:00"));
            context.Set <Retweet>().ToList()[0].TweetTweetId.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.RetwitterUserId.Should().Be(1);
            updateResponse.Record.Time.Should().Be(TimeSpan.Parse("02:00:00"));
            updateResponse.Record.TweetTweetId.Should().Be(1);
        }