예제 #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;

            IAddressService service = testServer.Host.Services.GetService(typeof(IAddressService)) as IAddressService;
            var             model   = new ApiAddressServerRequestModel();

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

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

            ActionResponse deleteResult = await client.AddressDeleteAsync(2);

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

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

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

            response.Should().NotBeNull();
            response.Address1.Should().Be("A");
            response.Address2.Should().Be("A");
            response.City.Should().Be("A");
            response.State.Should().Be("A");
            response.Zip.Should().Be("A");
        }
        public void CreatePatch()
        {
            var mapper = new ApiAddressServerModelMapper();
            var model  = new ApiAddressServerRequestModel();

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

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

            patch.ApplyTo(response);
            response.Address1.Should().Be("A");
            response.Address2.Should().Be("A");
            response.City.Should().Be("A");
            response.State.Should().Be("A");
            response.Zip.Should().Be("A");
        }