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;

            IVenueService service = testServer.Host.Services.GetService(typeof(IVenueService)) as IVenueService;
            var           model   = new ApiVenueServerRequestModel();

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

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

            ActionResponse deleteResult = await client.VenueDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
Beispiel #2
0
        public async Task <Venue> Get(int id)
        {
            try
            {
                var result = await _venueService.Get(id);

                return(VenueParser.ToVenueContract(result));
            }
            catch (VenueException exception)
            {
                var fault = new ServiceValidationFaultDetails {
                    Message = "Get venue error"
                };
                throw new FaultException <ServiceValidationFaultDetails>(fault, exception.Message);
            }
        }
        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 ApiVenueServerModelMapper();
            ApplicationDbContext        context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IVenueService               service = testServer.Host.Services.GetService(typeof(IVenueService)) as IVenueService;
            ApiVenueServerResponseModel model   = await service.Get(1);

            ApiVenueClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

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

            UpdateResponse <ApiVenueClientResponseModel> updateResponse = await client.VenueUpdateAsync(model.Id, request);

            context.Entry(context.Set <Venue>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Venue>().ToList()[0].Address1.Should().Be("B");
            context.Set <Venue>().ToList()[0].Address2.Should().Be("B");
            context.Set <Venue>().ToList()[0].AdminId.Should().Be(1);
            context.Set <Venue>().ToList()[0].Email.Should().Be("B");
            context.Set <Venue>().ToList()[0].Facebook.Should().Be("B");
            context.Set <Venue>().ToList()[0].Name.Should().Be("B");
            context.Set <Venue>().ToList()[0].Phone.Should().Be("B");
            context.Set <Venue>().ToList()[0].ProvinceId.Should().Be(1);
            context.Set <Venue>().ToList()[0].Website.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Address1.Should().Be("B");
            updateResponse.Record.Address2.Should().Be("B");
            updateResponse.Record.AdminId.Should().Be(1);
            updateResponse.Record.Email.Should().Be("B");
            updateResponse.Record.Facebook.Should().Be("B");
            updateResponse.Record.Name.Should().Be("B");
            updateResponse.Record.Phone.Should().Be("B");
            updateResponse.Record.ProvinceId.Should().Be(1);
            updateResponse.Record.Website.Should().Be("B");
        }