Beispiel #1
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());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            var mapper = new ApiSaleServerModelMapper();
            ApplicationDbContext       context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            ISaleService               service = testServer.Host.Services.GetService(typeof(ISaleService)) as ISaleService;
            ApiSaleServerResponseModel model   = await service.Get(1);

            ApiSaleClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(2, DateTime.Parse("1/1/1988 12:00:00 AM"));

            UpdateResponse <ApiSaleClientResponseModel> updateResponse = await client.SaleUpdateAsync(model.Id, request);

            context.Entry(context.Set <Sale>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Sale>().ToList()[0].CustomerId.Should().Be(2);
            context.Set <Sale>().ToList()[0].Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.CustomerId.Should().Be(2);
            updateResponse.Record.Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
        }
Beispiel #2
0
        public void MapServerResponseToRequest()
        {
            var mapper = new ApiSaleServerModelMapper();
            var model  = new ApiSaleServerResponseModel();

            model.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"));
            ApiSaleServerRequestModel response = mapper.MapServerResponseToRequest(model);

            response.Should().NotBeNull();
            response.CustomerId.Should().Be(1);
            response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
        }
Beispiel #3
0
        public void CreatePatch()
        {
            var mapper = new ApiSaleServerModelMapper();
            var model  = new ApiSaleServerRequestModel();

            model.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"));

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

            patch.ApplyTo(response);
            response.CustomerId.Should().Be(1);
            response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
        }
Beispiel #4
0
        public void MapServerResponseToRequest()
        {
            var mapper = new ApiSaleServerModelMapper();
            var model  = new ApiSaleServerResponseModel();

            model.SetProperties(1, "A", "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1);
            ApiSaleServerRequestModel response = mapper.MapServerResponseToRequest(model);

            response.Should().NotBeNull();
            response.IpAddress.Should().Be("A");
            response.Notes.Should().Be("A");
            response.SaleDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.TransactionId.Should().Be(1);
        }
Beispiel #5
0
        public void MapServerResponseToRequest()
        {
            var mapper = new ApiSaleServerModelMapper();
            var model  = new ApiSaleServerResponseModel();

            model.SetProperties(1, 1m, 1, "A", 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1);
            ApiSaleServerRequestModel response = mapper.MapServerResponseToRequest(model);

            response.Should().NotBeNull();
            response.Amount.Should().Be(1m);
            response.CutomerId.Should().Be(1);
            response.Note.Should().Be("A");
            response.PetId.Should().Be(1);
            response.SaleDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.SalesPersonId.Should().Be(1);
        }
Beispiel #6
0
        public void MapServerResponseToRequest()
        {
            var mapper = new ApiSaleServerModelMapper();
            var model  = new ApiSaleServerResponseModel();

            model.SetProperties(1, 1m, "A", "A", 1, 1, "A");
            ApiSaleServerRequestModel response = mapper.MapServerResponseToRequest(model);

            response.Should().NotBeNull();
            response.Amount.Should().Be(1m);
            response.FirstName.Should().Be("A");
            response.LastName.Should().Be("A");
            response.PaymentTypeId.Should().Be(1);
            response.PetId.Should().Be(1);
            response.Phone.Should().Be("A");
        }
Beispiel #7
0
        public void CreatePatch()
        {
            var mapper = new ApiSaleServerModelMapper();
            var model  = new ApiSaleServerRequestModel();

            model.SetProperties("A", "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1);

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

            patch.ApplyTo(response);
            response.IpAddress.Should().Be("A");
            response.Notes.Should().Be("A");
            response.SaleDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.TransactionId.Should().Be(1);
        }
Beispiel #8
0
        public void CreatePatch()
        {
            var mapper = new ApiSaleServerModelMapper();
            var model  = new ApiSaleServerRequestModel();

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

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

            patch.ApplyTo(response);
            response.Amount.Should().Be(1m);
            response.FirstName.Should().Be("A");
            response.LastName.Should().Be("A");
            response.PaymentTypeId.Should().Be(1);
            response.PetId.Should().Be(1);
            response.Phone.Should().Be("A");
        }