public void MapServerResponseToRequest()
        {
            var mapper = new ApiAdminServerModelMapper();
            var model  = new ApiAdminServerResponseModel();

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

            response.Should().NotBeNull();
            response.Birthday.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.LastName.Should().Be("A");
            response.Phone.Should().Be("A");
            response.UserId.Should().Be(1);
        }
        public void MapServerResponseToRequest()
        {
            var mapper = new ApiAdminServerModelMapper();
            var model  = new ApiAdminServerResponseModel();

            model.SetProperties(1, "A", "A", "A", "A", "A", "A");
            ApiAdminServerRequestModel response = mapper.MapServerResponseToRequest(model);

            response.Should().NotBeNull();
            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.LastName.Should().Be("A");
            response.Password.Should().Be("A");
            response.Phone.Should().Be("A");
            response.Username.Should().Be("A");
        }
        public void CreatePatch()
        {
            var mapper = new ApiAdminServerModelMapper();
            var model  = new ApiAdminServerRequestModel();

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

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

            patch.ApplyTo(response);
            response.Birthday.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.LastName.Should().Be("A");
            response.Phone.Should().Be("A");
            response.UserId.Should().Be(1);
        }
        public void CreatePatch()
        {
            var mapper = new ApiAdminServerModelMapper();
            var model  = new ApiAdminServerRequestModel();

            model.SetProperties("A", "A", "A", "A", "A", "A");

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

            patch.ApplyTo(response);
            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.LastName.Should().Be("A");
            response.Password.Should().Be("A");
            response.Phone.Should().Be("A");
            response.Username.Should().Be("A");
        }
Пример #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 ApiAdminServerModelMapper();
            ApplicationDbContext        context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IAdminService               service = testServer.Host.Services.GetService(typeof(IAdminService)) as IAdminService;
            ApiAdminServerResponseModel model   = await service.Get(1);

            ApiAdminClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

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

            UpdateResponse <ApiAdminClientResponseModel> updateResponse = await client.AdminUpdateAsync(model.Id, request);

            context.Entry(context.Set <Admin>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Admin>().ToList()[0].Email.Should().Be("B");
            context.Set <Admin>().ToList()[0].FirstName.Should().Be("B");
            context.Set <Admin>().ToList()[0].LastName.Should().Be("B");
            context.Set <Admin>().ToList()[0].Password.Should().Be("B");
            context.Set <Admin>().ToList()[0].Phone.Should().Be("B");
            context.Set <Admin>().ToList()[0].Username.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Email.Should().Be("B");
            updateResponse.Record.FirstName.Should().Be("B");
            updateResponse.Record.LastName.Should().Be("B");
            updateResponse.Record.Password.Should().Be("B");
            updateResponse.Record.Phone.Should().Be("B");
            updateResponse.Record.Username.Should().Be("B");
        }