示例#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;

            IFamilyService service = testServer.Host.Services.GetService(typeof(IFamilyService)) as IFamilyService;
            var            model   = new ApiFamilyServerRequestModel();

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

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

            ActionResponse deleteResult = await client.FamilyDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
示例#2
0
        public void MapServerRequestToResponse()
        {
            var mapper = new ApiFamilyServerModelMapper();
            var model  = new ApiFamilyServerRequestModel();

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

            response.Should().NotBeNull();
            response.Notes.Should().Be("A");
            response.PrimaryContactEmail.Should().Be("A");
            response.PrimaryContactFirstName.Should().Be("A");
            response.PrimaryContactLastName.Should().Be("A");
            response.PrimaryContactPhone.Should().Be("A");
        }
示例#3
0
        public void CreatePatch()
        {
            var mapper = new ApiFamilyServerModelMapper();
            var model  = new ApiFamilyServerRequestModel();

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

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

            patch.ApplyTo(response);
            response.Notes.Should().Be("A");
            response.PrimaryContactEmail.Should().Be("A");
            response.PrimaryContactFirstName.Should().Be("A");
            response.PrimaryContactLastName.Should().Be("A");
            response.PrimaryContactPhone.Should().Be("A");
        }