Esempio n. 1
0
        public virtual async void TestDelete()
        {
            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;

            IFollowingService service = testServer.Host.Services.GetService(typeof(IFollowingService)) as IFollowingService;
            var model = new ApiFollowingServerRequestModel();

            model.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), "B");
            CreateResponse <ApiFollowingServerResponseModel> createdResponse = await service.Create(model);

            createdResponse.Success.Should().BeTrue();

            ActionResponse deleteResult = await client.FollowingDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();
            ApiFollowingServerResponseModel verifyResponse = await service.Get(2);

            verifyResponse.Should().BeNull();
        }
Esempio n. 2
0
        public void MapServerRequestToResponse()
        {
            var mapper = new ApiFollowingServerModelMapper();
            var model  = new ApiFollowingServerRequestModel();

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

            response.Should().NotBeNull();
            response.DateFollowed.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Muted.Should().Be("A");
        }
Esempio n. 3
0
        public void CreatePatch()
        {
            var mapper = new ApiFollowingServerModelMapper();
            var model  = new ApiFollowingServerRequestModel();

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

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

            patch.ApplyTo(response);
            response.DateFollowed.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Muted.Should().Be("A");
        }