public virtual ApiArtistClientRequestModel MapServerResponseToClientRequest(
            ApiArtistServerResponseModel response)
        {
            var request = new ApiArtistClientRequestModel();

            request.SetProperties(
                response.AspNetUserId,
                response.Bio,
                response.ExternalId,
                response.Facebook,
                response.Name,
                response.SoundCloud,
                response.Twitter,
                response.Venmo,
                response.Website);
            return(request);
        }
Esempio n. 2
0
        public virtual async void TestBulkInsert()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer           testServer = new TestServer(builder);
            var                  client     = new ApiClient(testServer.CreateClient());
            ApplicationDbContext context    = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            var model = new ApiArtistClientRequestModel();

            model.SetProperties("B", "B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B", "B", "B", "B", "B", "B");
            var model2 = new ApiArtistClientRequestModel();

            model2.SetProperties("C", "C", Guid.Parse("8d721ec8-4c9d-632f-6f06-7f89cc14862c"), "C", "C", "C", "C", "C", "C");
            var request = new List <ApiArtistClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiArtistClientResponseModel> > result = await client.ArtistBulkInsertAsync(request);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();

            context.Set <Artist>().ToList()[1].AspNetUserId.Should().Be("B");
            context.Set <Artist>().ToList()[1].Bio.Should().Be("B");
            context.Set <Artist>().ToList()[1].ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <Artist>().ToList()[1].Facebook.Should().Be("B");
            context.Set <Artist>().ToList()[1].Name.Should().Be("B");
            context.Set <Artist>().ToList()[1].SoundCloud.Should().Be("B");
            context.Set <Artist>().ToList()[1].Twitter.Should().Be("B");
            context.Set <Artist>().ToList()[1].Venmo.Should().Be("B");
            context.Set <Artist>().ToList()[1].Website.Should().Be("B");

            context.Set <Artist>().ToList()[2].AspNetUserId.Should().Be("C");
            context.Set <Artist>().ToList()[2].Bio.Should().Be("C");
            context.Set <Artist>().ToList()[2].ExternalId.Should().Be(Guid.Parse("8d721ec8-4c9d-632f-6f06-7f89cc14862c"));
            context.Set <Artist>().ToList()[2].Facebook.Should().Be("C");
            context.Set <Artist>().ToList()[2].Name.Should().Be("C");
            context.Set <Artist>().ToList()[2].SoundCloud.Should().Be("C");
            context.Set <Artist>().ToList()[2].Twitter.Should().Be("C");
            context.Set <Artist>().ToList()[2].Venmo.Should().Be("C");
            context.Set <Artist>().ToList()[2].Website.Should().Be("C");
        }
Esempio n. 3
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());
            var mapper = new ApiArtistServerModelMapper();
            ApplicationDbContext         context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IArtistService               service = testServer.Host.Services.GetService(typeof(IArtistService)) as IArtistService;
            ApiArtistServerResponseModel model   = await service.Get(1);

            ApiArtistClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties("B", "B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B", "B", "B", "B", "B", "B");

            UpdateResponse <ApiArtistClientResponseModel> updateResponse = await client.ArtistUpdateAsync(model.Id, request);

            context.Entry(context.Set <Artist>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Artist>().ToList()[0].AspNetUserId.Should().Be("B");
            context.Set <Artist>().ToList()[0].Bio.Should().Be("B");
            context.Set <Artist>().ToList()[0].ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <Artist>().ToList()[0].Facebook.Should().Be("B");
            context.Set <Artist>().ToList()[0].Name.Should().Be("B");
            context.Set <Artist>().ToList()[0].SoundCloud.Should().Be("B");
            context.Set <Artist>().ToList()[0].Twitter.Should().Be("B");
            context.Set <Artist>().ToList()[0].Venmo.Should().Be("B");
            context.Set <Artist>().ToList()[0].Website.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.AspNetUserId.Should().Be("B");
            updateResponse.Record.Bio.Should().Be("B");
            updateResponse.Record.ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            updateResponse.Record.Facebook.Should().Be("B");
            updateResponse.Record.Name.Should().Be("B");
            updateResponse.Record.SoundCloud.Should().Be("B");
            updateResponse.Record.Twitter.Should().Be("B");
            updateResponse.Record.Venmo.Should().Be("B");
            updateResponse.Record.Website.Should().Be("B");
        }
Esempio n. 4
0
        public void MapClientRequestToResponse()
        {
            var mapper = new ApiArtistModelMapper();
            var model  = new ApiArtistClientRequestModel();

            model.SetProperties("A", "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A", "A", "A", "A", "A", "A");
            ApiArtistClientResponseModel response = mapper.MapClientRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.AspNetUserId.Should().Be("A");
            response.Bio.Should().Be("A");
            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.Facebook.Should().Be("A");
            response.Name.Should().Be("A");
            response.SoundCloud.Should().Be("A");
            response.Twitter.Should().Be("A");
            response.Venmo.Should().Be("A");
            response.Website.Should().Be("A");
        }