Esempio n. 1
0
        public virtual async void TestByOfficerIdFound()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiVehicleOfficerClientResponseModel> response = await client.ByVehicleOfficerByOfficerId(1);

            response.Should().NotBeEmpty();
            response[0].Id.Should().Be(1);
            response[0].OfficerId.Should().Be(1);
            response[0].VehicleId.Should().Be(1);
        }
        public virtual async void TestGetFound()
        {
            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;

            ApiUnitDispositionClientResponseModel response = await client.UnitDispositionGetAsync(1);

            response.Should().NotBeNull();
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Esempio n. 3
0
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiCallPersonClientResponseModel> response = await client.CallPersonAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].Id.Should().Be(1);
            response[0].Note.Should().Be("A");
            response[0].PersonId.Should().Be(1);
            response[0].PersonTypeId.Should().Be(1);
        }
Esempio n. 4
0
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiNoteClientResponseModel> response = await client.NoteAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].CallId.Should().Be(1);
            response[0].DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response[0].Id.Should().Be(1);
            response[0].NoteText.Should().Be("A");
            response[0].OfficerId.Should().Be(1);
        }
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiOfficerClientResponseModel> response = await client.OfficerAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].Badge.Should().Be("A");
            response[0].Email.Should().Be("A");
            response[0].FirstName.Should().Be("A");
            response[0].Id.Should().Be(1);
            response[0].LastName.Should().Be("A");
            response[0].Password.Should().Be("A");
        }
Esempio n. 6
0
        public virtual async void TestGetFound()
        {
            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;

            ApiNoteClientResponseModel response = await client.NoteGetAsync(1);

            response.Should().NotBeNull();
            response.CallId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Id.Should().Be(1);
            response.NoteText.Should().Be("A");
            response.OfficerId.Should().Be(1);
        }
        public virtual async void TestCreate()
        {
            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;

            var model = new ApiUnitDispositionClientRequestModel();

            model.SetProperties("B");
            CreateResponse <ApiUnitDispositionClientResponseModel> result = await client.UnitDispositionCreateAsync(model);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();
            context.Set <UnitDisposition>().ToList()[1].Name.Should().Be("B");

            result.Record.Name.Should().Be("B");
        }
        public virtual async void TestBulkInsert()
        {
            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;

            var model = new ApiOfficerClientRequestModel();

            model.SetProperties("B", "B", "B", "B", "B");
            var model2 = new ApiOfficerClientRequestModel();

            model2.SetProperties("C", "C", "C", "C", "C");
            var request = new List <ApiOfficerClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiOfficerClientResponseModel> > result = await client.OfficerBulkInsertAsync(request);

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

            context.Set <Officer>().ToList()[1].Badge.Should().Be("B");
            context.Set <Officer>().ToList()[1].Email.Should().Be("B");
            context.Set <Officer>().ToList()[1].FirstName.Should().Be("B");
            context.Set <Officer>().ToList()[1].LastName.Should().Be("B");
            context.Set <Officer>().ToList()[1].Password.Should().Be("B");

            context.Set <Officer>().ToList()[2].Badge.Should().Be("C");
            context.Set <Officer>().ToList()[2].Email.Should().Be("C");
            context.Set <Officer>().ToList()[2].FirstName.Should().Be("C");
            context.Set <Officer>().ToList()[2].LastName.Should().Be("C");
            context.Set <Officer>().ToList()[2].Password.Should().Be("C");
        }
        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 ApiOfficerServerModelMapper();
            ApplicationDbContext          context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IOfficerService               service = testServer.Host.Services.GetService(typeof(IOfficerService)) as IOfficerService;
            ApiOfficerServerResponseModel model   = await service.Get(1);

            ApiOfficerClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

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

            UpdateResponse <ApiOfficerClientResponseModel> updateResponse = await client.OfficerUpdateAsync(model.Id, request);

            context.Entry(context.Set <Officer>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Officer>().ToList()[0].Badge.Should().Be("B");
            context.Set <Officer>().ToList()[0].Email.Should().Be("B");
            context.Set <Officer>().ToList()[0].FirstName.Should().Be("B");
            context.Set <Officer>().ToList()[0].LastName.Should().Be("B");
            context.Set <Officer>().ToList()[0].Password.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Badge.Should().Be("B");
            updateResponse.Record.Email.Should().Be("B");
            updateResponse.Record.FirstName.Should().Be("B");
            updateResponse.Record.LastName.Should().Be("B");
            updateResponse.Record.Password.Should().Be("B");
        }
