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

            IOfficerService service = testServer.Host.Services.GetService(typeof(IOfficerService)) as IOfficerService;
            var             model   = new ApiOfficerServerRequestModel();

            model.SetProperties("B", "B", "B", "B", "B");
            CreateResponse <ApiOfficerServerResponseModel> createdResponse = await service.Create(model);

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

            ActionResponse deleteResult = await client.OfficerDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
        public void MapServerRequestToResponse()
        {
            var mapper = new ApiOfficerServerModelMapper();
            var model  = new ApiOfficerServerRequestModel();

            model.SetProperties("A", "A", "A", "A", "A");
            ApiOfficerServerResponseModel response = mapper.MapServerRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.Badge.Should().Be("A");
            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.LastName.Should().Be("A");
            response.Password.Should().Be("A");
        }
        public void CreatePatch()
        {
            var mapper = new ApiOfficerServerModelMapper();
            var model  = new ApiOfficerServerRequestModel();

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

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

            patch.ApplyTo(response);
            response.Badge.Should().Be("A");
            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.LastName.Should().Be("A");
            response.Password.Should().Be("A");
        }