Esempio n. 10
0
        public virtual async void TestCreate()
        {
            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;

            var model = new ApiCallClientRequestModel();

            model.SetProperties(1, 1, 1, "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), 2);
            CreateResponse <ApiCallClientResponseModel> result = await client.CallCreateAsync(model);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();
            context.Set <Call>().ToList()[1].AddressId.Should().Be(1);
            context.Set <Call>().ToList()[1].CallDispositionId.Should().Be(1);
            context.Set <Call>().ToList()[1].CallStatusId.Should().Be(1);
            context.Set <Call>().ToList()[1].CallString.Should().Be("B");
            context.Set <Call>().ToList()[1].CallTypeId.Should().Be(1);
            context.Set <Call>().ToList()[1].DateCleared.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Call>().ToList()[1].DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Call>().ToList()[1].DateDispatched.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Call>().ToList()[1].QuickCallNumber.Should().Be(2);

            result.Record.AddressId.Should().Be(1);
            result.Record.CallDispositionId.Should().Be(1);
            result.Record.CallStatusId.Should().Be(1);
            result.Record.CallString.Should().Be("B");
            result.Record.CallTypeId.Should().Be(1);
            result.Record.DateCleared.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            result.Record.DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            result.Record.DateDispatched.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            result.Record.QuickCallNumber.Should().Be(2);
        }
Esempio n. 11
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());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());

            ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            var model = new ApiNoteClientRequestModel();

            model.SetProperties(1, DateTime.Parse("1/1/1988 12:00:00 AM"), "B", 1);
            var model2 = new ApiNoteClientRequestModel();

            model2.SetProperties(1, DateTime.Parse("1/1/1989 12:00:00 AM"), "C", 1);
            var request = new List <ApiNoteClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiNoteClientResponseModel> > result = await client.NoteBulkInsertAsync(request);

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

            context.Set <Note>().ToList()[1].CallId.Should().Be(1);
            context.Set <Note>().ToList()[1].DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Note>().ToList()[1].NoteText.Should().Be("B");
            context.Set <Note>().ToList()[1].OfficerId.Should().Be(1);

            context.Set <Note>().ToList()[2].CallId.Should().Be(1);
            context.Set <Note>().ToList()[2].DateCreated.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM"));
            context.Set <Note>().ToList()[2].NoteText.Should().Be("C");
            context.Set <Note>().ToList()[2].OfficerId.Should().Be(1);
        }
Esempio n. 12
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 ApiNoteServerModelMapper();
            ApplicationDbContext       context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            INoteService               service = testServer.Host.Services.GetService(typeof(INoteService)) as INoteService;
            ApiNoteServerResponseModel model   = await service.Get(1);

            ApiNoteClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

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

            UpdateResponse <ApiNoteClientResponseModel> updateResponse = await client.NoteUpdateAsync(model.Id, request);

            context.Entry(context.Set <Note>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Note>().ToList()[0].CallId.Should().Be(1);
            context.Set <Note>().ToList()[0].DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Note>().ToList()[0].NoteText.Should().Be("B");
            context.Set <Note>().ToList()[0].OfficerId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.CallId.Should().Be(1);
            updateResponse.Record.DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.NoteText.Should().Be("B");
            updateResponse.Record.OfficerId.Should().Be(1);
        }
Esempio n. 13
0
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiCallClientResponseModel> response = await client.CallAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].AddressId.Should().Be(1);
            response[0].CallDispositionId.Should().Be(1);
            response[0].CallStatusId.Should().Be(1);
            response[0].CallString.Should().Be("A");
            response[0].CallTypeId.Should().Be(1);
            response[0].DateCleared.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response[0].DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response[0].DateDispatched.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response[0].Id.Should().Be(1);
            response[0].QuickCallNumber.Should().Be(1);
        }